Above is a diagram to help people understand what I'm looking for. This is for a Flash Actionscript 3 project I'm working on.
Ultimately, what I want to be able to do is draw a nice sine curve on any angle, like at the top right of the image. To achieve this I need to calculate the coordinates of a triangle. I can then use C as the control points when using curveTo(); in actionscript the cursor is set to a point (x,y) using moveTo(x,y), then a curved line can be drawn to a second point with a control point defining the curve curveTo(ctrlX,ctrlY,x2,y2).
I found some maths online that looked like it would answer my question, but from the way it was written I've struggled to fully understand it. You can see it here:
ActionScript.org Forums - View Single Post - maths....HELP!Coordinates for point C of an equilateral triangle given points A and B
So, to explain the diagram above, and what I understand:
A (x1,y1) and B (x2,y2) are known as these are the start and end points of my line. D (x4,y4) I also know as these can be calculated from A and B as in the formula above.
Also known is M1, the gradient of the line AB, as calculated in the formula above. I think I need to know M2 (the gradient of line CD) as well, but am unsure how to calculate this correctly. As the triangle is equilateral all internal angles are 60 degrees.
So, what I need to know is how to calculate C (x3,y3) given the information above.
Can anybody help me with the maths to calculate x3,y3 please?
I know it's doable, my maths just isn't good enough (Crying)
BTW The coordinates of a Flash movie (0,0) start in the top left hand corner.
NB The fact that y1 and y2 have different values is important when it comes to drawing the line. I have a feeling it would be much easier if they were the same, but that's not what I need.
Any help would be gratefully received. Please go gently on me in any answer, as maths isn't my strong point.
22.6 KB Views: 109