Canvas Issue: Drawing a line through 3 points

Get help using Construct 2

Post » Wed Aug 21, 2013 4:54 pm

Oh ! And the line will always hit the wall ? Then this should do the trick :

X1 = FirstObject.X
Y1 = FirstObject.Y
X2 = Wall.X
Y2 = FirstObject.Y + Tan(Angle(FirstObject.X, FirstObject.Y, SecondObject.X, SecondObject.Y)) * abs(FirstObject.X - Wall.X)
B
76
S
31
G
27
Posts: 1,015
Reputation: 20,790

Post » Wed Aug 21, 2013 10:11 pm

That was near the solution, thanks! But for some values, the line breaks.
The formula I have finally used and works fine is:

Y=((((X-x1)*(y2-y1))/(x2-x1))+y1

Where x1,x2,y1,y2 and X are known values.

Nevertheless, thanks a lot!
B
17
S
4
G
1
Posts: 105
Reputation: 1,874

Post » Thu Aug 22, 2013 2:49 pm

That's pretty much the same formula without using the angle !

Tan(angle) = (y2-y1) / (x2 - x1)

Replacing that in my formula, we obtain the same thing ! Maybe there's something wrong with the angle() function... Nevertheless, you're better off without it !
B
76
S
31
G
27
Posts: 1,015
Reputation: 20,790

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests