cf_project_v3¶
Category: math
GitHub: cute_math3d.h
Projects vector a onto vector b.
CF_V3 cf_project_v3(CF_V3 a, CF_V3 b) { float d = cf_dot_v3(b, b); return d != 0 ? cf_mul_v3_f(b, cf_dot_v3(a, b) / d) : cf_v3(0.0f); }
| Parameters | Description |
|---|---|
a |
The vector to project. |
b |
The vector to project onto. Need not be unit length. |
Return Value¶
Returns the component of a parallel to b, or zero when b is zero.
Remarks¶
cf_slide_v3 returns the complementary perpendicular component. For projecting a point onto a plane see cf_project_plane3.