Vector.AngleWithVector - measuring direction problem?

Hi, guys! I am working on a script for apartment buildings, meant to renumber rooms in each appartment(each one is a separate area in our case), based on the angle of rotation from the entrance door. However, I noticed Vector.AngleWithVector node seems to return the angles measured in a different direction each time:

Here are the angles measured for this apartment:

Here are the sample files used:
RVT: https://siasky.net/AAC8WQCwjmk2i0nchBXzUl3Zn5TDM3WhHI_4-bkz7dwy1A
Dynamo: https://siasky.net/nAClSe6bR2lzv9yJZ5b9GHquUvtSSeqsXtrw6FnYc8VFPA

At first, I thought the issue might be caused by the fact I am measuring the angle with a canonical vector in this case - 0,1,0, while others have specific coordinates. I found out even if I try to place it in the right location, it is still converted to the canonical one:

However, I tried to replicate the issue in a simple script, but it seems to be working just fine:

So I think this is not the cause of the problem… Just in case, I am uploading this script as well:
https://siasky.net/JABU_emO1Ky9hZgWPUPJwSoBCb2D54iUuJJ-rXMUn66I7Q

I really thought this to be a simle and a straightforwards task, but I already spent loads of time, trying to resolve the issue. Any help would be appreaciated! :frowning:

1 Like

Angle with vector will always return the ‘smallest’ angle, so you will never get results over 180.

Try Vector.AngleAboutAxis and specify the canonical Z Axis as the axis.

2 Likes

Hi, Jacob. I tried that already, same result :frowning: I don’t really need an angle, larger than 180, but at least I need it measured in the same direction each time, otherwise it’s not really usable. I am still not sure if it is a direction related problem though, as I could not recreate it in the separate example. Also, in the abovementioned example (the first one) you may see angles are not returned with the smallest value in each case, which is kind of weird

Use the dot product node and convert radians to degrees

Edit: My bad here. Wrote that before my coffee. I meant you could try the dot product of the normalized vectors and use the inverse cosine to get the angle. However that should give you the same result as Vector.AngleWithVector.

You mentioned in your test the node gives the angles as expected so I’d check then if I am comparing it to the right thing.
To get consistent results in different rooms you’d need a vector based in the location of the door and pointing towards the rooms.

3 Likes

Hi, Viktor, thx for coming to rescue! That’s actually what I am doing now as well, I have vectors starting at the location point of each door and going to the center of each room (geometric center, projected onto the level plane, not the placement point):

I bould those lines to visualise the vectors I am using at the moment. As for the vector, I am measuring the angles with, I tried to rebuild it, starting from the door location, but I noticed dynamo keeps converting it to the canonical vector:

However, the same thing actually worked in the test file…

But what are you comparing those to in order to get your angle?

I get the location and orientation of each door and then I create a vector, representing it. Like that:

I then tried to move the vector at the location point of each door, e.g. the previous post

In this particular case, the measurement looks like that:

I tried building arcs to measure their sweep angle and it works fine for me in this case :slight_smile:

image

etc.

I will go with that… I am just still curious what was causing the issue with vector measurement, guess we might not find out

2 Likes

Great approach actually.
My guess for the results with the angles in the vectors would be that in some of the cases the vectors go in opposite directions of the others. This would result in 180-(the angle you expect)
Anyway, do let me know if you find out what the actual reason was

1 Like

thx, I think so too, but I keep trying to replicate the issue. If I find out, I will let you know