Wednesday, February 4, 2009

Second Life creation problems with equilateral triangles

In Second Life you can create any 3D object using the basic building blocks (called Prims from primatives) like cubes and spheres. These are a maximum size of 10x10x10m (unless you are a God I guess).

I wanted to create the maximum size possible equilateral triangle (in order to help make a giant tetrahedron), unfortunately the "prism" prim was less that 10m on a side maximum. Instead I flattened a 10m cube and tapered it to be a triangle. To turn it into an equilateral I changed the height from 10m to 8.66m, as using Pythagoras' theorem the height must be:
√(102-52)m=√(25x(3-1))m=5m√(2)
≈8.660m


Now here's the unexpected problem. When you rotate the large equilateral, it turns out that the centre of gravity is still based on the cube and so has been set to be at half the height. Consequently to rotate correctly about a centre I had to add a correction vector (unfortunately it's not possible to reassign the centre of gravity of a prim).



The centre of an equilateral triangle can be found by bisecting the angles, the resulting 3 central lines intersect at the centre. Looking at the intersection of one of these bisecting lines and the height line gives a right-angled triangle with 30° at the corner and with a base of 5m. Consequently the distance from the base to the centre of gravity must be:
COG=5m*tan(30°)
=5m/(√3)
≈2.887m


So my correction factor to move to the centre (in the Y-plane) is:
CF=[(5m√2)/2]-[5m/(√3)]
=5m(1/√2-1/√3)

≈0.649m


I kind of wish I'd stuck to the prism prim as this correction factor has really sullied the beauty of my LSL scripts ;)

No comments: