Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-12-26 13:05:03 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-12-26 13:07:44 +0400
commitbc1eb0bf0a0c5a6ebf3ff19dae0bfe6a65529b8e (patch)
treefc6b62276f968930cf12acf90abf8a11c92725ae /source/blender/blenlib
parent03fed41e59cc9247f7db6af33b2e76b6b05340f7 (diff)
Simplify isect_point_poly_v2 functions using angle_signed_v2v2
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/math_geom.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 11875722d27..1d03bf42f83 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -721,24 +721,16 @@ bool isect_point_poly_v2(const float pt[2], const float verts[][2], const unsign
/* first vector */
fp1[0] = (float)(p1[0] - pt[0]);
fp1[1] = (float)(p1[1] - pt[1]);
- normalize_v2(fp1);
for (i = 0; i < nr; i++) {
- float dot, ang, cross;
p2 = verts[i];
/* second vector */
fp2[0] = (float)(p2[0] - pt[0]);
fp2[1] = (float)(p2[1] - pt[1]);
- normalize_v2(fp2);
/* dot and angle and cross */
- dot = dot_v2v2(fp1, fp2);
- ang = fabsf(saacos(dot));
- cross = (float)((p1[1] - p2[1]) * (p1[0] - pt[0]) + (p2[0] - p1[0]) * (p1[1] - pt[1]));
-
- if (cross < 0.0f) angletot -= ang;
- else angletot += ang;
+ angletot += angle_signed_v2v2(fp1, fp2);
/* circulate */
copy_v2_v2(fp1, fp2);
@@ -769,24 +761,16 @@ bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsign
/* first vector */
fp1[0] = (float)(p1[0] - pt[0]);
fp1[1] = (float)(p1[1] - pt[1]);
- normalize_v2(fp1);
for (i = 0; i < nr; i++) {
- float dot, ang, cross;
p2 = verts[i];
/* second vector */
fp2[0] = (float)(p2[0] - pt[0]);
fp2[1] = (float)(p2[1] - pt[1]);
- normalize_v2(fp2);
/* dot and angle and cross */
- dot = dot_v2v2(fp1, fp2);
- ang = fabsf(saacos(dot));
- cross = (float)((p1[1] - p2[1]) * (p1[0] - pt[0]) + (p2[0] - p1[0]) * (p1[1] - pt[1]));
-
- if (cross < 0.0f) angletot -= ang;
- else angletot += ang;
+ angletot += angle_signed_v2v2(fp1, fp2);
/* circulate */
copy_v2_v2(fp1, fp2);