Grasshopper

algorithmic modeling for Rhino

Why the "angle between vectors" component is always positive?

I have to know the angle between a lot of vectors, but some times this should be negative, I thought that this component measure the angle in the direction of the clock.

Any idea of how can I get the real angles, negative and positive???

Views: 29151

Replies to This Discussion

This answer will always be positive because A)in order for there to be a negitive angle there needs to be an defined axis and B) having a negitive rotation implies going from condition A to condition B and the angle component is only concerned about the absolute angle between the two vectors.

Its very hard to say how exactly to get you the rotation that your looking for without really knowing what your working with. Ultimately though, the angle is there, so you just need to find out what condition needs the postive version of it, and what condition needs the negative version. This will largely depend on how you setup your axis, because you can rotate different ways depending the orientation of that axis.
This has always bothered me as well.... I took some time today and wrote a def. I hope this helps.

Input a 'base' point and an 'evaluation' point, and the def returns the absolute angle, measured counterclockwise from the positive x-axis (like we all remember from geometry class!).

definition:
Attachments:
Here's the way that I handle this (pretty much Damien's method.)

1) Calculate the difference in the normal way.
2) Measure each one against a reference in my case Y vector
3) Compare each referenced angle to find which is greater
4) Pass the True/False trough a replace string to get -1/1 instead of 0/1
5) Multiply the actual angle by these to get negative and positive angles


It looks a bit clunky because of some limitations I came across with the way GH handles strings. In an ideal world I would like to have just replaced ZERO with -1 but because of the special character "-" I had to change 1s for 2s and then subtract 1 again.
Danny,

This might be a touch cleaner. You can still work with booleans for the subtraction.

Implementing and testing Taz's boolean switch made me realize that the method I outlined above does not work for every condition. My definition had fairly small angles to measure predominantly in the NE to SE sector of the compass if there was a W factor in it I don't think this would work.
:(
I think there's a more reliable way to do all this, but in pure GH components its way messier than it needs to be. I'll write a script or a component tomorrow to do this and it will make it easier. Essentially, it will take the axis for the rotation from the plane that's created by the normals, and make that axis always point in a reliable direction (which ATM would be up, i guess), then I'll make it output the positive and negative angles...maybe with the option to switch between radians and degrees...
Sorry Taz, I forgot to say nice booleans

Hey Danny, Can I have your grasshopper definition for this post please?

Thanks,

2010? hum, better forget about it! You probably couldn't even open it with current version of gh!

Anyway the true anwer to this question is :

Angle measurements in 3D are always positive and between 0 and 180. You need to supply a plane input, then the angle goes 0 to 360.

OK. thank you Fred!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service