Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Projecting a point

edited March 2012 in Questions Posts: 2,820

Something I've really wanted to do for a while is be able to project a point in a direction. Basically, you say projectPoint(x,y,angle, distance). I understand that means knowing how to use sin and cosin and know triginometry, so I can't figure out the formula (because I'm only in middle school). If someone could help me, that would be great.


  • edited March 2012 Posts: 622

    How do x,y and angle relate?

    Are you wanting to start at x,y and go in the direction of the angle? If so then, how far?

    Are you looking to draw a dot there or a line?

  • Posts: 2,820

    Sorry. I forgot to add the parameter distance. So I was thinking of using triangles. So we know the hypotenuse and all the angles (if we subtract the angle and 90 from 180). I may just be clueless.

  • Posts: 2,161

    I presume that you are in 2D, that you are starting at (x,y) and moving in the direction specified by angle for a distance of distance. If this is correct, the formula is:

    X = x + distance * math.cos(angle)
    Y = y + distance * math.sin(angle)

    You need to make sure that your angles are in radians.

  • Posts: 2,820

    Alright. Thanks. My plan is also to use it in 3D eventually too though, so I'll see. Thanks!

Sign In or Register to comment.