[SOLVED] How to use ANGLETOLOC() function?

Started by nashwaan, April 25, 2012, 09:43:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nashwaan

How to get the angle of a shape which is inside a nested rotated shapes?

Lets say we have 4 nested shapes where Sheet.1 is parent of Sheet.2, Sheet.2 is parent of Sheet.3, and Sheet.3 is parent of Sheet.4
Then how to get the angle of any of the child shape with respect to Sheet.1? For example if Sheet.2 is rotated by 20 degrees and Sheet.3 is rotated by 20 degrees. Then, effectively, this means that Sheet.3 is rotated by 40 degrees with respect to Sheet.1. But how to get this value without directly writing all the parents of the child shape (except the very first parent)?

I tried to use ANGLETOLOC but it doesn't provide result as i expect! I used the following formula in each of the child shapes:
User.ANGLETOLOC = ANGLETOLOC(Angle,Angle,Sheet.1!Angle)
Please see attached file which has these shapes showing the calculations interactively.

To illustrate this problem, we start off by the 4 shapes without any rotation been applied.


Now, if we rotate the Sheet.2 which is child of Sheet.1 and parent of Sheet.3 by 20 degrees, then we get this result:

Why User.ANGLETOLOC for Sheet.2 reports 40 degrees? I was expecting this to be 20 degrees!
Note the value of User.ANGLETOLOC for Sheet.3 and Sheet.4 reports as i expect: 20 degrees.

And if we then rotate Sheet.3 which is child of Sheet.2 and parent of Sheet.4 by 20 degrees, then we get this result:

Why User.ANGLETOLOC for Sheet.3 reports 60 degrees? I was expecting this to be 40 degrees (20 + 20)!
Note the value of User.ANGLETOLOC for Sheet.4 reports as i expect: 40 degrees.

And if we further rotate Sheet.4 which is child of Sheet.3 and parent of no shape by 20 degrees, then we get this result:

Why User.ANGLETOLOC for Sheet.4 reports 80 degrees? I was expecting this to be 60 degrees (20 + 20 + 20)!

Appreciate any clarifications specially on the proper usage of ANGLETOLOC function.
Please see the attached file and rotate any of the child shapes clockwise and counter-clockwise and note the angle values.

Thanks,
Yousuf.
Give me six hours to chop down a tree and I will spend the first four sharpening the axe — Abraham Lincoln

Jumpy

#1
Can't answer the question directly, but, couldn't you use the Page as reference instaead oh Sheet.1!Angle  in the formula?

Isn't the angle of Shape 4 the sum of the angles of Shape 1+2+3? Maybe u could use that, but note that there could be trouble with flipped shapes.

Or what happens with this small modification:
User.ANGLETOLOC = ANGLETOLOC(Angle,Angle,Sheet.1!Angle)-Angle

Don't have Visio at the moment, so can't test it myself.

nashwaan

Thanks Jumpy for your reply.

Yes, the angle of Shape 4 is the sum of the angles of all four shapes. But i don't want to go for that approach because i don't want to refer to the parent shapes directly in the formula (except the very first parent shape of the group).

The formula User.ANGLETOLOC = ANGLETOLOC(Angle,Angle,Sheet.1!Angle)-Angle
helps to solve part of the issue but not completly.  :) Try it and you will know.

But the main question remains, why ANGLETOLOC() doesn't provide the result as advertised?
Is this a bug or am i missing something here?  :-\

I hope the Visio drawing attachement in the first post is clear to examine this issue.

Thanks,
Yousuf.
Give me six hours to chop down a tree and I will spend the first four sharpening the axe — Abraham Lincoln

aledlund

AFAIK
"User.ANGLETOLOC = ANGLETOLOC(Angle,Angle,Sheet.1!Angle)"
Where angletoloc supplies an angle, when in the user section angles are defaulted to radians, not degrees

Secondly: are you defining the parent as sheet.1 in the
ANGLETOPAR(srcAngle, srcRef, dstRef) definiton as well as the ANGLETOLOC?

al


nashwaan

#4
Thanks Al for your reply.

In my test setup, ANGLETOLOC() returns the angle in degrees. Even if the angle supplied is in Radians, Visio is smart enough to do the right conversion when passed as an argument to another function.

And yes, i defined the parent as Sheet.1 in ANGLETOPAR(), which in this case is equivelant to defining ThePage as the local in ANGLETOLOC().

Anyways, my main concern here is to understand the return value of ANGLETOLOC(). The attached test setup demonstrates this issue.

Yousuf.
Give me six hours to chop down a tree and I will spend the first four sharpening the axe — Abraham Lincoln

Jumpy

Thought a bit about that problem, but as I currently have no Visio available I couldn't test it.

User.ANGLETOLOC = ANGLETOLOC(Angle,Angle,Sheet.1!Angle)

What if you replace the second Angle in the formula with any other cell in the shape?

nashwaan

Thanks again Jumpy for the attempts to help with this issue.

I tried to change Angle in the second argument to diffrent cell names; but as i expected there is no change in the result. In fact the cell names in the second and third argument are merely a way to reference the shape/page that owns these cells. VisGuy has this to say regarding these arguments:

Quote from: Visio Guy on June 24, 2008, 09:11:54 AM
Those funny arguments at the end of the functions serve to tell Visio "from which shape" and "to which shape" you want to transform.

There is no "Sheet identifier" in the ShapeSheet that can stand on its own. I.e. you can't just write "Sheet.2" in a ShapeSheet cell or function. So they've written "Sheet.2!Width", but the function really only cares that it needs to do something with Sheet.2s coordinate system. It could have been "Sheet.2!FlipX" or anything.

Ok, i think i found the answer. Though i did not test this throughly:

User.ANGLETOLOC = ANGLETOLOC(0 deg,Angle,Sheet.1!Angle)

The first argument should be 0 deg and not the Angle of the shape!

Yousuf.
Give me six hours to chop down a tree and I will spend the first four sharpening the axe — Abraham Lincoln

Jumpy

Now that I think about it, it sounds good because 0 deg is always the angle of the shape in it's own coordinate system. The value in the Angle-cell represents the shape's angle in the parent-coordinate-system.