Math Lib: inline project_plane_v3_v3v3
This commit is contained in:
@@ -591,19 +591,28 @@ void project_v3_v3v3(float c[3], const float v1[3], const float v2[3])
|
||||
* Projecting will make \a c a copy of \a v orthogonal to \a v_plane.
|
||||
*
|
||||
* \note If \a v is exactly perpendicular to \a v_plane, \a c will just be a copy of \a v.
|
||||
*
|
||||
* \note This function is a convenience to call:
|
||||
* \code{.c}
|
||||
* project_v3_v3v3(c, v, v_plane);
|
||||
* sub_v3_v3v3(c, v, c);
|
||||
* \endcode
|
||||
*/
|
||||
void project_plane_v3_v3v3(float c[3], const float v[3], const float v_plane[3])
|
||||
{
|
||||
float delta[3];
|
||||
project_v3_v3v3(delta, v, v_plane);
|
||||
sub_v3_v3v3(c, v, delta);
|
||||
const float mul = dot_v3v3(v, v_plane) / dot_v3v3(v_plane, v_plane);
|
||||
|
||||
c[0] = v[0] - (mul * v_plane[0]);
|
||||
c[1] = v[1] - (mul * v_plane[1]);
|
||||
c[2] = v[2] - (mul * v_plane[2]);
|
||||
}
|
||||
|
||||
void project_plane_v2_v2v2(float c[2], const float v[2], const float v_plane[2])
|
||||
{
|
||||
float delta[2];
|
||||
project_v2_v2v2(delta, v, v_plane);
|
||||
sub_v2_v2v2(c, v, delta);
|
||||
const float mul = dot_v2v2(v, v_plane) / dot_v2v2(v_plane, v_plane);
|
||||
|
||||
c[0] = v[0] - (mul * v_plane[0]);
|
||||
c[1] = v[1] - (mul * v_plane[1]);
|
||||
}
|
||||
|
||||
/* project a vector on a plane defined by normal and a plane point p */
|
||||
|
Reference in New Issue
Block a user