Finding a face's azimuth
-
Hi all,
Just wondering if anyone has any ideas on how to figure out a face's azimuth within sketchup. I've spent a while looking at this but haven't come up with anything too useful as yet. Any ideas would be greatly appreciated.
My current value for azimuth is being calculated as such:
def azimuth
a = self.normal
a.z = 0
a.angle_between(Geom::Vector3d.new 1,0,0).radians
endbut is not correct
Best Regards
-
No help here, but I would like to ask a faavor. Can you draw, in SU, an example that illustrates what an azimuth is? And, how an example one would be calculated? I went to wikipedia and I still don't get it.
Thanks, Todd
-
-
Well, that's easy enough to understand with a picture! Thanks azuby.
So, all that's needed to determine the azimuth is
- you have to know the north angle
- you need the face normal.
Right?
I'm also guessing an azimuth value is worthless without some type of lat-long to go along with it. Is this correct?
Todd
-
M:
Do you need the angle in plan (projected down to the ground plane)? Also, be aware that the angle_between method will not return a negative value. It's always the absolute value of the difference, and it is that angle in 3D (not in plan). CB.
-
The problem is compounded by angles generally being measured counter-clockwise, while azimuth angles are measured clockwise.
I think it would come down to determining the quadrant of the vector (by checking X and Y for +/- value), then adding the previous right-angle azimuth vector to the angle_between of it and the specified vector
if vector.x>0 if vector.y>0 az = [0,1,0].angle_between(vector).radians else az = [1,0,0].angle_between(vector).radians+Math;;PI/2 end else if vector.y<0 az = [0,-1,0].angle_between(vector).radians+Math;;PI else az = [-1,0,0].angle_between(vector).radians+(3*Math;;PI/2) endThe above example doesn't take into account cases where x or y equal zero, so you'll have to add that. It shouldn't be too difficult, though.
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