In this course we're going to look at something a little different, creating technically accurate 3D printed parts.
# 1 15-02-2010 , 10:51 AM

Registered User
Join Date: Feb 2010
Posts: 4

#### How are expressions processed?

Hi

I'm currently in a lesson working with basic expressions. The task was to create an expression that would make an oil lamp swing on it's hinge. My original code:

PHP Code:
``` //values are keyed to Impact=50, Dropoff=200, Amp=30 \$angleZ = 0; if (frame > Handle2.Impact){     \$angleZ = (Handle2.ImpactDropoff / frame);     \$angleZ = \$angleZ * (Handle2.Amplitude / 2); } Handle2.rotateZ = sin(frame / 5) * \$angleZ;  ```
I put the two \$angleZ parts on different lines for readability. It's simply my programming style, however it yields a very strange result: At about frame 66/67 the lamp changes direction for 1 frame. If however, I use the following code:

PHP Code:
``` \$angleZ = 0; if (frame > Handle2.Impact){     \$angleZ = (Handle2.ImpactDropoff / frame) * (Handle2.Amplitude / 2); } Handle2.rotateZ = sin(frame / 5) * \$angleZ;  ```
There are no problems.

I can't see at all how the two expressions could possibly run differently, especially as the variable is modified before the angle in both cases. Can someone please explain what is happening?

# 2 15-02-2010 , 02:16 PM

Technical Director
Join Date: Feb 2004
Posts: 2,988
Try switching
Code:
`\$angleZ = \$angleZ * (Handle2.Amplitude / 2);`
to
Code:
`\$angleZ *= (Handle2.Amplitude / 2);`

Imagination is more important than knowledge.

##### 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

0

By Nasser2022 Animation
0

2

1

0

By atonofswans Maya Technical Issues
1

### 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