# Child prims points toward root prim

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

## Recommended Posts

Hi All,

I'm trying to figure out a script that turns/rotate every child prims x axis to points towards the root prim.

##### Share on other sites

```default
{   state_entry()
vector Y = llVecNorm(<0,0,1>%X);
vector Z = llVecNorm(X%Y);
}
}```

note to self: vecNorms are actually required for accurate results.

• 1
• 2
##### Share on other sites

Thanks, it worked like a charm.

##### Share on other sites

That information was very helpful. Is it also possible for linked prims to face towards its adjust / next linked prim same on X axis and not the root prim?

##### Share on other sites

1 hour ago, sunil Treves said:

That information was very helpful. Is it also possible for linked prims to face towards its adjust / next linked prim same on X axis and not the root prim?

You can make each linked prim's x-axis face any which way you like, you just need to set X to a normalized vector indicating the direction (in local coordinates). Conveniently for the above example, the local position of a linked prim is a vector pointing from the root to the prim. A vector pointing from one linked prim to another would be the difference in their positions.

##### Share on other sites

Thanks,

Its bit confusing in terms of maths, may i have an code example?

Suppose there are 5 linked prims  in a zig zag line formation and they need to point at previous link number.

##### Share on other sites

2 minutes ago, sunil Treves said:

may i have an code example?

This (section of the) forum is more for discussing general ideas and methodologies for how to do things, not for asking people to write a complete script for you.

I feel a bit crass saying this, but you really ought to learn to script it yourself, or pay someone else to do it for you (for which you might try the 'wanted' or 'in-world employment' sub-sections of the forum).

##### Share on other sites

Thanks

Apologies if i didn’t explain myself clearly as i didn’t request a complete script but an example for the maths you stated for the difference between there positions.

Even a wiki page would do however I can search myself based on ur suggestion. Also, I’m trying to learn the complex system around rotation and been looking for correct direction using this form

9 hours ago, Quistess Alpha said:

You can make each linked prim's x-axis face any which way you like, you just need to set X to a normalized vector indicating the direction (in local coordinates). Conveniently for the above example, the local position of a linked prim is a vector pointing from the root to the prim. A vector pointing from one linked prim to another would be the difference in their positions.

Edited by sunil Treves
##### Share on other sites

41 minutes ago, sunil Treves said:

Even a wiki page would do.

```vector posA = llList2Vector(llGetLinkPrimitiveParams(linkA,[PRIM_POS_LOCAL]),0);
vector difference = posA-posB;```

The difference between 2 things isn't exactly rocket science?

ETA: while I'm posting wiki links: https://en.wikipedia.org/wiki/Cross_product

More usefully, crossing 2 of these axes in counter-clockwise order gives you the third: Thumb%pointer=middle; pointer%middle=thumb; middle%thumb=pointer

Edited by Quistess Alpha
• 1
• 1