Show / Hide Table of Contents

    Class Box

    A geometry type representing an oriented cuboid in space.

    Examples
    var box1 = new Box((-1, -1, -1), (1, 1, 1));
    var box2 = new Box((6, 7, 8), (9, 12, 15), new Transform().Rotated(new Vector3(1, 1, 1).Unitized(), 30));
    
    var circle = new Circle((0, 0, 0), 1);
    var polygon = circle.ToPolygon(20);
    var mappedPolygon = polygon.TransformedPolygon(Elements.Geometry.Box.TransformBetween(box1, box2));
    
    Inheritance
    System.Object
    Box
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Elements.Geometry
    Assembly: Hypar.Elements.dll
    Syntax
    public class Box

    Constructors

    Box(BBox3, Transform)

    Create a new box from a bounding box.

    Declaration
    [JsonConstructor]
    public Box(BBox3 box = default(BBox3), Transform transform = null)
    Parameters
    Type Name Description
    BBox3 box

    The world-oriented bounding box.

    Transform transform

    If supplied, the transform indicating the box's local coordinate frame.

    Box(Box)

    Make a new box as a copy of the supplied box.

    Declaration
    public Box(Box other)
    Parameters
    Type Name Description
    Box other

    The box to copy.

    Box(Vector3, Vector3, Transform)

    Create a new box from a minimum and maximum point in world coordinates, and an optional Transform indicating the orientation frame of the box.

    Declaration
    public Box(Vector3 min, Vector3 max, Transform transform = null)
    Parameters
    Type Name Description
    Vector3 min

    The minimum point of the box, in world coordinates.

    Vector3 max

    The maximum point of the box, in world coordinates.

    Transform transform

    If supplied, the transform indicating the box's origin and orientation.

    Box(IEnumerable<Vector3>, Transform)

    Construct a box from a collection of points and a transform to specify the box's orientation.

    Declaration
    public Box(IEnumerable<Vector3> points, Transform transform)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<Vector3> points
    Transform transform

    Properties

    Bounds

    A BBox3 representing the extents of this box, expressed in coordinates relative to the box's transform.

    Declaration
    public BBox3 Bounds { get; set; }
    Property Value
    Type Description
    BBox3

    Max

    The (0,0,0) corner of the box, in world coordinates

    Declaration
    public Vector3 Max { get; }
    Property Value
    Type Description
    Vector3

    Min

    The (0,0,0) corner of the box, in world coordinates

    Declaration
    public Vector3 Min { get; }
    Property Value
    Type Description
    Vector3

    Transform

    The Transform indicating the local coordinate frame of this box. Do not modify this transform directly to modify the box, instead use TransformBox().

    Declaration
    public Transform Transform { get; set; }
    Property Value
    Type Description
    Transform

    Volume

    The volume of the box. Note that this value will be inaccurate if using a non-euclidean transform.

    Declaration
    [JsonIgnore]
    public double Volume { get; }
    Property Value
    Type Description
    System.Double

    Methods

    BoxToUVW()

    Get the transform that maps geometry from this box to a normalized, world-oriented unit cube at the origin (the UVW coordinate space of the box).

    Declaration
    public Transform BoxToUVW()
    Returns
    Type Description
    Transform

    IsValid()

    Check if this box has a valid transform and bounds.

    Declaration
    public bool IsValid()
    Returns
    Type Description
    System.Boolean

    PointAt(Vector3)

    Get a point from this box by supplying a vector specifying normalized parameters from 0 to 1. A point at (0,0,0) will be the minimum point of the box, a point at (1,1,1) will be the maximum point, and a point at (0.5,0.5,0.5) will be the center.

    Declaration
    public Vector3 PointAt(Vector3 uvw)
    Parameters
    Type Name Description
    Vector3 uvw

    The vector in the box's parametric UVW coordinate space.

    Returns
    Type Description
    Vector3

    A point in world coordinates.

    PointAt(Double, Double, Double)

    Get a point from this bounding box by supplying normalized parameters from 0 to 1. A point at (0,0,0) will be the minimum point of the box, a point at (1,1,1) will be the maximum point, and a point at (0.5,0.5,0.5) will be the center.

    Declaration
    public Vector3 PointAt(double u, double v, double w)
    Parameters
    Type Name Description
    System.Double u

    The u parameter at which to evaluate the box.

    System.Double v

    The v parameter at which to evaluate the box.

    System.Double w

    The w parameter at which to evaluate the box.

    Returns
    Type Description
    Vector3

    A point in world coordinates.

    ToModelCurves(Material)

    Convert a Box to a set of model curves.

    Declaration
    public List<ModelCurve> ToModelCurves(Material material = null)
    Parameters
    Type Name Description
    Material material

    An optional material to use for these curves.

    Returns
    Type Description
    System.Collections.Generic.List<ModelCurve>

    TransformAt(Double, Double, Double)

    Get a transform from this bounding box by supplying normalized parameters from 0 to 1. A point at (0,0,0) will be a transform at the minimum point of the bounding box, a point at (1,1,1) will be at the maximum point, and a point at (0.5,0.5,0.5) will be at the center.

    Declaration
    public Transform TransformAt(double u, double v, double w)
    Parameters
    Type Name Description
    System.Double u

    The u parameter at which to evaluate the box.

    System.Double v

    The v parameter at which to evaluate the box.

    System.Double w

    The w parameter at which to evaluate the box.

    Returns
    Type Description
    Transform

    TransformBetween(Box, Box)

    Get the transform that maps geometry from one box to another.

    Declaration
    public static Transform TransformBetween(Box from, Box to)
    Parameters
    Type Name Description
    Box from
    Box to
    Returns
    Type Description
    Transform

    TransformBox(Transform)

    Transform this box.

    Declaration
    public void TransformBox(Transform transform)
    Parameters
    Type Name Description
    Transform transform

    The transform to apply.

    Transformed(Transform)

    Return a new box transformed by the supplied transform.

    Declaration
    public Box Transformed(Transform transform)
    Parameters
    Type Name Description
    Transform transform

    The transform to apply.

    Returns
    Type Description
    Box

    A transformed copy of the box.

    UVWAtPoint(Vector3)

    For a point in world coordinates, get the corresponding vector in the box's parametric UVW coordinate space.

    Declaration
    public Vector3 UVWAtPoint(Vector3 point)
    Parameters
    Type Name Description
    Vector3 point

    A point in world coordinates.

    Returns
    Type Description
    Vector3

    A Vector3 representing the corresponding U,V,W coordinates in the box's coordinate space.

    UVWToBox()

    Get the transform that maps geometry from a normalized, world-oriented unit cube at the origin (the UVW coordinate space of the box) to this box.

    Declaration
    public Transform UVWToBox()
    Returns
    Type Description
    Transform

    Operators

    Implicit(BBox3 to Box)

    Automatically convert a Bbox3 to a Box.

    Declaration
    public static implicit operator Box(BBox3 bbox)
    Parameters
    Type Name Description
    BBox3 bbox

    A bounding box.

    Returns
    Type Description
    Box