Perpendiculars
The objective of this section is to cover geometric constructions using points and vectors. In particular this section focused on raising and dropping perpendicular directions.
Vector - Vector
Provided with two vectors u
and v
, determine all vectors which are 90deg to both u
and v
.
""" Inputs
"""
u = Vector3d( ux, uy, uz )
v = Vector3d( vx, vy, vz )
Solution
A vector w
orthogonal to u
and v
is produced by the cross product. All vector are multiples of w * s
by a scaling factor s
.
""" Outputs
"""
def Orthogonal( u, v, s ):
#-- u : Vector3d, v : Vector3d, s : float
#--
return Vector3d.CrossProduct( u, v ) * s
Plane - Line
Provided with a line segment ( p, q )
defined by two points p
, and q
, determine a plane perpendicular to the line segment at its mid-point.
""" Inputs
"""
p = Point3d( px, py, pz )
q = Point3d( qx, qy, qz )
Solution
The origin of the plane is constructed by the average of the line segment's start and end points. The plane's normal is just the direction of the line.
""" Outputs
"""
origin = ( p + q ) / 2
normal = q - p
plane = Plane( origin, normal )
Basis - Vector
Provided with a unit vector u
, construct an orthonormal basis ( u, v, n )
by computing the vectors v
and n
.
""" Inputs
"""
u = Vector3d( ux, uy, uz )
Solution
This is an application of the unary cross product concept, where one of the world's basis vector is used to produce a vector orthogonal to the input. The normal vector is then produced using another cross product between the previous two.
Note that since the input vector u
is unit-length, and the unary cross product uses another unit-length vector, their result ought to be also unit-length. Therefore, normalization is not required but generally performed to ensure no numerical issues arise.
""" Outputs
"""
v = Vector3d_CrossProductUnary( u )
n = Vector3d.CrossProduct( u, v )
#-- Optionally
#--
v.Unitize( )
n.Unitize( )
Basis - Line
Provided with a line segment ( p, q )
defined by two points p
, and q
, determine a basis ( m, u, v, n )
perpendicular to the line segment at its mid-point m
, where u
, v
and n
are three orthonormal vectors.
""" Inputs
"""
p = Point3d( px, py, pz )
q = Point3d( qx, qy, qz )
Solution
The origin of the basis is computed from the average of the points ( p + q ) / 2
, and the normal direction from their difference q - p
. Constructing the orthogonal vectors is achieved by first applying the unary cross product concept to produce u
, followed by another cross product n x u
. All vectors are finally normalized.
""" Outputs
"""
m = ( p + q ) / 2
n = ( q - p )
u = Vector3d_CrossProductUnary( n )
v = Vector3d.CrossProduct( n, u )
u.Unitize( )
v.Unitize( )
n.Unitize( )
Raise Perp
Provided with a line segment ( p, q )
defined by two points p
, and q
, on the plane ( p, n )
, where n
is the plane's normal vector, determine a point o
perpendicular to the line segment, in the plane, at distance d
from point q
.
""" Inputs
"""
p = Point3d( px, py, pz )
q = Point3d( qx, qy, qz )
n = Vector3d( nx, ny, nz )
d = 2.0
Solution
The direction of the line segment u = q - p
and the plane's normal n
must be orthogonal since the segment is in the plane. Therefore, their cross product v = u x n
shall produce a direction which is orthogonal to the line and within the plane. A point o
therefore can be reached by translating q
by either d * v / |v|
or -d * v / |v|
.
""" Outputs
"""
u = q - p
v = Vector3d.CrossProduct( u, n )
v.Unitize( )
o = q + v * d
''' or ''''
o = q - v * d