# Help with circle rezzing

Please take a moment to consider if this thread is worth bumping.

## Recommended Posts

I am using a modified version Glen larsen's looprez script to generate circular linksets, the code below works beautifully , creating a ring of prims around the world z axis of object the script is in, what I would like to do is have them rezzed around the objects local axis...rotate the object 45 degrees on say the x axis and when it rezzes the prims, the resulting loop is also rotated 45 degrees on the x...

////////////////////////////////////////////////////////////////////////////////
// LoopRez v0.61, by Ged Larsen, 2 February 2007
//
// - rez a number of objects in an ellipse, whose size is determined by xRadius and yRadius
// - all facing "outwards", along a tangent to the ellipse
// - can set how much the objects flare outwards
// - properly handles object rotation corrections (for example, X-axis 180 degree rotation helps for flexi-prim skirts)
// - can also get a 'saddle' bend, to generate a bend that might help for necklaces (from Ariane Brodie)
//
// - (the only difference between v0.6, previously released, and v0.61 is changing some integers to floats, and consolidating some vector math
//
// To use:
// 1) create a prim that will contain this script and the object to use
// 2) put the script into the prim
// 3) create an object that will be used, and name it "Object"
// 4) put "Object" into the prim containing the script, by dragging it from your inventory
// 5) get out of Edit Mode, and touch the prim
//
// Random note:
// - this version does NOT insure equal spacing of objects along the perimeter of the ellipse
// - i.e., objects "bunch up" at the long ends of an ellipse; the effect should be acceptable for non-extreme ellipses
// - even spacing of objects can be accomplished, but requires simulation of integral calculus, which slows down the script
//
// References:
// - tangent formulas from: http://mathworld.wolfram.com/Ellipse.html
//
// I don't know all those fancy legal terms, but bottom line is that you can do whatever
// you want with this script. Have fun :)
//
// If you like this, check out LoopRez Deluxe at http://slged.blogspot.com
//

////////////////////////////////////////////////////////////////////////////////
// CONFIGURATION PARAMETERS, change these to your liking

string objectName = "Oval Bead"; // object to use; will need to be in the inventory of the prim containing this script
integer numObjects = 32; // how many objects
float flareAngle = 45.0; // how many DEGREES the bottom of object will flare outwards, the "poof" factor
float bendCoefficient = 0.02; // makes a "saddle shape", bends DOWN this number of meters at extremes of X-axis
vector rotOffset = <0.0, 180.0, 0.0>; // rotation offset in DEGREES -- fixes the rotation of ALL objects; for flexi prims, often you will want <0.0, 180.0, 0.0>
vector posOffset = <0.0, 0.0, 0.0>; // position offset

////////////////////////////////////////////////////////////////////////////////
// No need to mess with anything below here

makeLoop()
{
vector size=llGetScale( );
llSay(0,(string)numObjects);
integer n; // which object is being placed
float theta; // angle in radians
vector pos; // position
rotation rot; // rotation in quaternion format

for(n = 0; n < numObjects; n++) {

theta = TWO_PI * ( (float)n / (float)numObjects );
pos = llGetPos() + posOffset + < xRadius * llCos(theta), yRadius * llSin(theta), -bendCoefficient*llCos(theta)*llCos(theta)>;

rot = llEuler2Rot( DEG_TO_RAD * rotOffset); // user-chosen rotation offset correction
rot = rot * llEuler2Rot(<0.0, -1.0*flareAngle*DEG_TO_RAD, 0.0>); // flare generation (poof)

// the following make the objects face outwards properly for an ellipse; using theta alone is only correct for a circle
// the scary formula calculates a unit vector TANGENTIAL to the ellipse, and llRotBetween is used to figure out how much the object needs to rotate to lie parallel to the tangent
if ( n== (numObjects/2) ) // LSL's implementation of llRotBetween at theta = pi radians is reversed at 180 degrees, so this manually corrects it
rot = rot * llEuler2Rot( <0.0, PI, 0.0> );

llRezObject(objectName, pos, ZERO_VECTOR, rot, 0);
}
}

default
{
state_entry()
{

}

touch_start(integer total_number)
{
if (llDetectedKey(0) == llGetOwner())
{
makeLoop();
}
}
}

##### Share on other sites

In the long run, you should probably buddy-up with a friendly scripter to do these minor fixes for you. In theory, we should tell you to go hire one from a different forum, but what you want is so tiny it seems more work for you to post again than for one of us to just give you the change.

pos = llGetPos() + posOffset + < xRadius * llCos(theta), yRadius * llSin(theta), -bendCoefficient*llCos(theta)*llCos(theta)> ) * llGetRot();

