Commit: 751496437b55f6d31828f79b47c7a3c6ababe827
Author: Luca Rood
Date:   Thu Dec 22 02:13:03 2016 -0200
Branches: surface-deform-modifier
https://developer.blender.org/rB751496437b55f6d31828f79b47c7a3c6ababe827

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

===================================================================

M       source/blender/blenlib/BLI_math_geom.h
M       source/blender/blenlib/intern/math_geom.c

===================================================================

diff --git a/source/blender/blenlib/BLI_math_geom.h 
b/source/blender/blenlib/BLI_math_geom.h
index 3e2a00c..cd141c9 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -396,6 +396,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_v3v3(float r_co[2], const float co[3], const 
float axis[3], const float angle);
 
 /********************************** Normals **********************************/
 
diff --git a/source/blender/blenlib/intern/math_geom.c 
b/source/blender/blenlib/intern/math_geom.c
index 7f9b33a..9d0e390 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -4071,6 +4071,29 @@ 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];
+       float angle;
+
+       cross_v3_v3v3(axis, no, target);
+       normalize_v3(axis);
+
+       angle = saacos(dot_v3v3(no, target));
+
+       map_to_plane_axis_angle_v2_v3v3(r_co, co, axis, angle);
+}
+
+void map_to_plane_axis_angle_v2_v3v3(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(

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to