Lochlyn Dragonash Posted July 12, 2021 Share Posted July 12, 2021 To recreate the sample for this question, Make you a sphere as small as possible, make it glow or something. Name it Ball. Make a script inside Ball with code below so it will kill itself. Make a Cube and put Ball inside the Cube. Make a script inside Cube. Touch Cube to rez the Balls. Touch Cube again to kill them. EXERSIZE: Identify a circle of points on the face of Cube, visually represented by a Ball rezzed on its surface. WHAT WORKS: When Cube is oriented with default rotation, the ring of points (and thus the position of rezzed Balls) is fine. WHAT FAILS: Any rotation of the cube in 3D space is not translated into the position of the points. The Balls want to stay in their own plane. THE QUESTION: It goes without saying my math is wrong and I am not properly taking into account the rotation of Cube when calculating the positions necessary for the Balls. My question is what am I missing, and is there some simple way for my Neanderthal brain to make sense of it? I have read countless things on Rotations and Rotation Math and ... still can't grasp it. Code for Ball: default { state_entry() { llListen(15,"",NULL_KEY,""); } touch_start(integer total_number) { llDie(); } listen(integer channel, string name, key id, string message) { llDie(); } } Code for Cube: float a = PI; float b = PI; float angle; float radius; vector size; integer balls = 20; integer kill = FALSE; makeBall(){ if (a >= TWO_PI) a = 0; if (b >= TWO_PI) b = 0; vector position = ((llGetPos() + <0,-(size.z / 2),0>)) + <radius * llCos(a += angle), 0, radius * llSin(b += angle)>; llRezObject("Ball",position, <0,0,0>,ZERO_ROTATION, 0); } default { state_entry() { angle = (360.0 / balls) / 180.0 * PI; size = llGetScale(); radius = size.x * 0.67 / 2; } touch_start(integer num) { if (kill) { llSay(15,"x"); } else { integer ct = 0; do { makeBall(); ct++; } while (ct < balls); } kill = !kill; } } 1 Link to comment Share on other sites More sharing options...
Quistess Alpha Posted July 12, 2021 Share Posted July 12, 2021 (edited) 20 minutes ago, Lochlyn Dragonash said: Identify a circle of points on the face of Cube, visually represented by a Ball rezzed on its surface. I can't parse that sentence. actually I can, but it took a couple tries. If I'm understanding correctly what you want is to translate local coordinates to global ones. The code to do that is: vector local2Global(vector pos) { return llGetRootPosition()+pos*llGetRootRotation(); } and if I'm understanding correctly (too lazy to check) you want something like this in your make_ball function: vector position = local2Global( <0,-(size.z / 2),0> + <radius * llCos(a += angle), 0, radius * llSin(b += angle)> ); Edited July 12, 2021 by Quistess Alpha fixed parentheces. 1 1 Link to comment Share on other sites More sharing options...
Lochlyn Dragonash Posted July 12, 2021 Author Share Posted July 12, 2021 Thank you for the quick response. Sorry if I wasn't clear enough in my description. Makes more sense when you see it in world. That's a step in the right direction - the plane of the rezzed ring does appear to obey the rotation of the cube, but now the ring is perpendicular to the face rather than flush with it. I might can figure this out though. Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now