Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Microsoft.Geospatial.VectorMath

Brian Kircher edited this page Jun 3, 2021 · 9 revisions

Constants

Common constants used for computations.

public static class Microsoft.Geospatial.VectorMath.Constants

Static Fields

Type Name Summary
Double DegreesToRadians The conversion factor to transform degrees to radians.
Double FourPi Four times System.Math.PI.
Double PiOverFour System.Math.PI divided by four.
Double PiOverTwo System.Math.PI divided by two.
Double RadiansToDegrees The conversion factor to transform radians to degrees.
Double TwoPi Two times System.Math.PI.

Plane3D

Encapsulates a plane in 3D space based on doubles.

public struct Microsoft.Geospatial.VectorMath.Plane3D
    : IEquatable<Plane3D>

Properties

Type Name Summary
Double A Gets the A coefficient of the plane equation Ax + By + Cz = D.
Double B Gets the B coefficient of the plane equation Ax + By + Cz = D.
Double C Gets the C coefficient of the plane equation Ax + By + Cz = D.
Double D Gets the D coefficient of the plane equation Ax + By + Cz = D.
Vector3D Normal Gets the normal of the plane.

Methods

Type Name Summary
Double DistanceTo(Vector3D vector) Gets the distance from a point to this plane. A positive result is in front of the plane, a negative result is behind.
Boolean Equals(Plane3D other) Succeeds if the specified plane precisely equals this plane.
Boolean Equals(Object obj) Succeeds if the specified plane precisely equals this plane.
Int32 GetHashCode() Calculates a hash code for this plane.
Vector3D Project(Vector3D vector) Projects a point onto this plane.
String ToString() Returns a string in the form "{A=?,B=?,C=?,D=?}" for this plane.

Static Methods

Type Name Summary
Double EstimatePlaneD(IEnumerable<Vector3D> points, Vector3D normal) Given normal vector, the method estimates free term in plane equation using least squares.
Plane3D FromPointNormal(Vector3D point, Vector3D normal) Creates a new Microsoft.Geospatial.VectorMath.Plane3D from a point and a normal. The normal will be normalized.
Plane3D FromPoints(Vector3D point1, Vector3D point2, Vector3D point3, Boolean clockwise = True) Creates a new Microsoft.Geospatial.VectorMath.Plane3D from three points.
Boolean TryFromPoints(IEnumerable<Vector3D> points, Plane3D& plane) Creates a new Microsoft.Geospatial.VectorMath.Plane3D from an arbitrary number of points.
Boolean TryGetIntersection(Plane3D plane1, Plane3D plane2, Plane3D plane3, Vector3D& point) Try to compute the intersection between 3 planes.
Boolean TryGetIntersection(Plane3D plane1, Plane3D plane2, Ray3D& line) Try to compute the intersection between 3 planes.

Ray3D

A Ray in 3D space.

public struct Microsoft.Geospatial.VectorMath.Ray3D
    : IEquatable<Ray3D>

Fields

Type Name Summary
Vector3D Direction Gets or sets the direction of the ray.
Vector3D Origin Gets or sets the origin of the ray.

Methods

Type Name Summary
Boolean Equals(Ray3D ray) Compares two Microsoft.Geospatial.VectorMath.Ray3Da for equality.
Boolean Equals(Ray3D& ray) Compares two Microsoft.Geospatial.VectorMath.Ray3Da for equality.
Boolean Equals(Object obj) Compares two Microsoft.Geospatial.VectorMath.Ray3Da for equality.
Int32 GetHashCode() Returns the hash code for this Microsoft.Geospatial.VectorMath.Ray3D.
Vector3D GetPoint(Double distanceAlongRay) Gets a point that lies at the specified distance along the ray. The distance may be negative in which case it will be behind the origin of the ray.
Boolean IsValid() Returns true if the origin and direction of the ray are valid.
String ToString() String representing the Microsoft.Geospatial.VectorMath.Ray3D

Static Fields

Type Name Summary
Ray3D Empty Gets an empty ray.

Vector3D

Encapsulates a 3 dimensional vector based on doubles.

public struct Microsoft.Geospatial.VectorMath.Vector3D
    : IEquatable<Vector3D>

Fields

Type Name Summary
Double X Represents the x component of the 3-D vector.
Double Y Represents the y component of the 3-D vector.
Double Z Represents the z component of the 3-D vector.

Properties

Type Name Summary
Double Heading Gets the left-right angle of the vector.
Double Item Provide indexed access to the components of this Vector3D. 0 is X value, 1 is Y, 2 is Z.
Double Pitch Gets the look-up angle of the vector.

Methods

