Hi,

After some coding in Visual Studio I came across a goniomethrical problem:

I want to draw a line.

this line is made by defining two positions. (position = X & Y value)

The first position is constant/stationary over time.

The second position changes over time.

I want to define the second position so that the second position of the line would move in a circular path,

following the traditional formula of drawing a circle

pos2.x = pos1.x + (cos(angle) * length);

pos2.y = pos1.y + (sin(angle) * length);

('angle' changes it's value as time passes)

However, that's not really what I want to achieve.

I want to achieve that the angle of the line would change in the exact same way as the example given above,

however the length of the line has to vary, so that the rotation of the line would fit in a square shape instead of a circular shape.

so that adds another variable: 'size' of the border of the square.

so the variables to use are:

pos1.x

pos1.y

pos2.x

pos2.y

angle

length

'size' of the border of the square

I have been struggling alot with this problem, and I've found some ways to approach the exact visualisation of this problem, but it is far from perfect.

Does anyone have an idea of a formula I could use or a solution to this problem?

Thanks in advance.

see sketch below for help to the visualisation of the problem

http://i54.tinypic.com/315gxsh.png