计算矩形3D坐标及其阴影坐标? [英] Calculating rectangle 3D coordinate with coordinate its shadow?

查看:44
本文介绍了计算矩形3D坐标及其阴影坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时是一个问题,什么是矩形 3D 旋转和透视转换(例如在 CSS 中)绘制为四边形.但是我们希望通过旋转和透视绘制得到矩形(宽度、长度、欧拉角、透视)作为四边形.

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.

推荐答案


解决:
坐标系:
坐标系的原点与对角线交点重合.Ax Z 垂直于四边形.斧头 X 穿过 A 点
a,b,c,d;- ;- 带坐标的矩形
a(x1,y1,z1);b(x2,y2,z2);c(x3,y3,z3);a(x4,y4,z4);
A、B、C、D 阴影.角点 A(q1,p1,0);B(q2,p2,0);C(q3,p3,0);D(q4,p4,0);
k 视角.
在那个坐标系中,y1=y3=0.
图1.
从相似变换三角形是:

x1=1-z1/kq1;
x3=1-z3/k
q3
从问题的陈述是对角线交叉在坐标的原点,因此:
z3=-z1 и x3=-x1
在上面的表达式中替换并相互等同是:
x1=2*q1*q3/(q3-q1);
z1=(q1+q3)/(q1-q3)*k.


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/k
q3
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.

为了简化其他计算,假设第二个矩形对角线 (bd) 位于坐标系中,对角点的 Y 坐标为零.在这个坐标系中,坐标点 b 和 d 与点 a 和 c 相同,但是我们必须将 z1 更改为 z2,z3至 z4、x1 至  x2、x3 至 x4,q1 到  q2, q3 到 q4.
从想象系统转换到实际系统使用旋转坐标公式(Z轴相同,z坐标等于)
图2

x=x'*cos(a);y=y'*s​​in(a);
结果是:
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 是平行四边形.对角线交叉点将对角线分成两半.我们需要多一个表达式来制作矩形.使用等于 90 度的角度.在 abcd 中制作两侧的标量乘法向量.在坐标上是:
(ab)
(da)=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))
我们得到 k(perspective) 的方程:f*k2-g=0,求解它

k=sqrt(g/f).


收集所有公式我们得到点 abcd 的所有坐标.
从角的坐标计算矩形的边很简单.

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.

这篇关于计算矩形3D坐标及其阴影坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