Obtaining angles of connectors between connected objects

M

Mac

Hello; Imagine objects connected (via connectors, of course) so that they
form triangles, rectangles and pentagons. What I need is the sum of the
three, four or five angles formed by the connectors at each vertice (1 object
= 1 vertice). The connector's angle property is only relative to the
originating object and I need to calculate the angle between both incoming
and outgoing connectors.. Anyone has an idea?
 
P

Paul Herber

Hello; Imagine objects connected (via connectors, of course) so that they
form triangles, rectangles and pentagons. What I need is the sum of the
three, four or five angles formed by the connectors at each vertice (1 object
= 1 vertice). The connector's angle property is only relative to the
originating object and I need to calculate the angle between both incoming
and outgoing connectors.. Anyone has an idea?

Using the connector's BeginX, BeginY, EndX, EndY cells, a bit of
geometry (sine, cos and tan) will give the the angle. This calculation
can be done within the shapesheet.
 
M

Mac

Thank you Paul,
I've already figured out that the only way to get the angle of a connector
is probably to calculate it and now you have confirmed that to me. But what
do you mean by 'within the shapesheet'; I plan on grabbing at the
FromConnects collection of a shape, then iterate through the Connects one by
one while doing my calculations using Connects' relevant CellsSrc proerties.
Is what you suggest more efficient and why? Thank you!
 
P

Paul Herber

Thank you Paul,
I've already figured out that the only way to get the angle of a connector
is probably to calculate it and now you have confirmed that to me. But what
do you mean by 'within the shapesheet'; I plan on grabbing at the
FromConnects collection of a shape, then iterate through the Connects one by
one while doing my calculations using Connects' relevant CellsSrc proerties.
Is what you suggest more efficient and why? Thank you!

If you are using your own connector shape then you could create a cell
within the shape (custom properties, user-defined data or scratch data
areas) and do the angle calculation within the shape.
But as you are doing the calculation re;ative to the shape that the
connector connects to then your has to extract all this data anyway so
probably not worthwhile. Besides if your code does the calculating
then it isn't prone to any editing that might occur in the connector,
accidental or otherwise.
 
V

vojo

with multiple separate connectors, you probably need a macro for this. The
ATN function in VB can give you the angle of the connector. This is what
I do in a different macro

my_angle = Atn(my_deltay / (my_deltax + 0.000001))

y / x the 0.000001 is incase its vertical and there is no delta between x
coordinates. this gives angle in radians....degrees = radians * pi/180 if I
remember right.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top