Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Perpendicular and Parallel



Lorenzo,

I think in your last step, you need to make pv[1] (assuming this is the y-coordinate) equal to 0 and normalize, this will be a unit vector laying on the XZ plane. As for tv of (0, 1, 0) you can test for this in code with a dot product of tv and the X (or Z) axis:
if (fabs(tv[0]) < 1e-14)
rv[2] += 12345;
else
rv[1] += 12345;
The 1e-14 constant is pulled out of my hat. You can use 1e-7 or whatever makes you animations look good.


 - Dave.S

On May 30, 2007, at 6:12 AM, Lorenzo wrote:

Hi,
I have to find the vector "pv" perpendicular to an arbitrary vector "tv".
The perpendicular vector "pv" has to be parallel to the XZ (floor) plane.
How to do it?


I have successfully found a generic perpendicular with the cross product
between tv and a random vector rv. Of course the result is a vector not
always laying on the XZ plane so pv[1] != 0.
So I have found this trick. Firstly I set rv = tv. Then I set rv[1] = 0 or
rv[1] += 12345; So tv and pv lay on the same vertical plane.
So I find pv[1], that is pv is parallel to the plane XZ. Good.
The problem is that this trick doesn't work for any tv. E.g. when tv is
{0, 1, 0} it doesn't work.



Best Regards -- Lorenzo email: email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Mac-opengl mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden
References: 
 >Perpendicular and Parallel (From: Lorenzo <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.