[Bf-blender-cvs] [6efcd9e] master: Math Lib: redundant axis flip decomposing a plane
Campbell Barton
noreply at git.blender.org
Wed Mar 4 10:13:52 CET 2015
Commit: 6efcd9e8fec28aecc23ae7560d07ad19f5aeb57b
Author: Campbell Barton
Date: Wed Mar 4 20:08:16 2015 +1100
Branches: master
https://developer.blender.org/rB6efcd9e8fec28aecc23ae7560d07ad19f5aeb57b
Math Lib: redundant axis flip decomposing a plane
Also add a faster, non-normalized version of the function.
(Neither are used currently used).
===================================================================
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 9023cdd..4f7a331 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -74,7 +74,9 @@ float cross_poly_v2(const float verts[][2], unsigned int nr);
/********************************* Planes **********************************/
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3]);
-void plane_to_point_normal_v3(const float plane[4], float r_plane_co[3], float r_plane_no[3]);
+void plane_to_point_vector_v3(const float plane[4], float r_plane_co[3], float r_plane_no[3]);
+void plane_to_point_vector_v3_normalized(const float plane[4], float r_plane_co[3], float r_plane_no[3]);
+
MINLINE float plane_point_side_v3(const float plane[4], const float co[3]);
/********************************* Volume **********************************/
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index eee7829..ba1f448 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -257,14 +257,22 @@ void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const
}
/**
- * Get a point and a normal from a plane.
+ * Get a point and a direction from a plane.
*/
-void plane_to_point_normal_v3(const float plane[4], float r_plane_co[3], float r_plane_no[3])
+void plane_to_point_vector_v3(const float plane[4], float r_plane_co[3], float r_plane_no[3])
{
- const float length = normalize_v3_v3(r_plane_no, plane);
- madd_v3_v3v3fl(r_plane_co, r_plane_no, r_plane_no, (-plane[3] / length) - 1.0f);
+ mul_v3_v3fl(r_plane_co, plane, (-plane[3] / len_squared_v3(plane)));
+ copy_v3_v3(r_plane_no, plane);
}
+/**
+ * version of #plane_to_point_vector_v3 that gets a unit length vector.
+ */
+void plane_to_point_vector_v3_normalized(const float plane[4], float r_plane_co[3], float r_plane_no[3])
+{
+ const float length = normalize_v3_v3(r_plane_no, plane);
+ mul_v3_v3fl(r_plane_co, r_plane_no, (-plane[3] / length));
+}
/********************************* Volume **********************************/
More information about the Bf-blender-cvs
mailing list