SOLVED Math question with drawing a triangle

Hi everyone,

I could use some help with the parameters for draw_triangle(x1, y1, x2, y2, x3, y3, outline)

I'd like to draw a triangle where the coordinates of the first point are pre-determined, and the coordinates of the other two points are determined based on distance and rotation from the first point. So for example, let's say point 1 is at (50,50), point 2 is 90 degrees with a distance of 20, and point 3 is 180 degrees with a distance of 40. In this case, I need a calculation so that point 2 lands at (50,30) and point 3 lands at (10,50).
I'm pretty sure this is basic trigonometry, but it's been so long since I took that in high school and I could use some direction.

Thanks for your help!
 

Attachments

distance and rotation
This is exactly what the lengthdir_* functions are for. If you have a specific distance (or length) and rotation (or dir), plug those into lengthdir and it will spit out the coordinates needed for that. It is, as you said, simply using trig, and you can achieve the same effect using cos and stuff, but lengthdir is the easiest way for us less maths-heavy folk to figure out the things.
 

Yal

šŸ§ *penguin noises*
GMC Elder
This is exactly what the lengthdir_* functions are for. If you have a specific distance (or length) and rotation (or dir), plug those into lengthdir and it will spit out the coordinates needed for that. It is, as you said, simply using trig, and you can achieve the same effect using cos and stuff, but lengthdir is the easiest way for us less maths-heavy folk to figure out the things.
I'm maths-heavy*, and I still prefer them over the real trigonometric functions :p One of the reasons being that GM has an inverted y axis, and lengthdir_y handles that, so there's less opportunities for you do get minus signs in the wrong places and mess stuff up.

* frequency domain transforms, linear algebra, tensors, differential equation systems, curved coordinate systems, ...
 
Top