I have the coordinates of n points on a sphere and I know they are all coplanar. How can I find the edges of the polygon which has the vertex the n given points?
OK, your problem is weird ordering.
Project all points onto any convenient plane - the simplest approach is using OXY, OXZ or OYZ plane (choose one that is not perpendicular to your plane) - in this case you just use (P[i].X. P[i].Y, 0) for P[i] point and sort projected 2D points by angle against the first point - it works because points on sphere arc form convex polygon. Then use this ordering as polygon vertex indexes.
Sometimes was a problem what is the rectangle 3D rotated and be perspective transition (for example in CSS) draw as the tetragon. But we want obtain the rectangle (width, length, Euler angle, perspective) transformed via rotate and perspective draw as the tetragon.
figure
fig.1 points a,c diagonal rectangle(yellow) points A,C diagonal tetragon(shadow) (red)
fig.2 a,b,c,d rectangle points(yellow) A,B,C,D shadow(tetragon) (red)
Solve:
Coordinate system:
The origin of the coordinate system is coincident with diagonals intersection point. Axe Z normal to the tetragon. Axe X crosses point A
a,b,c,d;- ;- rectangular with coordinates
a(x1,y1,z1);
b(x2,y2,z2);
c(x3,y3,z3);
a(x4,y4,z4);
A,B,C,D-shadow. Corner points A(q1,p1,0);
B(q2,p2,0); C(q3,p3,0);
D(q4,p4,0);
k perspective.
In that system of coordinate y1=y3=0.
Fig1.
From similarity transformation triangles is:
x1=1-z1/kq1;
x3=1-z3/kq3
From statement of problem was that diagonal cross is in the origin of the coordinate thus:
z3=-z1 и x3=-x1
Substituting in expression above and equating to each other was :
x1=2*q1*q3/(q3-q1);
z1=(q1+q3)/(q1-q3)*k.
To simplify other calculation imagine that second rectangle diagonal (bd) lie in coordinate system in that Y coordinate of diagonal points is equal zero. In this coordinate system coordinate points b and d was the same as point a and c but we must change z1 to z2, z3 to z4, x1 to x2, x3 to x4,q1 to q2, q3 to q4. To translate from imagine system to real system use rotation coordinate formula (Z axe is the same, z coordinate is equals)
Fig.2
x=x'*cos(a); y=y'*sin(a); The result was:
x2=-x4=2*q2*q4/(q4-q2);
y2=-y4=x2*tan(a);
z2=-z4=(q2+q4)/(q2-q4)k;
tan(a)=(p2-p4)/(q2-q4)
abcd was parallelogram. Diagonal cross point divide diagonal to half. We need to one more expression to make rectangular. Use angle equal 90 degrees. Make scalar multiplication vector of two side in abcd. In coordinate it was:
(a-b)(d-a)=y4y2+(x1-x4)(x1-x2)+(z1-z4)*(z1-z2)=0;
f=(q1*q2-q3q4)(q1*q4-q2*q3)
g=-tan2(a)*q42q22(q1-q3)2+(-q1q2(q3+q4)+q3q4(q1+q2))*(q1q2(q4-q3)+q3q4(q1-q2))
We receive equation to k(perspective): f*k2-g=0, solve it
k=sqrt(g/f).
Collect all formula we get all coordinates of point abcd.
From coordinate of corner is simple to calculate side of rectangular.
Calculating quaternion, rotation matrix, angles see calculate quaternion by coordinate 2 points of object in two positions
I have a list of all triangle sharing an edge. How can I draw a voronoi diagram? I loop over the Delaunay triangles and compare it to vertex 1 = vertex 2 and vertex 2 = vertex 1, I. e. if there are the same edges. It also checks when vertex 1 = vertex 1 and vertex 2 = vertex 2. In the equation both side is a different triangle. It's the same loop from the boywer watson algorithm.
When two triangles are adjacent in the Delaunay triangulation, draw a line segment between the circumcenters of these triangles.
There is an easy to remember rule for the duality between Delaunay triangulations and Voronoi diagrams: The dimensions of the dual elements always sum up to the dimension of space. For example in 2D:
Delaunay <-> Voronoi
Triangle (2) + Point (0) = 2
Segment (1) + Segment (1) = 2
Point (0) + Cell (2) = 2
...similar in 3D.
Given a 2D point that is on the surface of a triangle, where each corner of the triangle is a 3D point, how can you compute the corresponding 3D point of the 2D point?
To get the 3D location of a particular 2D point on a triangle, use barycentric coordinates to interpolate the locations of the 3D vertices:
2D coordinates: u,v such that 0 <= u,v <= 1 and u+v <= 1
-> barycentric coordinates: add t such that t+u+v = 1 -> t = 1-(u+v)
3D vertices: V1, V2, and V3
-> result = u*V1 + v*V2 + t*V3
I have a set of points on the plane (300 000 points). How do I find a polygon with equal cosines of angles and equal sides where vertices of polygon are some of points? The more number of sides and more lengths of sides the better.