Add 3d to 2d plane mapping functions to math lib

This adds two functions to project 3d coordinates onto a 3d plane,
to get 2d coordinates, essentially eliminating the plane's normal axis
from the coordinates.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D2460
This commit is contained in:
Luca Rood 2016-12-22 02:13:03 -02:00
parent 646aa40cf7
commit 0a446d7276
Notes: blender-bot 2023-02-14 07:17:41 +01:00
Referenced by issue #50520, Blender internal, shadow problem
Referenced by issue #50460, Cycles cull option ui problem
Referenced by issue #50439, Dopesheet clip editor view selections are not in sync with other clip editor view selections
Referenced by issue #50427, Properties are only editable *after* pressing "detect feature" in motion tracking
2 changed files with 22 additions and 0 deletions

View File

@ -389,6 +389,8 @@ void box_minmax_bounds_m4(float min[3], float max[3],
void map_to_tube(float *r_u, float *r_v, const float x, const float y, const float z);
void map_to_sphere(float *r_u, float *r_v, const float x, const float y, const float z);
void map_to_plane_v2_v3v3(float r_co[2], const float co[3], const float no[3]);
void map_to_plane_axis_angle_v2_v3v3fl(float r_co[2], const float co[3], const float axis[3], const float angle);
/********************************** Normals **********************************/

View File

@ -4048,6 +4048,26 @@ void map_to_sphere(float *r_u, float *r_v, const float x, const float y, const f
}
}
void map_to_plane_v2_v3v3(float r_co[2], const float co[3], const float no[3])
{
float target[3] = {0.0f, 0.0f, 1.0f};
float axis[3];
cross_v3_v3v3(axis, no, target);
normalize_v3(axis);
map_to_plane_axis_angle_v2_v3v3fl(r_co, co, axis, angle_normalized_v3v3(no, target));
}
void map_to_plane_axis_angle_v2_v3v3fl(float r_co[2], const float co[3], const float axis[3], const float angle)
{
float tmp[3];
rotate_normalized_v3_v3v3fl(tmp, co, axis, angle);
copy_v2_v2(r_co, tmp);
}
/********************************* Normals **********************************/
void accumulate_vertex_normals_tri(