Angle between 3 points

For questions about using Classic.

Post » Mon Aug 11, 2008 5:16 pm

While I forgot this stuff from school and can sort of look it up, is there any better way of working this out? I need to be able to calculate this relative angle because it changes some variables and I need to have them handy.
B
2
G
4
Posts: 29
Reputation: 1,108

Post » Mon Aug 11, 2008 5:30 pm

you mean if you have like
...............A.......
............../........
............/..........
.........../...........
........./.............
......../\.............
.......B a |...........
........\ /.............
..........\.............
........... \...........
.............C.........
I think if you do angle(Bx,By,Ax,Ay)-angle(Bx,By,Cx,Cy) it should work
(lol really bad ascii picture)
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Mon Aug 11, 2008 5:32 pm

er, scratch that. No, that wouldn't work at all. I already tried it and it should've been obvious in the first place because "angles" in construct (and many other maker program) don't even work that way.

That is, when I did it, depending on which way it was facing caused drastic changes in the variables.
B
2
G
4
Posts: 29
Reputation: 1,108

Post » Mon Aug 11, 2008 5:55 pm

[quote="Cheez":2zzsa73c]er, scratch that. No, that wouldn't work at all. I already tried it and it should've been obvious in the first place because "angles" in construct (and many other maker program) don't even work that way.[/quote:2zzsa73c]

If you mean animation angles, then... yes actually they do. Those angles face the same way as "real" angles. What exactly are you trying to do? It would be easier to help you if we knew the problem.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Mon Aug 11, 2008 6:04 pm

The problem is, you're not making any sense, because an angle doesn't face any particular direction. You can say anything you want about "real" angles, but a 30 degree angle isn't going to change if you turn it. I'm now beginning to wonder if you people ever even went to school, as you have no idea what I'm talking about even WITH the subject.
B
2
G
4
Posts: 29
Reputation: 1,108

Post » Mon Aug 11, 2008 6:13 pm

Angles in Construct work as bearings, with 0 degrees pointing along the X axis and incrementing clockwise. Going by the diagram above, you can find the bearing from B->A using angle(B.X, B.Y, A.X, A.Y) and B-C with angle(B.X, B.Y, A.X, A.Y). However, to get the angle between the two bearings is a bit trickier - you can't just subtract them (sometimes you'll get something like 0 and 270 - the difference is clearly 90 degrees, not 270 as you'd get by subtraction). This requires some funky math which would be a fair bit easier to add as built in expressions to Construct. I'll see if I can add something like that for the next build.

As deadeye said, what's the end result you want? There might be an easier way if its for a game or something.

Cheez: lay off the insults. People are trying to help you.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Mon Aug 11, 2008 6:24 pm

Hey, I think I'm perfectly justified in saying that. It's not hard to understand "finding the angle between 3 points". I need the actual angle that makes up those 3 points, so I can use the angle as a variable. From the looks of it though, it doesn't seem like there's any simple way out than doing the whole thing by hand.
B
2
G
4
Posts: 29
Reputation: 1,108

Post » Mon Aug 11, 2008 6:31 pm

[quote="Cheez":2rq3sh3q]The problem is, you're not making any sense, because an angle doesn't face any particular direction. You can say anything you want about "real" angles, but a 30 degree angle isn't going to change if you turn it. I'm now beginning to wonder if you people ever even went to school, as you have no idea what I'm talking about even WITH the subject.[/quote:2rq3sh3q]

Dude, if you want people to help you out, this is the wrong way to go about it. And yes, I understand that a 30 degree angle is a 30 degree angle no matter which way it's facing. If I misunderstood your problem, it's only because you're withholding information that is relevant in helping you.

Which I now no longer care to do. Good luck.

Edit:

[quote="Cheez":2rq3sh3q]Hey, I think I'm perfectly justified in saying that.[/quote:2rq3sh3q]

No, you're just being a dick. Try explaining yourself instead of jumping to insults. I assumed you meant you wanted to calculate your sprite animation angle based on the three points, and that's the problem you were having. When I said "real angles" I assumed you understood that Construct's angles were fixed coordinates. What you want is to calculate the relative angle and translate that to Construct's fixed angle.

And again, good luck with that.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Mon Aug 11, 2008 6:47 pm

Wooeeeeeeeoooooooeeeeoooooooo flamewar alert!

Cheez, you were not justified in your aggressive tone. These people are kind enough to type up replies with suggestions trying to help you, so you don't need to go biting the hand that feeds. If you disagree, my forum, my rules. And deadeye, there was no need to come back with counterinsults. That will only make things worse.

Politeness, guys. It's really simple.

Anyways, lock on this one (Cheez said they would attempt it by hand).
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Wed Aug 27, 2008 4:30 am

Actually faggotron was correct in his answer.

Heres a diagram explaining:



So the maths would be something like:

Set value of myangle to abs( angle(Bx,By,Ax,Ay)-angle(Bx,By,Cx,Cy) )
If myangle > 180
----- myangle = 360 - angle


Or if you want to do it in 1 event with 2 actions:

myangle = abs( angle(Bx,By,Ax,Ay)-angle(Bx,By,Cx,Cy) )
myangle = myangle > 180 ? 360 - angle, angle
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests