Point4d Class

4 Dimensional point (x,y,z,w) used in perspective calculations.

  • the coordinates are stored in a Float64Array of length 4.
  • properties x, y, z, w access array members. *
  • The coordinates are physically stored as a single Float64Array with 4 entries. (w last) *

Implements

Methods

Name Description
constructor(x: number = 0, y: number = 0, z: number = 0, w: number = 0): Point4d Protected Construct from coordinates.  
altitude(point: Point3d): number dotProduct with (point.x, point.y, point.z, 1) Used in PlaneAltitudeEvaluator interface  
altitudeXYZ(x: number, y: number, z: number): number dotProduct with (x, y, z, 1) Used in PlaneAltitudeEvaluator interface  
clone(result?: Point4d): Point4d Clone this point  
crossWeightedMinus(other: Point4d, result?: Vector3d): Vector3d Return ((other.w * this) - (this.w * other))  
distanceSquaredXYZW(other: Point4d): number Return the squared 4d distance from this point to other, with all 4 components squared into the hypotenuse.  
distanceXYZW(other: Point4d): number Return the 4d distance from this point to other, with all 4 components squared into the hypotenuse.  
dotProduct(other: Point4d): number return (4d) dot product of the instance and other point.  
dotProductXYZW(x: number, y: number, z: number, w: number): number return (4d) dot product of the instance with xyzw  
dotVectorsToTargets(targetA: Point4d, targetB: Point4d): number Return dot product of (4d) vectors from the instance to targetA and targetB  
interpolate(fraction: number, pointB: Point4d, result?: Point4d): Point4d Return interpolation between instance and pointB at fraction  
isAlmostEqual(other: Point4d): boolean Near-equality test, using Geometry.isSameCoordinate on all 4 x,y,z,w  
isAlmostEqualXYZW(x: number, y: number, z: number, w: number): boolean Test for same coordinate by direct x,y,z,w args  
magnitudeSquaredXYZ(): number Returns the magnitude of the leading xyz components.  
magnitudeXYZW(): number Returns the magnitude including all 4 components x,y,z,w  
maxAbs(): number Return the largest absolute entry of all 4 components x,y,z,w  
maxDiff(other: Point4d): number Return the largest absolute distance between corresponding components
* x,y,z,w all participate without normalization.
 
minus(other: Point4d, result?: Point4d): Point4d Return the difference (this-other) using all 4 components x,y,z,w  
negate(result?: Point4d): Point4d Negate components (including w!!)  
normalizeQuaternion(): number Normalize so sum of squares of all 4 coordinates is 1.  
normalizeWeight(result?: Point4d): Point4d | undefined If this.w is nonzero, return a 4d point (x/w,y/w,z/w, 1)
If this.w is zero, return undefined.
 
normalizeXYZW(result?: Point4d): Point4d | undefined divide all components (x,y,z,w) by the 4d magnitude.  
plus(other: Point4d, result?: Point4d): Point4d Return the sum of this and other, using all 4 components x,y,z,w  
plus2Scaled(vectorA: Point4d, scalarA: number, vectorB: Point4d, scalarB: number, result?: Point4d): Point4d Return point + vectorA * scalarA + vectorB * scalarB  
plus3Scaled(vectorA: Point4d, scalarA: number, vectorB: Point4d, scalarB: number, vectorC: Point4d, scalarC: number, result?: Point4d): Point4d Return point + vectorA * scalarA + vectorB * scalarB + vectorC * scalarC  
plusScaled(vector: Point4d, scaleFactor: number, result?: Point4d): Point4d Return point + vector * scalar  
radiansToPoint4dXYZW(other: Point4d): number | undefined Measure the "angle" between two points, using all 4 components in the dot product that
gives the cosine of the angle.
 
realDistanceXY(other: Point4d): number | undefined Return the distance between the instance and other after normalizing by weights  
realPoint(result?: Point3d): Point3d | undefined If this.w is nonzero, return a 3d point (x/w,y/w,z/w)
If this.w is zero, return undefined.
 
