Angle between 3 points

This forum is currently in read-only mode.
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • 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.

  • 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)

  • 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.

  • 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.

    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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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.

    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:

    Hey, I think I'm perfectly justified in saying that.

    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.

  • 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).

  • Actually faggotron was correct in his answer.

    Heres a diagram explaining:

    <img src="http://img507.imageshack.us/img507/6259/itworksca1.png">

    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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)