Hi All ,
The premise is to create random pivot positions per piece of geometry. I seem to be having a hard time getting to grips with controlling how I can do this. As I want to be able to push the position pf the pivot towards the boundaries much like fitting the position between 2 values of my choosing.
So what I do know is $CEX , $CEY , $CEY is the centre of each piece. $XMIN and $XMAX etc The X are the extents of the bounding box. Im just not sure how I can take those values and weight more one towards the min or max values.
Rob
? expression pivot manipulation
6581 3 0- circusmonkey
- Member
- 2624 posts
- Joined: Aug. 2006
- Offline
- asnowcappedromance
- Member
- 512 posts
- Joined: July 2009
- Offline
- circusmonkey
- Member
- 2624 posts
- Joined: Aug. 2006
- Offline
Hi Manu,
fit01(rand($CEX+“random number”),$XMIN,$XMAX) Gets me a random position, but Im still not sure how I can weight the values either towards the max or min as every piece will of course have different values. Maybe If I take the values and fit them into zero to 1 it might be more controllable. to help me better understand whats going on with the values Ive created a couple of detail attributes so I have the values in front of me. ( new scene) Then the aim is to jam the lot into a foreach !
rob
fit01(rand($CEX+“random number”),$XMIN,$XMAX) Gets me a random position, but Im still not sure how I can weight the values either towards the max or min as every piece will of course have different values. Maybe If I take the values and fit them into zero to 1 it might be more controllable. to help me better understand whats going on with the values Ive created a couple of detail attributes so I have the values in front of me. ( new scene) Then the aim is to jam the lot into a foreach !
rob
Gone fishing
- asnowcappedromance
- Member
- 512 posts
- Joined: July 2009
- Offline
oh sorry Rob, last time it was me who was tired
of course you want to control your offset values per piece by taken into account the length in x, y or z.
So you just calculate the length of one of the components and divide that by 2:
xLen = xmax + abs(xmin) / 2
and then you can offset the component by adding or subtracting this value from your centroid variable:
$CEX + fit01(rand($CEX+1),-xLen, xLen)
This only works if your centroid is exactly in the center of you piece, if not, it would be safer to clamp this offset in order to avoid that the new value lies outside of you boundaries. The best way would be to use the center of mass instead.
of course you want to control your offset values per piece by taken into account the length in x, y or z.
So you just calculate the length of one of the components and divide that by 2:
xLen = xmax + abs(xmin) / 2
and then you can offset the component by adding or subtracting this value from your centroid variable:
$CEX + fit01(rand($CEX+1),-xLen, xLen)
This only works if your centroid is exactly in the center of you piece, if not, it would be safer to clamp this offset in order to avoid that the new value lies outside of you boundaries. The best way would be to use the center of mass instead.
-
- Quick Links