Over the last couple of years UV layout in Maya has changed for the better. In this course we're going to be taking a look at some of those changes as we UV map an entire character
# 1 08-10-2012 , 04:07 PM

Subscriber
Join Date: Oct 2005
Posts: 1

#### random rotate expression

Hi all, I have been ripping my hair out trying to get this correct. What I have is an airplane that is instanced to particles and moved in formation with an air field. Simple enough, but what I need now is to randomly rotate them like if they are individually rocking back and forth (twists where wngs go up and down).
Have a creation expression of: particleShape1.RandRotate = <<0,0,rand(-3,3)>>; because I want the planes to be created with a rotation, randomly, between -3 and 3. Again simple enough, but now where the problem comes in, I need them to twist smoothly and randomly between -3 and 3 during runtime.
Have a runtime expression of: particleShape1.RandRotate += <<0,0,sin(time*2)*1.1>>; which works, but it does not sweep between the full positive and negative degrees. Would not make any sense to have them only rotate between 0 and 3 say haha.
Anyone have any ideas?

# 2 06-11-2012 , 04:06 AM

Technical Director
Join Date: Feb 2004
Posts: 2,988
You can do this by the following function: (3/2) * (sin(x) + 1)

You also have to remember that in Maya, sine expects units in radians, meaning that 2*pi = (~6.28) = one full cycle of sine. Therefore, in 6 frames, you make a complete cycle of sine. In your expression, you have halved that (remember that multiplying inside the brackets does the opposite transformation), so it now takes 3 frames to cycle completely. The minimums and maximums of sine are found at pi/2 and (3*pi)/2. (Green lines) Since (2*pi)/3 = ~2.1, you are jumping past pi/2, and again past (3*pi)/2. In the example where you are currently hitting are the red lines.

In short:
float \$speed = 0.02;

pCube1.rotateZ = (3.0 / 2.0) * (sin(frame * (1.0 / \$speed)) + 1);

Imagination is more important than knowledge.

Last edited by NextDesign; 06-11-2012 at 04:32 AM.

# 3 03-02-2013 , 05:15 PM

Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
The noise() function is handy for these kinds of situations. It takes in time and outputs values between -1 and 1. So something like this would work:

Code:
```float \$fFreq = 1.0;
float \$fMag = 3.0;

myObject.rotateZ = \$fMag * noise(time * \$fFreq);```

Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!

# 4 03-02-2013 , 07:43 PM

Registered User
Join Date: Aug 2007
Location: The Netherlands
Posts: 88

You can do this by the following function: (3/2) * (sin(x) + 1)

You also have to remember that in Maya, sine expects units in radians, meaning that 2*pi = (~6.28) = one full cycle of sine. Therefore, in 6 frames, you make a complete cycle of sine. In your expression, you have halved that (remember that multiplying inside the brackets does the opposite transformation), so it now takes 3 frames to cycle completely. The minimums and maximums of sine are found at pi/2 and (3*pi)/2. (Green lines) Since (2*pi)/3 = ~2.1, you are jumping past pi/2, and again past (3*pi)/2. In the example where you are currently hitting are the red lines.

In short:
float \$speed = 0.02;

pCube1.rotateZ = (3.0 / 2.0) * (sin(frame * (1.0 / \$speed)) + 1);

trying to combine the commands shown here with a previous one about a flickering light
would you be willing to explain this a little more further....
or maybe i have to open a new thread with an explanation of my goal......???

*
The Universe is larger then you ever can think, But smaller then the size of your imagination.

all are welcome at www.ieoie.nl

##### Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

### Topics

2

3

By sevakvigneshmaya Maya Modeling
2

140

By jasnacholera Maya Basics & Newbie Lounge
0

By AnimatorJC Finished Work
0

### VFX News

On 2022-05-13 13:52:25

On 2022-05-02 20:24:13

On 2022-04-13 16:02:13

On 2022-04-06 12:59:07

On 2022-04-06 12:57:02

On 2022-03-31 12:10:08