calculate dist from a point x (x1, x2) to another point y (y1, y2) dist is defined as euclidean dist sqrt((x1 - y1)^2 + (x2 - y2)^2)
calculate dist from a point x (x1, x2) to a line of y (y1, y2) - z (z1, z2) dist is defined as euclidean dist x to x_proj_yz, where x_proj_yz is point x's projected point on line y - z.
calculate proj from a point x (x1, x2) to a line of y (y1, y2) - z (z1, z2) projection point x_proj_yz is defined as point p on line extended by y - z which minimize euclidean dist(x, p), p argmin(dist(x, p), p on line y - z)
calculate angle of a point x (x1, x2) to a segement y (y1, y2) - z (z1, z2) angle is defined as angleYXZ = cosine(vXY, vXZ) cosine of angle spanned at vertex X in triangle YXZ, and vXY is X -> Y: vector from X to Y. an often use case: determine whether x_proj_yzLine within ygSegment or not x_proj_yzLine within ygSegment if both angle x-y-z > 0 and x-z-y > 0 x_proj_yzLine within ygSegment and on exact point y if x-y-z = 0 x_proj_yzLine within ygSegment and on exact point z if x-z-y = 0 x_proj_ygLine outside ygSegment and close to y if x-y-z < 0 and x-z-y > 0 x_proj_ygLine outside ygSegment and close to z if x-y-z > 0 and x-z-y < 0 it is impossible to have both x-y-z < 0 and x-z-y < 0 a on euclidean space
check x_proj_yz - a point x (x1, x2)'s proj on line y (y1, y2) - z (z1, z2) - x_proj_yz is within segment y - z? on point y or z? outside segment y - z? this is an application of calculate_angle_point_segment
calculate dist from a point x(x1, x2) to a line segment y(y1, y2) - z(z1, z2) dist is defined as dist(x, x_proj_yz), when x_proj_yz on line segment y - z, and otherwise min(dist(x, y), dist(x, z)), where point x_proj_yz is defined as point x's projected point on line segment x - y. dist defined above is equivalent to min(dist(x, p), p on yzSegment). calculation is vectoriezed so param z1, z2, x2, x2, y1, y2 are expected to be vectors of same length.
1 2 3 4 5 6 7 8 9 10 11 | calculate_dist_point_point(x1, x2, y1, y2)
calculate_dist_point_line(x1, x2, y1, y2, z1, z2)
calculate_proj_point_line(x1, x2, y1, y2, z1, z2)
calculate_angle_point_segment(x1, x2, y1, y2, z1, z2)
check_proj_within_segment(x1, x2, y1, y2, z1, z2)
calculate_dist_point_segment(x1, x2, y1, y2, z1, z2)
|
TRUE: within segment y - z, on point y or z FALSE: outside segment y - z
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.