| ||
The important formulas in this chapter are those for 3D perspective, coordinate rotation, and distance.
Basic perspective:
scale = fl / (fl + z); mc._xscale = mc._yscale = scale * 100; mc._alpha = scale * 100; // optional mc._x = vanishingPointX + x * scale; mc._y = vanishingPointY + y * scale; mc.swapDepths(-z); // optional
Coordinate rotation:
x1 = cos(angleZ) * x sin(angleZ) * y; y1 = cos(angleZ) * y + sin(angleZ) * x; x1 = cos(angleY) * x sin(angleY) * z; z1 = cos(angleY) * z + sin(angleY) * x; y1 = cos(angleX) * y sin(angleX) * z; z1 = cos(angleX) * z + sin(angleX) * y;
3D distance:
dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
| ||