Difference between revisions of "LlGetGeometricCenter"

From Second Life Wiki
Jump to navigation Jump to search
 
m
(16 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{LSLFunctionAll|func_id=278|func_sleep=0.0|func_energy=10.0|func=llGetGeometricCenter|return_type=vector|func_footnote=Returns the geometric center of the linked set the script is attached to.|return_text|spec|caveats|examples|helpers|related|also|notes}}[[Category:LSL_Functions]][[Category:LSL_Stub]]
{{Issues/SVC-6579}}{{LSL_Function
|func_id=278|func_sleep=0.0|func_energy=10.0
|func=llGetGeometricCenter|return_type=vector
|func_footnote
|func_desc
|Return_text=that is the geometric center of the object [[Viewer_coordinate_frames#Local|relative]] to the root prim.
|spec
|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.
|constants
|examples
|helpers
|also_functions=
{{LSL DefineRow||[[llGetCenterOfMass]]|}}
|also_events
|also_tests
|also_articles
|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.
|deepnotes=
<source lang="lsl2">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;
}</source>
|haiku={{Haiku|With each added prim|away shifts our origin|to encompass all.}}
|cat1=Physics
|cat2
|cat3
|cat4
}}

Revision as of 01:54, 22 January 2015

Summary

Function: vector llGetGeometricCenter( );

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.

All Issues ~ Search JIRA for related Bugs

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

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;
}

All Issues

~ Search JIRA for related Issues
   Provide better llGetGeometricCenter function.

Signature

function vector llGetGeometricCenter();

Haiku

With each added prim
away shifts our origin
to encompass all.