modify closest_to_plane_v3 not to use point-normal form.
This commit is contained in:
@@ -89,7 +89,7 @@ float dist_to_line_v3(const float p[3], const float l1[3], const float l2[3]);
|
||||
float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]);
|
||||
float closest_to_line_v2(float r[2], const float p[2], const float l1[2], const float l2[2]);
|
||||
void closest_to_line_segment_v3(float r[3], const float p[3], const float l1[3], const float l2[3]);
|
||||
void closest_to_plane_v3(float r[3], const float plane_co[3], const float plane_no_unit[3], const float pt[3]);
|
||||
void closest_to_plane_v3(float close_r[3], const float plane[4], const float pt[3]);
|
||||
|
||||
/* Set 'r' to the point in triangle (t1, t2, t3) closest to point 'p' */
|
||||
void closest_on_tri_to_point_v3(float r[3], const float p[3], const float t1[3], const float t2[3], const float t3[3]);
|
||||
|
||||
@@ -305,24 +305,20 @@ void closest_to_line_segment_v3(float close_r[3], const float v1[3], const float
|
||||
copy_v3_v3(close_r, cp);
|
||||
}
|
||||
|
||||
/* find the closest point on a plane to another point and store it in close_r
|
||||
* close_r: return coordinate
|
||||
* plane_co: a point on the plane
|
||||
* plane_no_unit: the plane's normal, and d is the last number in the plane equation 0 = ax + by + cz + d
|
||||
* pt: the point that you want the nearest of
|
||||
/**
|
||||
* Find the closest point on a plane.
|
||||
*
|
||||
* \param close_r Return coordinate
|
||||
* \param plane The plane to test against.
|
||||
* \param pt The point to find the nearest of
|
||||
*
|
||||
* \note non-unit-length planes are supported.
|
||||
*/
|
||||
|
||||
void closest_to_plane_v3(float close_r[3], const float plane_co[3], const float plane_no_unit[3], const float pt[3])
|
||||
void closest_to_plane_v3(float close_r[3], const float plane[4], const float pt[3])
|
||||
{
|
||||
float temp[3];
|
||||
float dotprod;
|
||||
|
||||
sub_v3_v3v3(temp, pt, plane_co);
|
||||
dotprod = dot_v3v3(temp, plane_no_unit);
|
||||
|
||||
close_r[0] = pt[0] - (plane_no_unit[0] * dotprod);
|
||||
close_r[1] = pt[1] - (plane_no_unit[1] * dotprod);
|
||||
close_r[2] = pt[2] - (plane_no_unit[2] * dotprod);
|
||||
const float length = len_squared_v3(plane);
|
||||
const float side = plane_point_side_v3(plane, pt);
|
||||
madd_v3_v3v3fl(close_r, pt, plane, -side / length);
|
||||
}
|
||||
|
||||
/* signed distance from the point to the plane in 3D */
|
||||
|
||||
@@ -734,14 +734,14 @@ static void snap_to_edge_profile(EdgeHalf *e, const float va[3], const float vb[
|
||||
float co[3])
|
||||
{
|
||||
float m[4][4], minv[4][4];
|
||||
float edir[3], va0[3], vb0[3], vmid0[3], p[3], snap[3];
|
||||
float edir[3], va0[3], vb0[3], vmid0[3], p[3], snap[3], plane[4];
|
||||
|
||||
sub_v3_v3v3(edir, e->e->v1->co, e->e->v2->co);
|
||||
normalize_v3(edir);
|
||||
|
||||
/* project va and vb onto plane P, with normal edir and containing co */
|
||||
closest_to_plane_v3(va0, co, edir, va);
|
||||
closest_to_plane_v3(vb0, co, edir, vb);
|
||||
plane_from_point_normal_v3(plane, co, edir);
|
||||
closest_to_plane_v3(va0, plane, va);
|
||||
closest_to_plane_v3(vb0, plane, vb);
|
||||
project_to_edge(e->e, va0, vb0, vmid0);
|
||||
if (make_unit_square_map(va0, vmid0, vb0, m)) {
|
||||
/* Transform co and project it onto the unit circle.
|
||||
|
||||
@@ -1561,9 +1561,12 @@ static void getVerticalAndHorizontalChange(const float norm[3], float d, const f
|
||||
/* A = Q - ((Q - P).N)N
|
||||
* D = (a * x0 + b * y0 +c * z0 + d) */
|
||||
float projA[3], projB[3];
|
||||
float plane[4];
|
||||
|
||||
closest_to_plane_v3(projA, coord, norm, start);
|
||||
closest_to_plane_v3(projB, coord, norm, end);
|
||||
plane_from_point_normal_v3(plane, coord, norm);
|
||||
|
||||
closest_to_plane_v3(projA, plane, start);
|
||||
closest_to_plane_v3(projB, plane, end);
|
||||
/* (vertical and horizontal refer to the plane's y and xz respectively)
|
||||
* vertical distance */
|
||||
dists[index] = dot_v3v3(norm, end) + d;
|
||||
|
||||
Reference in New Issue
Block a user