Plane3D
A robust representation of 3D planes for defining element orientations in space.
The Plane3D class provides a robust representation of a 3D plane defined by an origin point and three mutually perpendicular axes (X, Y, Z). The Z axis represents the plane's normal vector. This class is particularly useful for defining the orientation of elements like circles, arcs, text, and dimensions in 3D space.
/// Represents a 3D plane defined by an origin point and three mutually perpendicular axes (X, Y, Z).
/// The Z axis represents the plane's normal.
public class Plane3D
{
// Constructors
public Plane3D() { }
public Plane3D(Vector3 origin, Vector3 normal) { }
public Plane3D(Vector3 origin, Vector3 axisX, Vector3 axisY) { }
// Important Properties
public Vector3 Origin { get; set; } // The origin point of the plane.
public Vector3 AxisX { get; set; } // The X axis of the plane. Must be perpendicular to Y and Z axes and have a length of 1.
public Vector3 AxisY { get; set; } // The Y axis of the plane. Must be perpendicular to X and Z axes and have a length of 1.
public Vector3 AxisZ { get; set; } // The Z axis (normal) of the plane. Must be perpendicular to X and Y axes and have a length of 1.
// Predefined Static Instances
public static Plane3D WorldXY { get; }
public static Plane3D WorldYZ { get; }
public static Plane3D WorldXZ { get; }
}
# Coming soon...
Basic Usage Examples
// Using static predefined planes
var horizontalCircle = new Circle
{
Center = new Vector3(100, 100, 0),
Radius = 50,
Plane = Plane3D.WorldXY // Circle lies in the XY plane (default)
};
// Creating a vertical plane for a circle
var verticalPlane = new Plane3D(
origin: new Vector3(0, 0, 0),
normal: Vector3.UnitX // Normal points along X axis
);
var verticalCircle = new Circle
{
Center = new Vector3(0, 100, 100),
Radius = 50,
Plane = verticalPlane // Circle lies in the YZ plane
};
// Creating an angled plane for text
var textPlane = new Plane3D(
origin: new Vector3(100, 0, 0),
axisX: Vector3.Normalize(new Vector3(1, 1, 0)), // 45° in XY plane
axisY: Vector3.UnitZ
);
var angledText = new Text
{
InsertionPoint = textPlane.Origin,
TextString = "Angled Text",
Height = 10,
Plane = textPlane // Text oriented at 45° around Z
};
// Using a plane for an arc
var arcPlane = new Plane3D(
origin: new Vector3(0, 0, 100),
normal: Vector3.Normalize(new Vector3(1, 1, 1)) // 45° to all axes
);
var angledArc = new Arc
{
Center = arcPlane.Origin,
Radius = 50,
StartAngle = 0,
EndAngle = MathF.PI,
Plane = arcPlane // Arc lies in a plane tilted 45° to all axes
};
# Coming soon...
Key Points
- The Z axis (AxisZ) represents the plane's normal vector and defines its orientation in 3D space.
- All axes (X, Y, Z) are automatically normalized and made perpendicular to each other.
- When providing just a normal vector, the X and Y axes are computed automatically.
- When providing X and Y axes, Z is computed as their cross product.
- Static instances (WorldXY, WorldYZ, WorldXZ) provide convenient access to common plane orientations.
- The Plane3D.Validate() method can be called to ensure axes are unit length and orthogonal.
What's Next?
Now that you understand Plane3D, you can:
- Explore Elements that use Plane3D for orientation
- View Practical Examples to see Plane3D in action