Initializing 3D Canvas...

The Plane

1 min read•1 page

Infinite Flatness

A plane is a flat, two-dimensional surface that extends infinitely in 3D space. It is defined by an origin point and a perpendicular Normal Vector.

While a plane mathematically extends forever, we typically visualize it as a finite rectangular boundary to understand its orientation and local axes.

1 min read•1 page

Memory & Storage

A plane requires surprisingly little data. You only need a Point (where it is) and a Vector (which way it faces).

python
1class Plane:
2 def __init__(self, origin: 'Point3d', normal: 'Vector3d'):
3 self.Origin = origin
4 # The normal vector defines the "up" direction
5 # and perfectly locks the plane's rotation
6 self.Normal = normal.Unitize()
2 min read•1 page

BasisVectors (XAxis, YAxis, ZAxis):

When you construct a plane from a single Normal vector, the kernel automatically computes two mutually orthogonal unit vectors—XAxis (U) and YAxis (V)—that lie flat on the plane via the cross product.
python
1class Plane:
2 def __init__(self, origin: 'Point3d', normal: 'Vector3d'):
3 self.Origin = origin
4 self.ZAxis = normal.Unitized()
5
6 # Pick a helper vector not parallel to ZAxis to cross with
7 helper = Vector3d(1, 0, 0) if abs(self.ZAxis.X) < 0.9 else Vector3d(0, 1, 0)
8
9 # Cross products build two mutually orthogonal in-plane axes
10 self.XAxis = Vector3d.CrossProduct(helper, self.ZAxis).Unitized()
11 self.YAxis = Vector3d.CrossProduct(self.ZAxis, self.XAxis).Unitized()
Infinitely many 2D coordinate frames share the same plane normal—rotating the XAxis and YAxis around the ZAxis spins the plane's internal UV grid in place.
Rotate Basis Around Normal
0.00
3 min read•1 page

FromEquation(A, B, C, D):

In pure mathematics and physics engines, a plane is often defined implicitly by the general equation Ax + By + Cz + D = 0, where (A, B, C) is the plane's normal vector and -D / √(A² + B² + C²) is the signed distance from the world origin along the unit normal.
python
1import math
2
3class Plane:
4 @classmethod
5 def FromEquation(cls, a: float, b: float, c: float, d: float) -> 'Plane':
6 """Constructs a plane from Ax + By + Cz + D = 0."""
7 length = math.sqrt(a * a + b * b + c * c)
8 if length < 1e-12:
9 raise ValueError("Invalid zero-length plane normal.")
10
11 # Unitize normal and scale D by the same length
12 normal = Vector3d(a / length, b / length, c / length)
13 signed_dist = -d / length
14 origin = Point3d(normal.X * signed_dist, normal.Y * signed_dist, normal.Z * signed_dist)
15 return cls(origin, normal)
Every point (x, y, z) lying on the plane satisfies n · P + D = 0. When (A, B, C) is already unitized, D = -(n · Origin).
Constant (D)
-1.50
1 min read•1 page

FromNormal():

The most direct way to create a plane is by specifying its Origin point and the direction it should face (the Normal vector).
python
1class Plane:
2 @classmethod
3 def FromNormal(cls, origin: 'Point3d', normal: 'Vector3d') -> 'Plane':
4 """Constructs a plane from an origin point and a normal vector."""
5 return cls(origin, normal)
Tilt Normal X
0.00
Tilt Normal Z
0.00

From3Points():

Three non-collinear points perfectly define a flat surface. We use the Cross Product of the vectors between the points to find the plane's Normal.
python
1class Plane:
2 @classmethod
3 def From3Points(cls, a: 'Point3d', b: 'Point3d', c: 'Point3d') -> 'Plane':
4 """Constructs a plane passing through three points."""
5 # 1. Define the origin as the first point
6 origin = a
7
8 # 2. Create two vectors on the plane
9 vec1 = b - a
10 vec2 = c - a
11
12 # 3. The Cross Product gives us the perpendicular Normal!
13 normal = Vector3d.CrossProduct(vec1, vec2)
14
15 return cls(origin, normal)
Move Point C (Z)
-1.50
2 min read•1 page

PointAt(U, V):

A plane is a 2D coordinate system. You can map local 2D parameters (U, V) into 3D world space coordinates (X, Y, Z) using the plane's basis vectors.
python
1class Plane:
2 def PointAt(self, u: float, v: float) -> 'Point3d':
3 """Evaluates a 2D (U, V) coordinate to a 3D World Point."""
4 # 1. Start at the Origin
5 point = self.Origin
6
7 # 2. Move along the X-Axis by 'U' distance
8 point = point + (self.XAxis * u)
9
10 # 3. Move along the Y-Axis by 'V' distance
11 point = point + (self.YAxis * v)
12
13 return point
Parameter U
2.00
Parameter V
1.50
2 min read•1 page

ClosestPoint(Pt):

Finds the point on the plane that is closest to a test point in 3D space. This is equivalent to casting a shadow straight down (Projection) along the plane's Normal vector.
python
1class Plane:
2 def ClosestPoint(self, test_point: 'Point3d') -> 'Point3d':
3 """Projects a 3D point straight down onto the plane."""
4 # 1. Vector from origin to test point
5 vec = test_point - self.Origin
6
7 # 2. Distance along the normal (Dot Product)
8 dist = Vector3d.DotProduct(vec, self.Normal)
9
10 # 3. Move the test point BACK along the normal by that distance
11 return test_point - (self.Normal * dist)
Move Test X
-1.50
Move Test Z
2.00
1 min read•1 page

