Angles to vector
-
hi and many thanks for the precise answers i received for the previous question!
while reading tutos on ruby/sketchup i kind of remember of an "angles to vector" method.. supposed it was in Geom but i found nothing similar in the api reference on http://www.sketchup.com/intl/en/developer/docs/ourdoc/geom.php. And i can't find the tuto anymore in the mess of my browser's history.
so my question is: is there any function/method like this or do i have to sine/cosine the angles myself.
grtz
Abakobo
-
vector1.angle_between(vector2)result in radians...
See under 'Vector3d'... -
thanks! but this is vector to angle...
what i'm looking for is a method that ouputs a normalized Vector3d..
the arguments would be it's projection angle on xy plane and xz plane (with x axis).. actualy i already made a method with cos/sin myself but i'm afraid it will slowdown calculations when in loops and suppose a method from ruby/sketchup stds would be faster as i suppose it is in a lower level...grtz
abakobo
-
There is no inbuilt method... but this will do it [flattened to Z-plane]
def flat_angle(vector) vec=Geom;;Vector3d.new(vector.x, vector.y, 0) if vec.y < 0 return (2*Math;;PI)-(vec.angle_between(X_AXIS)) elsif vec.y > 0 return vec.angle_between(X_AXIS) elsif vec.y == 0 if vec.samedirection?(X_AXIS) return 0 else return Math;;PI end end endit's easy to make methods for X & Y planes - just adjust vec= to suit those other planes and adjust the tests from vec.y & _AXIS etc...
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement