File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -713,6 +713,32 @@ RMAPI Vector3 Vector3Normalize(Vector3 v)
713713 return result ;
714714}
715715
716+ //Calculate the projection of the vector v1 on to v2
717+ RMAPI Vector3 Vector3Project (Vector3 v1 , Vector3 v2 )
718+ {
719+ float v1dv2 = (v1 .x * v2 .x + v1 .y * v2 .y + v1 .z * v2 .z );
720+ float v2dv2 = (v2 .x * v2 .x + v2 .y * v2 .y + v2 .z * v2 .z );
721+
722+ float mag = v1dv2 /v2dv2 ;
723+
724+ Vector3 result = { v2 .x * mag , v2 .y * mag , v2 .z * mag };
725+
726+ return result ;
727+ }
728+
729+ //Calculate the rejection of the vector v1 on to v2
730+ RMAPI Vector3 Vector3Reject (Vector3 v1 , Vector3 v2 )
731+ {
732+ float v1dv2 = (v1 .x * v2 .x + v1 .y * v2 .y + v1 .z * v2 .z );
733+ float v2dv2 = (v2 .x * v2 .x + v2 .y * v2 .y + v2 .z * v2 .z );
734+
735+ float mag = v1dv2 /v2dv2 ;
736+
737+ Vector3 result = { v1 .x - (v2 .x * mag ) , v1 .y - (v2 .y * mag ), v1 .z - (v2 .z * mag ) };
738+
739+ return result ;
740+ }
741+
716742// Orthonormalize provided vectors
717743// Makes vectors normalized and orthogonal to each other
718744// Gram-Schmidt function implementation
You can’t perform that action at this time.
0 commit comments