MCPcopy Create free account
hub / github.com/carbonengine/trinity / TriVectorRotateToPlane

Function TriVectorRotateToPlane

trinity/TriMath.cpp:69–79  ·  view source on GitHub ↗

Projects a vector onto plane but maintains it's length so it's effectively like moving/rotating it onto the plane

Source from the content-addressed store, hash-verified

67
68// Projects a vector onto plane but maintains it's length so it's effectively like moving/rotating it onto the plane
69Vector3 TriVectorRotateToPlane( const Vector3& point, const Vector3& p0, const Vector3& n )
70{
71 Vector3 out = point - p0;
72 float length = Length( out );
73 out = n * Dot( out, n );
74 out = point - out;
75 // We have the projected position, now scale it to the original distance
76 out -= p0;
77 out = Normalize( out ) * length + p0;
78 return out;
79}
80
81Vector3* TriVectorRotateMatrix(
82 Vector3* out,

Callers 2

AddLineMethod · 0.85

Calls 2

LengthFunction · 0.85
DotFunction · 0.50

Tested by

no test coverage detected