realPointDefault000(result?: Point3d): Point3d * If this.w is nonzero, return Point3d with x/w,y/w,z/w.  
safeDivideOrNull(denominator: number, result?: Point4d): Point4d | undefined Divide by denominator, but return undefined if denominator is zero.  
scale(scale: number, result?: Point4d): Point4d scale all components (including w!!)  
set(x: number = 0, y: number = 0, z: number = 0, w: number = 0): Point4d Set x,y,z,w of this point.  
setComponent(index: number, value: number): void Set a component by index.  
setFrom(other: Point4d): Point4d Copy coordinates from other.  
setFromJSON(json?: Point4dProps): void Set this point's xyzw from a json array [x,y,z,w]  
toJSON(): Point4dProps Convert an Angle to a JSON object.  
toPlane3dByOriginAndUnitNormal(result?: Plane3dByOriginAndUnitNormal): Plane3dByOriginAndUnitNormal | undefined Treating this Point4d as plane coefficients, convert to origin and normal form.  
velocity(vector: Vector3d): number dotProduct with (vector.x, vector.y, vector.z, 0).  
velocityXYZ(x: number, y: number, z: number): number dotProduct with (x,y,z, 0).  
weightedAltitude(point: Point4d): number dotProduct with (point.x, point.y, point.z, point.w) Used in PlaneAltitudeEvaluator interface  
create(x: number = 0, y: number = 0, z: number = 0, w: number = 0, result?: Point4d): Point4d Static Return a Point4d with specified x,y,z,w  
createAdd2Scaled(vectorA: Point4d, scalarA: number, vectorB: Point4d, scalarB: number, result?: Point4d): Point4d Static Return point + vectorA * scalarA + vectorB * scalarB  
createAdd3Scaled(vectorA: Point4d, scalarA: number, vectorB: Point4d, scalarB: number, vectorC: Point4d, scalarC: number, result?: Point4d): Point4d Static Return point + vectorA \ scalarA + vectorB * scalarB + vectorC * scalarC  
createFromPackedXYZW(data: Float64Array, xIndex: number = 0, result?: Point4d): Point4d Static extract 4 consecutive numbers from a Float64Array into a Point4d.  
createFromPointAndWeight(xyz: XYAndZ, w: number): Point4d Static Create a Point4d with x,y,z from an XYAndZ input, and w from a separate number.  
createPlanePointPointZ(pointA: Point4d, pointB: Point4d, result?: Point4d): Point4d Static Create plane coefficients for the plane containing pointA, pointB, and 0010.  
createRealDerivativePlane3dByOriginAndVectorsDefault000(x: number, y: number, z: number, w: number, dx: number, dy: number, dz: number, dw: number, ddx: number, ddy: number, ddz: number, ddw: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors Static * If w is nonzero, return Vector3d which is the derivative of the projected xyz with given w and 4d derivatives.  
createRealDerivativeRay3dDefault000(x: number, y: number, z: number, w: number, dx: number, dy: number, dz: number, dw: number, result?: Ray3d): Ray3d Static * If w is nonzero, return Vector3d which is the derivative of the projected xyz with given w and 4d derivatives.  
createRealPoint3dDefault000(x: number, y: number, z: number, w: number, result?: Point3d): Point3d Static * If w is nonzero, return Point3d with x/w,y/w,z/w.  
createZero(): Point4d Static Create a point with zero in all coordinates.  
determinantIndexed3X3(pointA: Point4d, pointB: Point4d, pointC: Point4d, i: number, j: number, k: number): number Static Return the determinant of the 3x3 matrix using components i,j,k of the 3 inputs.  
fromJSON(json?: Point4dProps): Point4d Static Create a new point with coordinates from a json array [x,y,z,w]  
interpolateQuaternions(quaternion0: Point4d, fractionParameter: number, quaternion1: Point4d, result?: Point4d): Point4d Static Return a (normalized) quaternion interpolated between two quaternions.  
perpendicularPoint4dPlane(pointA: Point4d, pointB: Point4d, pointC: Point4d): Point4d Static Return a Point4d perpendicular to all 3 inputs.  
unitW(): Point4d Static unit W vector  
unitX(): Point4d Static unit X vector  
unitY(): Point4d Static unit Y vector  
unitZ(): Point4d Static unit Z vector  

Properties

Name Type Description
isAlmostZero Accessor ReadOnly boolean Test if all components are nearly zero.  
w Accessor number Return the w component of this point.  
x Accessor number Return the x component.  
xyzw Float64Array x,y,z,w are packed into a Float64Array  
y Accessor number Return the y component.  
z Accessor number Return the z component.  

Defined in

Last Updated: 08 January, 2020