Skip to content

I wish I know more trigs

Did too much soldering today. I’ll just post some screenshots as update for the U.S. intervention history visualization. Since last the most effort regarding this project was spent on figuring out the tech details on building interaction into the spinning globe. I wish I know more about trigs!

Several tips to put down for myself:

- move textFont() out of the loop;
- do not create font on the fly if using huge font size;
- screenX and screenY are your friends (while creating mouse over interaction in 3D) (Thanks Dan!);
- rotation is headache, rotation in 3D is huge headache:

I had some rotation and translation params of a point generated by geo data. It’s easy to get params in those forms when you’re dealing with a sphere. Such point can easily be drawn with a series of rotate() and translate(), and a box() or sphere(), however I want to calculate the actual coordinates of those points in the 3D space to place attractors / draw lines / whatever.

I wish I paid enough attention while I learned trigs in high school, but I ended up looking into processing core source code and did something like this:

1
2
3
4
5
6
7
8
9
10
11
PVector rotation = getRotation();    // the rotation params that i do have
float offsetZ = 500;                 // some arbitrary number

PMatrix3D m = new PMatrix3D();
m.rotateY(rotation.y);
m.rotateX(rotation.x);

//more 3D transformation here

m.translate(0,0, offsetZ);           // just do whatever I would do in normal draw loop
PVector l = new PVector(m.m03,m.m13,m.m23);

It’s basically just reusing the PMatrix3D class which is used internally in 3D transformation in processing, but I’m so happy not having to figure out the math myself.

More experiments:
picture-14picture-13picture-12picture-10picture-9picture-8picture-7picture-6picture-5picture-4picture-3picture-2picture-1

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*