Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

If I have two coordinates for a line, the begining and the end,

how do I find what angle the line is pointing relative to the begining of the

line?

 

I need this for a upcoming project where I need to move the camera in

a 2D world and it has to follow a line thus I need to know the angle which

the camera needs to move at.

 

Thanks!

Posted
If I have two coordinates for a line, the begining and the end,

how do I find what angle the line is pointing relative to the begining of the

line?

 

I need this for a upcoming project where I need to move the camera in

a 2D world and it has to follow a line thus I need to know the angle which

the camera needs to move at.

 

Thanks!

tan θ = (Y2-Y1) / (X2-X1)

θ = arctan((Y2-Y1) / (X2-X1))

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted
I think I might be able to work with that weird looking

formula but do you have any code by any chance?

Oh it is sad that simple trigonometry is 'weird'

 

 

look up Math.Atan

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted
Dim lineAngle as Single = tan(arc((Y2-Y1) / (X2-X1)))

 

Is that correct?

nope. . .

 

Dim lineAngle as Double = Math.Atan((Y2-Y1) / (X2-X1))

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted
NOTE THAT ATAN IS A DOUBLE!!!!

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted

or

Dim lineAngle as Double = Math.Atan2(Y2-Y1,X2-X1)

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted
look up Math.ATan - complete example

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...