[mel]rnd rotate 'y', but with snapping?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
Old 01 January 2011   #1
[mel]rnd rotate 'y', but with snapping?

hey peeps.

I made this.. maybe someone could use that..
now I need to actually rotate by steps like, 90degree steps.
Any Idea anyone?

string $sel[] = `ls -sl`; print $sel;
 float $yran = 0;
 for($i = 0; $i < size ($sel); $i++){
  $yran =  rand(0.2, 260);
 rotate  0 ($yran) 0 $sel[$i];

thanks bastian
Old 01 January 2011   #2
You could add a multiplier (example with step size of 30 degrees):

string $sel[] = `ls -sl`; print $sel;
 float $yran = 0;
 float $step = 30;
 for($i = 0; $i < size ($sel); $i++){
  $yran =  floor(rand(0, 10) + 0.5) * $step;
 rotate  0 ($yran) 0 $sel[$i];
blog ----- portfolio
Old 01 January 2011   #3
you're my hero, thx!
the floor thing is nice.. was also searching for a round thing for some time
Old 01 January 2011   #4
Originally Posted by Sorath: ... was also searching for a round thing for some time

global proc float roundFloat (float $f, float $precision)
	$f /= $precision;
	float $f1 = floor($f);
	float $f2 = ceil($f);
	float $v = (($f - $f1) > ($f2 - $f)) ? $f2 : $f1;
	return ($v*$precision);
roundFloat 72 90
// Result:90//
roundFloat 72 30
// Result:60//

Last edited by denisT : 01 January 2011 at 02:57 PM.
Old 01 January 2011   #5
wohoo! thx denis.
Old 01 January 2011   #6
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 05:48 PM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.