07.12.2012 Views

Adobe Director Basics

Adobe Director Basics

Adobe Director Basics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ADOBE DIRECTOR BASICS<br />

3D: Controlling action<br />

on GetDistanceToPlane(aPointInSpace,aPointOnPlane,aNormalToPlane)<br />

-- INPUT: All parameters must be vectors<br />

-- and must be position<br />

-- vectors<br />

-- must not have a length of zero<br />

-- OUTPUT: Returns the distance from aPointInSpace to the<br />

-- closest point in the plane<br />

---------------------------------------------------------------<br />

vNormal = aNormalToPlane.getNormalized()<br />

vPlaneToPoint = aPointInSpace - aPointOnPlane<br />

vDistance = vPlaneToPoint.dotProduct(vNormal)<br />

return vDistance<br />

end GetDistanceToPlane<br />

Getting the closest point in a plane<br />

Where will the fridge magnet jump to when the user releases it? The following handler uses the<br />

GetDistanceToPlane() to find the closest position rather than the distance:<br />

on GetClosestPointInPlane(aPosition,aPointOnPlane,aNormalToPlane)<br />

-- INPUT: All parameters must be vectors<br />

-- and must be position<br />

-- vectors<br />

-- must not have a length of zero<br />

-- OUTPUT: Returns the closest point in the plane to aPosition<br />

---------------------------------------------------------------<br />

vNormal = aNormalToPlane.getNormalized()<br />

vDistance = GetDistanceToPlane( \<br />

aPosition, \<br />

aPointOnPlane, \<br />

vNormal)<br />

vPointInPlane = aPosition - vNormal * vDistance<br />

return vPointInPlane<br />

end GetClosestPointInPlane<br />

Mapping a vector to a plane<br />

Imagine that you have an inclined plane with a ball on it. The force of gravity acts vertically on the ball. What<br />

proportion of that force acts parallel to the plane to make the ball roll?<br />

Imagine that you have a pole in the ground at an arbitrary angle, and that the sun is directly overhead. What will be<br />

the length and direction of the pole's shadow?<br />

You can use following handler to solve both these questions:<br />

Last updated 8/26/2011<br />

380

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!