This is my first post on Forge Hub so please bear with me :)
Enclosed is the backstory and formula
For some time now I have been bothered by the rotation of objects in forge 2.0. If you are building a ramp that isn't in line with the x or y axis then when you tilt it up it will go diagonal. After some experimentation I've found out that it is because forge renders objects by performing the Roll, then the Pitch, then the Yaw. This means that creating a ramp that is not parallel to an axis can be problematic at best.
Being a mathematician at heart I was determined that there must be a way to convert the angles I wanted in my head to the angles used by forge's implementation of Yaw, Pitch and Roll. After much searching on the subject of rotations in 3D and Euler angles I have come up with a formula to convert the angle system I want to use in to forge's angle system.
The angle system I find myself thinking of would work like this:
Rotate (Yaw) the object till its facing the direction you want, pull back(Pitch) until its at the angle you want and then spin the object to the appropriate slant (A second yaw). This is most useful if you with to create a banked corner for example or a spiral where you may want the slant(what I would call pitch) to be 30 degrees towards the middle of the corner. The last angle (second yaw) would then control the angle that the corner would be decreasing at.
I feel that the system I described is most useful when making race tracks. These are the rather complicated formulae I have come up with to convert between my system and forge's (P.S. Link to excel file at bottom of post):
a = Cos((Pi() * MyYaw1)/180) * Sin((Pi() * MyPitch)/180)
b = Cos((Pi() * MyPitch)/180) * Cos((Pi() * MyYaw1)/180)
c = Cos((Pi() * MyPitch)/180)
Pitch = 180 * ASin(a) / Pi()
Yaw = -Sign(Sin((Pi() * MyYaw1)/180)) * 180 * ACos(b * Sec((Pitch * Pi())/180)) / Pi() + MyYaw2
Roll = -Sign(Sin((Pi() * MyYaw1)/180)) * 180 * ACos(c * Sec((Pitch * Pi())/180)) / Pi()
MyYaw1 is the direction the ramp will face.
MyPitch is the angle it will slant at.
MyYaw2 is the tilt the object will have (useful for slanted banked track such as spirals).
The Sign() function just gives a plus or a minus depending whether the thing inside it is positive or negative. For example Sign(-10)=-1, Sin(3.4) = 1, Sign(-1.23) = -1, Sign(12345) = 1, etc.
Pitch, Yaw and Roll are what you would then enter in forge coordinate editing to make the piece angled as you would like.
EXAMPLE OF IT APPLIED
http://img833.imageshack.us/i/reach7237000full.jpg/
EXAMPLE MAP
Bungie.net : Halo Reach : File Details
STEP BY STEP
http://img145.imageshack.us/i/reach7338392full.jpg/
First lay out your circle or corner In this example I decided to use 8 pieces turning around a full circle. A full circle is 360° so each piece will be rotated by 360°/8 = 45° from the last piece. So the first piece is at 0°, the second at 0° + 45° = 45°, the third at 45°+45°= 90°, etc.
http://img264.imageshack.us/i/reach7338382full.jpg/
This is what we'd like to be able to do, pull each piece back by 30° to get our circle, but just look at all the diagonal pieces, they're clearly not straight! Here are some more pictures showing this:
http://img200.imageshack.us/i/reach7338388full.jpg/
http://img87.imageshack.us/i/reach7338419full.jpg/
So what can we do?
Ok so the 45°, 135°, 225° and 315° pieces are clearly wrong, to fix it lets use the spread sheet. Ok our first angle is how much each piece is spun around so were going to want to use 45°, 135°, 225° and 315°. Then were going to want to tilt back by 30°. And lastly this is a level curve (the height doesn't change as we turn) so the last angle is 0°.
Putting those numbers in excel gives us (21,-49,-22), (-21,-131,-22), (-21,131,22), (21,49,22), each set of 3 numbers is the (Pitch, Yaw, Roll) for each of those blocks.
Lets put those numbers in forge and look at the slants now.....
http://img257.imageshack.us/i/reach7338434full.jpg/
http://img515.imageshack.us/i/reach7338437full.jpg/
Now all you'd have to do is fit the pieces together. I'll let you figure that out :)
EXAMPLE- 30 degree banked circle with 'n' amount of sides
n=4. (30,0,0), (0,-90,-30), (-30,0,0), (0,90,30).
n=5. (30,0,0), (9,-74,-29), (-24,-140,-19), (-24,140,19), (9,74,29).
n=6. (30,0,0), (14,-63,-27), (-14,-117,-27), (-30,0,0), (-14,117,27), (14,63,27).
n=7. (30,0,0), (18,-55,-24), (-6,-101,-29), (-27,-151,-14), (-27,151,14), (-6,101,29), (18,55,24).
n=8. (30,0,0), (21,-49,-22), (0,-90,-30), (-21,-131,-22), (-30,0,0), (-21,131,22), (0,90,30), (21,49,22).
n=9. (30,0,0), (23,-44,-20), (5,-81,-30), (-14,-117,-27), (-28,-157,-11), (-28,157,11), (-14,117,27), (5,81,30), (23,44,20).
n=10. (30,0,0), (24,-40,-19), (9,-74,-29), (-9,-106,-29), (-24,-140,-19), (-30,0,0), (-24,140,19), (-9,106,29), (9,74,29), (24,40,19).
n=11. (30,0,0), (25,-37,-17), (12,-68,-28), (-4,-97,-30), (-19,-127,-24), (-29,-161,-9), (-29,161,9), (-19,127,24), (-4,97,30), (12,68,28), (25,37,17).
n=12. (30,0,0), (26,-34,-16), (14,-63,-27), (0,-90,-30), (-14,-117,-27), (-26,-146,-16), (-30,0,0), (-26,146,16), (-14,117,27), (0,90,30), (14,63,27), (26,34,16).
WHAT ELSE IS IN THE SPREADSHEET
There is a formula to rotate a piece around a specific point. So if you have a 4 way symmetrical map, you can take a piece, and rotate it around the center so it will be in the exact same position relative to the point, but rotated around that point (Think Sanctuary/Asylum or Wizard/Warlock).
There is also a reflection formula, where you can place a piece, and than reflect it across an axis, so it will be in the exact same position relative to the line and the exact same distance away. Useful for symmetrically reflected maps (Think Sidewinder, Avalanche, Narrows, The Pit or Midship).