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.
相关问题
- Is GLFW designed to use without LWJGL (in java)?
- d3.js moving average with previous and next data v
- How to get a fixed number of evenly spaced points
- Check if a number is a perfect power of another nu
- How to determine +/- sign when calculating diagona
相关文章
- ceil conterpart for Math.floorDiv in Java?
- why 48 bit seed in util Random class?
- Algorithm for partially filling a polygonal mesh
- Robust polygon normal calculation
- Algorithm for maximizing coverage of rectangular a
- Keep constant number of visible circles in 3D anim
- Need help generating discrete random numbers from
- How do you create a formula that has diminishing r
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.
Calculating quaternion, rotation matrix, angles see calculate quaternion by coordinate 2 points of object in two positionsTo 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:
(d-a)=y4y2+(x1-x4)(x1-x2)+(z1-z4)*(z1-z2)=0;(a-b)
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.
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)