and assuming you want the rezzed objects' orientations to correspond to the object around which they're rezzing, the actual rezzing would be done with:

llRezObject(objectName, pos, ZERO_VECTOR, rot * llGetRot(), 0);

(I happened to notice that the placement doesn't behave very well when there's an odd number of objects to be rezzed, but you'd need somebody more motivated than I to delve into that.)

• 1
##### Share on other sites

i just add a whatelse on here

if just want to make a ring then a whatelse way is with a shooter. example:

`string thingy = "rezthingy";  // thingy in contentsinteger num = 6;  // make the num of thingys to rez a multiple of 2, 3 or 5 to space goodfloat dist = 2.0; // distance from rezzershooter(){    rotation save = llGetRot(); // save start orient of rezzer    rotation rads =  // radians to rotate on each step        llEuler2Rot(<0, 0, 360.0 / (float)num> * DEG_TO_RAD);    vector pos = llGetPos();    integer i;    for (i = 0; i < num; i++)     {  // rez the thingys by rotate the rezzer       rotation rot = llGetRot();          llRezObject(thingy, pos + <dist, 0, 0> * rot, ZERO_VECTOR, rot, 0);       llSetRot(rads * rot);            }    llSetRot(save);  // tidy by set rezzer back to start orient  }default{    touch_end(integer total_number)    {        shooter();    }}`

• 1
##### Share on other sites

Well, heck, if you're going to go to that trouble, you might as well just write the script for an ellipse instead of a circular path. :smileywink:  You can do that, without rotating the rezzer, with something like this ...

`string thingy = "Test rez object";  // thingy in contentsinteger num = 10;  // Number of thingies to rezfloat MajAxis = 3.0;    // length of semi-major axis of your ellipsefloat MinAxis = 2.0;    // length of the semi-minor axis of your ellipsevector NewPos (float Theta){    // Avoid nasty division by zero problems by making a tiny deliberate    //    "error" in angles close to zero or PI/2 or 3*PI/2    if (llTan(Theta) < llTan (1.0*DEG_TO_RAD) )    {        Theta += 1.0*DEG_TO_RAD;    }    else if (llTan(Theta) > llTan(89.0*DEG_TO_RAD))    {        Theta -= 1.0*DEG_TO_RAD;    }    float TanSq = llTan(Theta)*llTan(Theta);    float X = (MajAxis * MinAxis)/ llSqrt(MinAxis*MinAxis + MajAxis*MajAxis*TanSq );    float Y = (MajAxis * MinAxis)/ llSqrt(MajAxis*MajAxis + MinAxis*MinAxis/TanSq);    if ((Theta >= PI/2.0) && (Theta <= 3.0*PI/2.0))    {        X = -X;    }    if ((Theta >= PI) && (Theta <= 2.0*PI))    {            Y = -Y;    }    return <X, Y, 0.0>;}default{    touch_end(integer total_number)    {        float rads = 360.0*DEG_TO_RAD/(float)num;        vector pos = llGetPos();        integer i;        for (i = 0; i < num; i++)         {            rotation rot = llEuler2Rot(<0.0,0.0,rads*i>) * llGetRot();              llRezObject(thingy, llGetPos() + NewPos(rads*i)*llGetRot(), ZERO_VECTOR, rot, 0);        }    }}`

Notice that because the llRezAtRoot command adjusts the NewPos by llGetRot, you can tilt the rezzer any way you like to get the resulting elliptical layout in the right orientation.

ETA:  Oh, because objects are rezzed at even angular intervals, they won't be spaced a fixed distance apart on the path.  You'll notice that Larsen's old LoopRez script does the same thing.  I remember commenting on that years ago, but concluding that it's a trivial issue for rezzing skirt panels because a waist is not very big and not dramatically elliptical. You could write the script to create equal spacing instead of equal angular measurement, but that's a different challenge (much nastier).  :smileywink:

• 1
##### Share on other sites

Thanks, I appreciate it..everything is working great now, it's a small piece of a larger project but rotations throw me from time to time..thanks again

##### Share on other sites

yes. for a building tool your way is much better

+

i just show a shooter bc i used to make those kinds of things once. Flying shooters with bling on. They quite fun to watch. Zoom round in patterns going pew pew pew!! (:

##### Share on other sites

Hehe.   Especially if they rotate fast and rez fast -moving physical objects.

##### Share on other sites

nuuu !!!  can get in big trouble doing that if not careful (:

sky painters and sky runners tho are pretty cool. Fractal paintings as well. with a little puppet person as the rezzer. with a brush. splish splosh splish splosh splash !!

+

for anybody who might have a go at doing this then is best when doing paintings to put the rez object on temp_rez or lldie. Otherwise can take ages to delete all the prims afterwards