diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-03-04 12:08:16 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-03-04 12:11:49 +0300 |
commit | 6efcd9e8fec28aecc23ae7560d07ad19f5aeb57b (patch) | |
tree | e4b80a70b792495033a9ee1cc124b9057503f0c9 /source | |
parent | b1e48ab4e483efd5382e5206a2c0177fdf8a7c64 (diff) |
Math Lib: redundant axis flip decomposing a plane
Also add a faster, non-normalized version of the function.
(Neither are used currently used).
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_math_geom.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 16 |
2 files changed, 15 insertions, 5 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 9023cdd17bf..4f7a3310ee6 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 eee78297106..ba1f4480659 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 **********************************/ |