|
Author |
Topic: help! (Read 603 times) |
|
adrien
|
help!
« on: Aug 22nd, 2002, 11:52pm » |
|
How about a section where users can post code they're having difficulty with, in the hope that someone might be able to help?
|
Signature: Signatures are displayed at the bottom of each post...
|
|
|
adrien
|
and so...
« Reply #1 on: Aug 22nd, 2002, 11:54pm » |
|
I will make a first contribution to this section, with a desperate plea for help with some 3D stuff. It's part of a larger project, but I have isolated the problem and built a demo to highlight it, so you don't have to wade through all the other junk to see it. and so: begin P5 code: // box rotation test // by adrien cater // the goal is to make a box that spins around, // but it tipped on it's corner... // the result here is pretty close to what I want, // but the axis is off by a few degrees... // the two little boxes should also be on the axis... // maybe it's because of the tilt of the earth's axis? // maybe if I re-compile at the equator it will change // at this point anything seems possible. // PI / 4 in radians is 45 degrees. right? // So what's with this little offset here? // maybe i'm just not understanding the rotation stuff clearly. // it all changes radically when I chnage the order of the // rotateX , Y and Z statements. This confuses me. // Shouldn't the order be independent? // hurts my brain does. my first 3D work this is. float rotation; void setup() { size(800, 550); background(51, 51, 102); } void loop(){ // draw the X and Y axis lines to see the problem clearly... stroke(102); line(width/2, 0, width/2, height); line(0, height/2, width, height/2); // put things in the middle... translate(width/2, height/2, -100); // the problem is here somewhere... rotateY(rotation); rotateX(PI / 4); rotateZ(PI / 4); // make the little boxes... stroke(0); translate(-100, -100, 100); fill(204); box(10); translate(200, 200, -200); fill(102); box(10); // make the big box translate(-100, -100, 100); fill(153); box(200); // make it spin! rotation += .03; } end P5 code...
|
Signature: Signatures are displayed at the bottom of each post...
|
|
|
adrien
|
Re: help!
« Reply #2 on: Aug 22nd, 2002, 11:56pm » |
|
BTW - thanks! If anyone wants to help, I am prepared to fed-ex you a beer upon request.
|
Signature: Signatures are displayed at the bottom of each post...
|
|
|
fry
|
Re: help!
« Reply #3 on: Sep 7th, 2002, 2:07am » |
|
this is one of the big problems with learning 3D--getting used to the order of transformations. they *are* (and should be) order dependent, because of how the math works, particularly as it changes throughout your program.. you can think about it in terms of an x/y/z axis diagram in space (you know, x with a line that pointsup, etc). when you rotate, you're twisting that pointy arrowed diagram around. to make something orbit, the order would be: 1. rotate by the orbit amount 2. translate 'out' to how far you want to be from the center 3. tilt the box with the other two rotate commands 4. draw the box also, since these accumulate, you might look into using push() and pop() around where you draw your two boxes. see the docs for details (i think they're in there.. hmm) good luck!
|
|
|
|
|