DistanceTo(Pt):

Unlike lines, plane distance is Signed. If the point is in the direction of the Normal, the distance is positive. If it is behind the plane, the distance is negative.
python
1class Plane:
2 def DistanceTo(self, test_point: 'Point3d') -> float:
3 """Calculates the signed distance to a point."""
4 vec = test_point - self.Origin
5
6 # The Dot Product of the vector and the Normal gives
7 # the exact signed distance!
8 return Vector3d.DotProduct(vec, self.Normal)
Move Point Up/Down
2.00
1 min read•1 page

Flip():

Flipping a plane reverses its Normal direction. This means "above" becomes "below", which affects signed distance calculations and mesh face rendering (normals).
python
1class Plane:
2 def Flip(self):
3 """Inverts the Normal direction of the plane."""
4 self.Normal.Reverse()
5
6 # To maintain the right-hand rule, one of the other
7 # axes (usually Y) is also reversed.
8 self._yAxis.Reverse()
Flip Plane (0/1)
1 min read•1 page

Transform(Matrix):

Because a plane is just a coordinate system (Origin + 3 Axes), translating or rotating a plane is as simple as applying a Matrix4x4 transformation to its origin and basis vectors.
python
1class Plane:
2 def Transform(self, xform: 'Matrix4x4'):
3 """Applies a Transformation Matrix to the plane."""
4 # Moving/Rotating a plane is exactly the same as
5 # multiplying its Origin and Basis Vectors by a matrix.
6 self.Origin.Transform(xform)
7 self.XAxis.Transform(xform)
8 self.YAxis.Transform(xform)
9 self.ZAxis.Transform(xform)
Translate X
2.00
Rotate Z (deg)
25.00
2 min read•1 page

Intersection:

Because planes are infinite, any line that is not parallel to the plane will pierce it at a single 3D intersection point.
python
1def LinePlaneIntersection(line: 'Line', plane: 'Plane') -> 'Point3d':
2 """Calculates the exact 3D point where a line pierces a plane."""
3
4 # 1. Dot product of line direction and plane normal
5 dot = Vector3d.DotProduct(line.Direction, plane.Normal)
6
7 # 2. If dot is 0, the line is parallel to the plane
8 if abs(dot) < 1e-6:
9 return None
10
11 # 3. Vector from line start to plane origin
12 vec = plane.Origin - line.StartPt
13
14 # 4. Calculate parameter 't' along the line
15 t = Vector3d.DotProduct(vec, plane.Normal) / dot
16
17 # 5. Get the point on the line at parameter 't'
18 return line.PointAt(t)
Move Line X
-1.50
Tilt Line (deg)
25.00
2 min read•1 page

Plane-Plane Intersection:

When two non-parallel infinite planes intersect, they form an infinite Line. This operation is the foundational math behind cutting meshes and solid modeling (B-Reps).
python
1import math
2
3def plane_plane_intersection(plane_a: Plane, plane_b: Plane):
4 # Intersection line direction is cross product of normal vectors
5 dir_vec = plane_a.normal.cross(plane_b.normal)
6 if dir_vec.length_squared() < 0.0001:
7 return None # Parallel planes
8
9 dir_vec = dir_vec.normalized()
10 nA, nB = plane_a.normal, plane_b.normal
11 det = nA.length_squared() * nB.length_squared() - (nA.dot(nB))**2
12
13 if abs(det) < 1e-9:
14 return None
15
16 # Solve for the point on the intersection line closest to the origin
17 c1 = (plane_a.constant * nB.length_squared() - plane_b.constant * nA.dot(nB)) / det
18 c2 = (plane_b.constant * nA.length_squared() - plane_a.constant * nA.dot(nB)) / det
19 point = nA.multiply(-c1).add(nB.multiply(-c2))
20
21 return point, dir_vec
Tilt Plane B
15.00
Move Plane B (Y)
1.60
2 min read•1 page

Orient (Plane-Plane):

Transforms geometry from the coordinate system of one plane (Plane A) directly into the coordinate system of another (Plane B) by projecting into local (u, v, w) coordinates and evaluating on the target plane.
python
1def RemapPlaneToPlane(pt: 'Point3d', src: 'Plane', target: 'Plane') -> 'Point3d':
2 """Remaps a point from src plane's local (u, v, w) frame into target plane's frame."""
3 # 1. Decompose point into local coordinates (u, v, w) on src plane via dot products
4 rel = pt - src.Origin
5 u = Vector3d.DotProduct(rel, src.XAxis)
6 v = Vector3d.DotProduct(rel, src.YAxis)
7 w = Vector3d.DotProduct(rel, src.ZAxis)
8
9 # 2. Reconstruct 3D world point on target plane using those exact local offsets
10 return target.Origin + (target.XAxis * u) + (target.YAxis * v) + (target.ZAxis * w)
Plane-to-plane orientation maintains the exact relative local offsets. A point positioned at (u, v, w) relative to Plane A is mapped to (u, v, w) relative to Plane B, regardless of their position or tilt in 3D space.
Local Offset U
1.50
Local Offset V
1.50
Local Offset W
1.00

Related Concepts