Type Name Summary
Double AbsMaximal() Get the maximal of the absolute values of the elements of this vector.
Double AbsMinimal() Get the minimal of the absolute values of the elements of this vector.
Vector3D Add(Vector3D vec) Gets the sum of the operands.
Vector3D Cross(Vector3D right) Determines the right-handed cross product (a x b) of the two specified vectors.
Double Dot(Vector3D right) Gets the dot product of the operands.
Boolean Equals(Vector3D other) Gets whether the parts of two vectors are equivalent.
Boolean Equals(Vector3D& other) Gets whether the parts of two vectors are equivalent.
Boolean Equals(Object obj) Gets whether the parts of two vectors are equivalent.
Int32 GetHashCode()
Double Length() Gets the length of a vector.
Double LengthSq() Gets the squared length of a vector.
Vector3D Lerp(Vector3D to, Double t) Linearly interpolate percent (0...1) distance from a to b.
Vector3D Max(Vector3D vec) Return a new vector containing the maximal of each of the elements of v0 and v1
Double Maximal() Get the maximal element of this vector.
Vector3D Min(Vector3D vec) Return a new vector containing the minimal of each of the elements of v0 and v1
Double Minimal() Get the minimal element of this vector.
Vector3D Multiply(Double scalingFactor) Gets the product of the operands.
void MultiplyBy(Double value) Multiplies a vector by a value.
Boolean NearlyEquals(Vector3D other, Double epsilon) Compares two Microsoft.Geospatial.VectorMath.Vector3Ds for near equality.
Vector3D Negate() Get a copy of this vector multiplied by -1.
void Normalize() Returns the normalized version of the specified vector.
UInt64 QuantizeNormal(Int32 precision) Compresses this vector into the given number of bits. This vector must be normalized.
Vector3D Subtract(Vector3D vec) Gets the right operand subtracted from the left.
Vector3D Subtract(Vector3D& vec) Gets the right operand subtracted from the left.
String ToString()

Static Fields

Type Name Summary
Vector3D MaxValue Gets a static readonly vector populated with System.Double.MaxValue.
Vector3D MinValue Gets a static readonly vector populated with System.Double.MinValue.
Vector3D UnitX Gets a static readonly vector populated with [1, 0, 0].
Vector3D UnitY Gets a static readonly vector populated with [0, 1, 0].
Vector3D UnitZ Gets a static readonly vector populated with [0, 0, 1].
Vector3D Zero Gets a static readonly vector populated with all zeros.

Static Methods

Type Name Summary
Vector3D Add(Vector3D left, Vector3D right) Gets the sum of the operands.
Vector3D Add(Vector3D& left, Vector3D& right) Gets the sum of the operands.
Double Area(Vector3D& a, Vector3D& b, Vector3D& c) Returns the area between the three points.
Vector3D Cross(Vector3D a, Vector3D b) Determines the right-handed cross product (a x b) of the two specified vectors.
Vector3D Cross(Vector3D& a, Vector3D& b) Determines the right-handed cross product (a x b) of the two specified vectors.
Vector3D DequantizeNormal(UInt64 n, Int32 precision) Decompresses a Vector3D previously packed with QuantizeNormal.
Double Distance(Vector3D pointA, Vector3D pointB) Returns the distance between two vectors, assuming that those vectors represent points. Put another way, returns
Double Distance(Vector3D& pointA, Vector3D& pointB) Returns the distance between two vectors, assuming that those vectors represent points. Put another way, returns
Double DistanceSq(Vector3D pointA, Vector3D pointB) Returns the square of the distance between two vectors, assuming that those vectors represent points. Put another way, returns
Double DistanceSq(Vector3D& pointA, Vector3D& pointB) Returns the square of the distance between two vectors, assuming that those vectors represent points. Put another way, returns
Double DistanceToSegment(Vector3D start, Vector3D end, Vector3D point, Double& percentageBetween) Returns the shortest distance from a point to line segment.
Double DistanceToSegmentSq(Vector3D start, Vector3D end, Vector3D point, Double& percentageBetween) Returns the shortest distance, squared, from a point to line segment.
Double Dot(Vector3D left, Vector3D right) Gets the dot product of the operands.
Double Dot(Vector3D& left, Vector3D& right) Gets the dot product of the operands.
Boolean Equals(Vector3D left, Vector3D right) Gets whether the parts of two vectors are equivalent.
Double GetAngle(Vector3D a, Vector3D b) Calculates the angle in radians between two 3D vectors.
Double GetAngle(Vector3D a, Vector3D b, Vector3D axis) Calculates the angle in radians between two 3D vectors.
Double Length(Vector3D vector) Gets the length of a vector.
Double Length(Vector3D& vector) Gets the length of a vector.
Double LengthSq(Vector3D& vector) Gets the squared length of a vector.
Double LengthSq(Vector3D vector) Gets the squared length of a vector.
Vector3D Lerp(Vector3D a, Vector3D b, Double percent) Linearly interpolate percent (0...1) distance from a to b.
Vector3D Max(Vector3D v0, Vector3D v1) Return a new vector containing the maximal of each of the elements of v0 and v1
Vector3D Min(Vector3D v0, Vector3D v1) Return a new vector containing the minimal of each of the elements of v0 and v1
Vector3D Multiply(Vector3D left, Double right) Gets the product of the operands.
Vector3D Multiply(Vector3D& left, Double right) Gets the product of the operands.
Vector3D Normalize(Vector3D vector) Returns the normalized version of the specified vector.
Vector3D Parse(String source) Initializes a new instance of the Microsoft.Geospatial.VectorMath.Vector3D from a comma-separated string.
Vector3D Subtract(Vector3D left, Vector3D right) Gets the right operand subtracted from the left.
Vector3D Subtract(Vector3D& left, Vector3D& right) Gets the right operand subtracted from the left.
Boolean TryParse(String source, Vector3D& vector) Initializes a new instance of the Microsoft.Geospatial.VectorMath.Vector3D from a comma-separated string.
void ValidatePosition(Vector3D position) Validates that the specified vector is within somewhat reasonable values.

Clone this wiki locally