Show / Hide Table of Contents

    Class Transform

    A right-handed coordinate system with +Z up.

    Examples
    var m1 = new Mass(Polygon.Rectangle(1.0, 1.0), 1.0, new Material("yellow", Colors.Yellow));
    this.Model.AddElement(m1);
    
    Profile prof = Polygon.Rectangle(1.0, 1.0);
    
    var j = 1.0;
    var count = 10;
    for (var i = 0.0; i < 360.0; i += 360.0 / (double)count)
    {
        var m2 = new Mass(prof, 1.0, new Material($"color_{j}", new Color((float)j - 1.0f, 0.0f, 0.0f, 1.0f)), new Transform());
    
        // Scale the mass.
        m2.Transform.Scale(new Vector3(j, j, j));
    
        // Move the mass.
        m2.Transform.Move(new Vector3(3, 0, 0));
    
        // Rotate the mass.
        m2.Transform.Rotate(Vector3.ZAxis, i);
        this.Model.AddElement(m2);
        j += 1.0 / (double)count;
    }
    
    Inheritance
    System.Object
    Transform
    Implements
    System.IEquatable<Transform>
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: Elements.Geometry
    Assembly: Hypar.Elements.dll
    Syntax
    public class Transform : IEquatable<Transform>

    Constructors

    Transform()

    Create the identity transform.

    Declaration
    public Transform()

    Transform(Matrix)

    Construct a transform.

    Declaration
    [JsonConstructor]
    public Transform(Matrix matrix)
    Parameters
    Type Name Description
    Matrix matrix

    Transform(Plane)

    Create a transform using the provided plane's origin and normal.

    Declaration
    public Transform(Plane plane)
    Parameters
    Type Name Description
    Plane plane

    The plane used to orient the transform.

    Transform(Transform)

    Create a transform by copying another transform.

    Declaration
    public Transform(Transform t)
    Parameters
    Type Name Description
    Transform t

    The transform to copy.

    Transform(Vector3, Vector3, Vector3, Vector3)

    Create a transform by origin, X, Y, and Z axes. Axes are automatically unitized — to create non-uniform transforms, use Transform.Scale.

    Declaration
    public Transform(Vector3 origin, Vector3 xAxis, Vector3 yAxis, Vector3 zAxis)
    Parameters
    Type Name Description
    Vector3 origin

    The origin of the transform.

    Vector3 xAxis

    The X axis of the transform.

    Vector3 yAxis

    The Y axis of the transform.

    Vector3 zAxis

    The Z axis of the transform.

    Transform(Vector3, Vector3, Vector3, Double)

    Create a transform by origin and X and Z axes.

    Declaration
    public Transform(Vector3 origin, Vector3 xAxis, Vector3 zAxis, double rotation = 0)
    Parameters
    Type Name Description
    Vector3 origin

    The origin of the transform.

    Vector3 xAxis

    The X axis of the transform.

    Vector3 zAxis

    The Z axis of the transform.

    System.Double rotation

    An optional rotation in degrees around the transform's z axis.

    Transform(Vector3, Vector3, Double)

    Create a transform centered at origin with its Z axis pointing along up.

    Declaration
    public Transform(Vector3 origin, Vector3 z, double rotation = 0)
    Parameters
    Type Name Description
    Vector3 origin

    The origin of the transform.

    Vector3 z

    The vector which will define the Z axis of the transform.

    System.Double rotation

    An optional rotation around the z axis.

    Transform(Vector3, Double)

    Create a transform with a translation.

    Declaration
    public Transform(Vector3 origin, double rotation = 0)
    Parameters
    Type Name Description
    Vector3 origin

    The origin of the transform.

    System.Double rotation

    An optional rotation in degrees around the transform's z axis.

    Transform(Double, Double, Double, Double)

    Create a transform with a translation.

    Declaration
    public Transform(double x, double y, double z, double rotation = 0)
    Parameters
    Type Name Description
    System.Double x

    The X component of translation.

    System.Double y

    The Y component of translation.

    System.Double z

    The Z component of translation.

    System.Double rotation

    An optional rotation in degrees around the transform's z axis.

    Properties

    Matrix

    The transform's matrix.

    Declaration
    [JsonProperty("Matrix", Required = Required.Always)]
    [Required]
    public Matrix Matrix { get; set; }
    Property Value
    Type Description
    Matrix

    Origin

    The origin of the transform.

    Declaration
    [JsonIgnore]
    public Vector3 Origin { get; }
    Property Value
    Type Description
    Vector3

    XAxis

    The x axis of the transform.

    Declaration
    [JsonIgnore]
    public Vector3 XAxis { get; }
    Property Value
    Type Description
    Vector3

    YAxis

    The y axis of the transform.

    Declaration
    [JsonIgnore]
    public Vector3 YAxis { get; }
    Property Value
    Type Description
    Vector3

    ZAxis

    The z axis of the transform.

    Declaration
    [JsonIgnore]
    public Vector3 ZAxis { get; }
    Property Value
    Type Description
    Vector3

    Methods

    Concatenate(Transform)

    Concatenate the transform.

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

    Concatenated(Transform)

    Return a new transform which is the supplied transform concatenated to this transform.

    Declaration
    public Transform Concatenated(Transform transform)
    Parameters
    Type Name Description
    Transform transform

    The transform to concatenate.

    Returns
    Type Description
    Transform

    CreateHorizontalFrameAlongCurve(Curve, Double, Vector3)

    Create a transform that is oriented along a curve at parameter t. The transform's +z axis will align with the +z world axis, and the +x axis will align with the XY projection of the tangent of the curve. If you want a perpendicular transform, use Curve.TransformAt(t) instead.

    Declaration
    public static Transform CreateHorizontalFrameAlongCurve(Curve curve, double t, Vector3 up = default(Vector3))
    Parameters
    Type Name Description
    Curve curve

    The curve along which to orient the transform.

    System.Double t

    A parameter value between 0.0 and 1.0.

    Vector3 up
    Returns
    Type Description
    Transform

    CreateOrientedAlongCurve(Curve, Double, Vector3)

    Create a transform that is oriented along a curve at parameter t. The transform's +z axis will align with the +z world axis, and the +x axis will align with the tangent of the curve. If you want a perpendicular transform, use Curve.TransformAt(t) instead.

    Declaration
    [Obsolete]
    public static Transform CreateOrientedAlongCurve(Curve curve, double t, Vector3 up = default(Vector3))
    Parameters
    Type Name Description
    Curve curve

    The curve along which to orient the transform.

    System.Double t

    A parameter value between 0.0 and 1.0.

    Vector3 up
    Returns
    Type Description
    Transform

    Equals(Transform)

    Is this transform equal to the provided transform?

    Declaration
    public bool Equals(Transform other)
    Parameters
    Type Name Description
    Transform other

    The transform to test.

    Returns
    Type Description
    System.Boolean

    True if the two transforms are equal, otherwise false.

    GetHashCode()

    Get the hash code for the transform.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32
    Overrides
    System.Object.GetHashCode()

    GetScale()

    Get the scale of the transform.

    Declaration
    public Vector3 GetScale()
    Returns
    Type Description
    Vector3

    Invert()

    Invert this transform.

    Declaration
    public void Invert()

    Inverted()

    Return a new transform which is the inverse of this transform.

    Declaration
    public Transform Inverted()
    Returns
    Type Description
    Transform

    Move(Vector3)

    Apply a translation to the transform.

    Declaration
    public void Move(Vector3 translation)
    Parameters
    Type Name Description
    Vector3 translation

    The translation to apply.

    Move(Double, Double, Double)

    Apply a translation to the transform.

    Declaration
    public void Move(double x = 0, double y = 0, double z = 0)
    Parameters
    Type Name Description
    System.Double x
    System.Double y
    System.Double z

    Moved(Vector3)

    Return a new transform which is this transform moved by the specified amount.

    Declaration
    public Transform Moved(Vector3 translation)
    Parameters
    Type Name Description
    Vector3 translation

    The translation to apply.

    Returns
    Type Description
    Transform

    Moved(Double, Double, Double)

    Return a new transform which is this transform moved by the specified amount.

    Declaration
    public Transform Moved(double x = 0, double y = 0, double z = 0)
    Parameters
    Type Name Description
    System.Double x
    System.Double y
    System.Double z
    Returns
    Type Description
    Transform

    OfBezier(Bezier)

    Transform the specifed bezier.

    Declaration
    [Obsolete("Use Bezier.Transformed(Transform) instead.")]
    public Bezier OfBezier(Bezier bezier)
    Parameters
    Type Name Description
    Bezier bezier

    The bezier to transform.

    Returns
    Type Description
    Bezier

    A new bezier transformed by this transform.

    OfCurve(Curve)

    A transformed copy of the supplied curve.

    Declaration
    [Obsolete("Use Curve.Transformed(Transform) instead.")]
    public Curve OfCurve(Curve curve)
    Parameters
    Type Name Description
    Curve curve

    The curve to transform.

    Returns
    Type Description
    Curve

    OfLine(Line)

    Transform the specified line.

    Declaration
    [Obsolete("Use Line.Transformed(Transform) instead.")]
    public Line OfLine(Line line)
    Parameters
    Type Name Description
    Line line

    The line to transform.

    Returns
    Type Description
    Line

    A new line transformed by this transform.

    OfPlane(Plane)

    Transform the specified plane.

    Declaration
    public Plane OfPlane(Plane plane)
    Parameters
    Type Name Description
    Plane plane

    The plane to transform.

    Returns
    Type Description
    Plane

    A new plane transformed by this transform.

    OfPoint(Vector3)

    Transform a vector into the coordinate space defined by this transform.

    Declaration
    public Vector3 OfPoint(Vector3 vector)
    Parameters
    Type Name Description
    Vector3 vector

    The vector to transform.

    Returns
    Type Description
    Vector3

    A new vector transformed by this transform.

    OfPolygon(Polygon)

    Transform the specified polygon.

    Declaration
    [Obsolete("Use Polygon.Transformed(Transform) instead.")]
    public Polygon OfPolygon(Polygon polygon)
    Parameters
    Type Name Description
    Polygon polygon

    The polygon to transform.

    Returns
    Type Description
    Polygon

    A new polygon transformed by this transform.

    OfPolygons(IList<Polygon>)

    Transform the specified polygons.

    Declaration
    public Polygon[] OfPolygons(IList<Polygon> polygons)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Polygon> polygons

    The polygons to transform.

    Returns
    Type Description
    Polygon[]

    An array of polygons transformed by this transform.

    OfProfile(Profile)

    Transform the specified profile.

    Declaration
    public Profile OfProfile(Profile profile)
    Parameters
    Type Name Description
    Profile profile

    The profile to transform.

    Returns
    Type Description
    Profile

    A new profile transformed by this transform.

    OfVector(Vector3)

    Transform a vector into the coordinate space defined by this transform ignoring the translation.

    Declaration
    public Vector3 OfVector(Vector3 vector)
    Parameters
    Type Name Description
    Vector3 vector

    The vector to transform.

    Returns
    Type Description
    Vector3

    A new vector transformed by this transform.

    Reflect(Vector3)

    Reflect about the plane with normal n.

    Declaration
    public void Reflect(Vector3 n)
    Parameters
    Type Name Description
    Vector3 n

    The normal of the reflection plane.

    Rotate(Vector3, Double)

    Apply a rotation to the transform.

    Declaration
    public void Rotate(Vector3 axis, double angle)
    Parameters
    Type Name Description
    Vector3 axis

    The axis of rotation.

    System.Double angle

    The angle of rotation in degrees.

    Rotate(Double)

    Apply a rotation to the transform around the Z axis.

    Declaration
    public void Rotate(double angle)
    Parameters
    Type Name Description
    System.Double angle

    The angle of rotation in degrees.

    RotateAboutPoint(Vector3, Vector3, Double)

    Apply a rotation to the transform about a center.

    Declaration
    public void RotateAboutPoint(Vector3 point, Vector3 axis, double angle)
    Parameters
    Type Name Description
    Vector3 point

    The center of rotation.

    Vector3 axis

    The axis direction.

    System.Double angle

    The angle of rotation in degrees.

    Rotated(Vector3, Double)

    Return a new transform which is a rotated copy of this transform.

    Declaration
    public Transform Rotated(Vector3 axis, double angle)
    Parameters
    Type Name Description
    Vector3 axis

    The axis of rotation.

    System.Double angle

    The angle of rotation in degrees.

    Returns
    Type Description
    Transform

    RotatedAboutPoint(Vector3, Vector3, Double)

    Return a new Transform which is a rotated copy of this transform.

    Declaration
    public Transform RotatedAboutPoint(Vector3 point, Vector3 axis, double angle)
    Parameters
    Type Name Description
    Vector3 point

    The center of rotation.

    Vector3 axis

    The axis direction.

    System.Double angle

    The angle of rotation in degrees.

    Returns
    Type Description
    Transform

    Scale(Vector3)

    Apply a scale to the transform.

    Declaration
    public void Scale(Vector3 amount)
    Parameters
    Type Name Description
    Vector3 amount

    The amount to scale.

    Scale(Double)

    Scale uniformly about the origin.

    Declaration
    public void Scale(double factor)
    Parameters
    Type Name Description
    System.Double factor

    The amount to scale uniformly

    Scale(Double, Vector3)

    Scale uniformly about a point

    Declaration
    public void Scale(double factor, Vector3 origin)
    Parameters
    Type Name Description
    System.Double factor

    The scale factor

    Vector3 origin

    The origin of scaling

    Scaled(Vector3)

    Return a copy of this transform scaled by the given value.

    Declaration
    public Transform Scaled(Vector3 amount)
    Parameters
    Type Name Description
    Vector3 amount

    The amount to scale.

    Returns
    Type Description
    Transform

    Scaled(Double)

    Return a copy of this transform scaled uniformly.

    Declaration
    public Transform Scaled(double factor)
    Parameters
    Type Name Description
    System.Double factor

    The amount to scale uniformly

    Returns
    Type Description
    Transform

    ToString()

    Get a string representation of the transform.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    A string representation of the transform.

    Overrides
    System.Object.ToString()

    XY()

    Calculate XY plane of the transform.

    Declaration
    public Plane XY()
    Returns
    Type Description
    Plane

    XZ()

    Calculate the XZ plane of the transform.

    Declaration
    public Plane XZ()
    Returns
    Type Description
    Plane

    YZ()

    Calculate the YZ plane of the transform.

    Declaration
    public Plane YZ()
    Returns
    Type Description
    Plane

    Implements

    System.IEquatable<T>

    Extension Methods

    ModelCurveExtensions.ToModelCurves(Transform, Transform)