Jump to content

Finding angle of a line in a picture?

- - - - -

  • Please log in to reply
3 replies to this topic

#1
MPQC

MPQC

    Newbie

  • Members
  • Pip
  • 2 posts
Okay.. Basically what I'm trying to do is detect the angle of a line within a circle. So basically, I have a circle of a fixed radius of 7 (so it'll be 15x15 from side to side.) A line branches out from the center of the circle, in any direction, and I want to be able to find it, but I'm really not sure where I should start. Could I have a tip?

Quick Edit: Basically I want to extend the line of the circle further away from the circle, which is why I want to find the angle. If I don't need the angle because of a quick and dirty idea, that would be great too. :p

#2
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 763 posts
You should start by finding out the second point where the line will cross (as the first is the center of the circle). Without this information we could never calculate the angle of the line.

#3
Kellogs kittens

Kellogs kittens

    Newbie

  • Members
  • Pip
  • 4 posts
yep, you'll definately need to know the second point of this line. Once you know the second point, then you could form a triangle from what is coming out of the circle, the second line will be horizontal, and will be approaching from the circle origin too, and will stop where the initial line does (on the x axis). This new line would be x length long, and have no y length (it would pretty much be a measurement of the x direction of the initial line).

Another line can then be drawn, that would emerge from the other end of the SECOND line (so not the end that is touching the origin), this line will be vertical and would pretty much fill the gap between the initial line and the second line. This line would be length y (it would be a measurement of the y direction of the initial line).

This would leave us with a right angled triangle, so you can use trigonometry (soh cah toa) to find the angle.

this might sound a lil confusing, and if you don't understand the maths part of using trigonometry with right angled triangles, it should be fairly easy to take a quick look on the internet to make sense of it all. Just type into google, "right angled triangles finding angles". I think the top link is the clearest one to click.

Anyway, that's the maths part behind your problem but... saying all that... I'm sure there must be some dirty trick to use that's a lot simpler than following all of the above o_O

#4
MPQC

MPQC

    Newbie

  • Members
  • Pip
  • 2 posts
Ah, makes perfect sense! Thanks very much.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users