Hi

I have a math kinda problem where I'm trying to split some lines when two or

more lines connect two shapes. The reason I am doing this is to make it

clear that there are multiple lines connecting the two shapes.

http://www.blackwaterbadgers.co.uk/image1.bmp

Image 1 shows how if you have a line between two shapes, the line is

straight. if you have more than one line, the lines will start overlapping

each other and essentially look like just the one line. What I have done is

to add a pivot to the centre of the line so the lines can be given a curve

as shown in Image 1.

The middle pivot is created when the line is straight so I know its

location. I also know the locations of either end of the line so from this

I can get the angle of the line. I also know the distance by which I want

to offset the middle pivot.

My plan is to run some code (most of this I have written) that looks to see

how many lines are going between the two shapes. If it is one line then I

will leave it alone. If it is more than one line, I want to separate out

the lines.

http://www.blackwaterbadgers.co.uk/image2.bmp

Based on Image 2

I know the location of the two red dots which give me oppA and adjA, from

this I can get the angle x. As I want the middle pivot to move at a right

angle to its origin, I know the angle of y.

hypB is the distance I want to move the pivot from its origin so from this I

can get oppB and adjB.

Based on the middle pivot, I can now use these measurements to offset the

middle pivot.

The only problem is, because I have used Math.Abs to ensure that I now

working with negative numbers, I now need to establish the direction in

which I want to offset the pivot. This isn't too much of a problem but I am

having trouble working out the distance by which to offset the pivot based

on the number of lines.

So my question is, how can I determine the offset direct and length based on

the number of lines?

Ideally, I would like to split the lines evenly so that if I had an odd

number of lines then the middle line would stay straight with the remaining

lines either side. If I have an even number of lines then the lines would

be split evenly.

A colleague suggested going through each line and offsetting each pivot in

the same direction and then moving all the pivots back to a more central

position but I'm sure it would be better to just work out the direction to

move each pivot and by how much.

Does anyone have any idea on how I could achieve this?

Regards, Carl Gilbert