Difference between revisions of "LlGetGeometricCenter"

From Second Life Wiki
Jump to navigation Jump to search
m (quick implementation)
m
Line 17: Line 17:
|notes=
|notes=
* The "geometric center" is the average of all linked prim centers. Mathematically, it's the root-relative positions of all linked prims in the linkset added together and divided by the number of prims in the linkset.
* The "geometric center" is the average of all linked prim centers. Mathematically, it's the root-relative positions of all linked prims in the linkset added together and divided by the number of prims in the linkset.
|deep_notes=
|deepnotes=
<lsl>vector GetGeometricCenter(){
<lsl>vector GetGeometricCenter(){
     vector center = ZERO_VECTOR;
     vector center = ZERO_VECTOR;

Revision as of 23:01, 28 February 2012

Summary

Function: vector llGetGeometricCenter( );
0.0 Forced Delay
10.0 Energy

Returns the vector that is the geometric center of the object relative to the root prim.

Caveats

The "geometric center" is different from the "center" in viewer's build tools and also different from what llRezObject considers to be the "center" of a linkset.

Examples

Notes

  • The "geometric center" is the average of all linked prim centers. Mathematically, it's the root-relative positions of all linked prims in the linkset added together and divided by the number of prims in the linkset.

See Also

Functions

•  llGetCenterOfMass

Deep Notes

<lsl>vector GetGeometricCenter(){

   vector center = ZERO_VECTOR;
   integer p = llGetNumberOfPrims();
   //since we skip the root prim, we can ignore the single prim case.
   //If we weren't skipping the root, this would be more complicated.
   integer i = 1;
   while(i < p)
       center += llList2Vector(llGetLinkPrimitiveParams(++i, [PRIM_POS_LOCAL]), 0);
   return center / p;

}</lsl>

Signature

function vector llGetGeometricCenter();