what is happening when things aren't happening

Official support for: xoxos
Post Reply New Topic
RELATED
PRODUCTS

Post

this is the amazing tale of how things are when they suck.

after completing blewm (end of july) i started expanding my graphical library. course i have to write my own rather than use opengl or such - for one thing, my chipset is like twelve years old? but dyi is of course good fun.

so we're in august and i realise it's simple to rasterise triangles and make solid 3d renderings. i bugger about with aa triangles, then explore the wonders of gimbal lock when performing the obligatory rotating geometric primitives, get through that, put together a rudimentary routine for drawing lots of triangles and feel confident about my ability to render 3d space, and got my code all sorted nicely to start putting these routines to use.

that was about a month ago.

first day of trying to do anything with it i ran across an unexpected obstacle:

Image

camera in 3d environ populated by a tetrahedron, placed in front of the viewer so that only one face is currently visible.

now, of course i was doing this with naive 2d geometric knowledge. i had no idea i was going to encounter the fact that rotating in 3d from a preexistent rotation doesn't work with 2d. if you don't understand the graphic, between the first and second frame the viewer rotates around the y axis, turning to the left, the tetrahedron moves right...

..in the 4th image we observe rotating the world on the y axis. the problem is that if we wish to turn left or right according to the viewer's perspective in the 3rd frame, that must be applied to our global orientation in a more complex manner than only rotating around y..

.........

i explored the charming history of this problem in mathematics, and appreciate that quaternions are pretty much the 3d version of the 2d complex oscillator i'd wondered about earlier. but quaternions are a freaking lump of operations compared to a 2d sine and cosine rotation.

so, as i expanded my knowledge and search terms, i pursued hints that there may be less intensive methods of performing the rotation. i am still not sure if this can be done purely with what people tend to call "euler angles" (it's supposed to be called tait-bryan angles and really only means using radians for each dimension). radians and i have spent a lot of time together.

rotation from an arbitrary orientation can be done with a 3x3 matrix. the thing is, everybody wants you to use quaternions. but in the olden days, people used to use 3x3 matrices.

in fact, they're well documented by NASA. there are lots of sources for rotation matrices.

but it's not quite that simple.

i've been using POVray for 3d modelling since ~1996? and feel very comfortable with 3d representation.

first discrepancy - POVray uses left hand rotation - make a fist, stick your thumb out - the thumb is the + direction on the axis, the curled fingers the direction of + rotation coefficients. NASA is a right handed rotation system. fair enough.

second degree of variance - how do you arrange your 3d axes? say you're used to looking at geometry books and orient x horizontally and y vertically, does z extend away fromthe viewer or towards? here again, make the hand, then point your first finger forward and your second finger 90 degrees from it..

there are also left handed and right handed coordinate systems. NASA is RHRH POVray is LHLH. so, NASA's matrices would require a fair bit of translation.

there are a few references for LHLH, yet i have never found one matching my own calculation for a LHLH matrix, which i find to be ever so fun.

so weeks go by and i finally find a LHLH reference (the matrix-to-euler conversion is a shit, more than i would ever want to think about) and my rotations are so abysmal, flashing about aliasing between locations.

another week goes by as i search for a better reference. eventually i realise the translation works, but my use of it didn't take into account that it only returns 180 degrees for y instead of 360.. which is why any rotation that passed between hemispheres was doing funky stuff. stupidly it took me several days to stop rotating world space and observe the rotation performed on a stationary object.

so now i'm at a point where i've actually got a functioning angle-to-matrix-to-angle process that works with the coordinate system i use, so i can correctly concatenate rotations, but the method is only good for 180 degrees of y, or only a hemisphere, with me nonplussed as to how to determine if two concatenated rotations will end up in one hemisphere or the other.

so my choices are to keep pushing for the way 3x3 matrices have been used by others requiring a full spherical response, or to implement quaternions.

apparently tomb raider was the first market game to use quaternion rotations.. i remember playing something in the mid 90s that had the matrix polar error (floating point numbers break down at the y poles) and would flutter about if you hit the lucky orientation. so, i even know how the error that people avoid matrices for performs.

so it's been an unexpected bump in the road, and one of those times where you get to know every bump in the road personally... eg. all the time spent acquiring a LHLH system was my fault for sticking with POVray for 18 years. and, you look at the road, you understand why all the bumps are there.

i ask on forums but people are reluctant to help with a matrix and not a quaternion implementation. my questions are answered with recommendations, such as the unhelpful "keep your rotations in matrix space, never convert to angles" where people fail to understand that, as an audio coder, i might want to interrelate my graphics with aural parameters. being pitted against an entire community is just one of those bumps on the road when you are in the world. again, it's so tiresome.. can't people even try and understand my special need to have angles in radians to work with? must i play the pariah at every step? can't someone just say, okay, we used matrices for a decade, i admit it, and let me know how they did it?

i try to avoid learning wherever possible because it involves other people. dynamics are just like that... like how we can't even settle on xyz, it has to be pitch yaw roll or heading attitude bank, or the cosine written after the number instead of before. translating is a process that consumes time and energy. as you probably know, i'm a very "outwards" person. you don't need a doctorate to devise algorithms. at least, learning being as painful as possible reminds me not to do it often.


about the time i hit the point where this narrative begins, i had some awesome bud. white fire c99 and something. amazing flavour and long lasting. normally i get scraps that aren't all that. smoked all that while reading stupid boring webpages about matrices instead of making stuff, and that's not cool. people should understand that those spaceships in dune wouldn't go anywhere worth going to if the navigators weren't blowing something decent. society should work with me more here.

i could stop and go back, and make 3d stuff, as long as no one falls over or tries to turn around. like 2 and a half dimensions. or i could wait and see if some nice person on a forum tells me about how matrices were used, or i could go on and implement quaternions, but then i'd have to read something by a prat, probably several things by several prats, and that really does me in.

in case you needed something to feel better about your own tribulations with :)
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

fixed it.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post Reply

Return to “xoxos”