Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7673145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:26:40+00:00 2026-05-31T16:26:40+00:00

I have two points in a cathesian 2D system, both give me the start

  • 0

I have two points in a cathesian 2D system, both give me the start and end point of a vector. Now i need the angle between the new vector and the x-axis.

I know that gradient = (y2-y1) / (x2-x1) and i know that angle = arctan(gradient).

But i dont know if this works for every case (direction) the vector takes.
When do i need to add 180 degrees or something like that.

can anyone provide me with some c / java like code or hints for all the cases.

Thx and best regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:26:41+00:00Added an answer on May 31, 2026 at 4:26 pm

    You could use the dot product (http://en.wikipedia.org/wiki/Dot_product) but simplifying it all out, you end up just taking the arctangent of the endpoint of your vector to get the angle between it and the x axis. Atan functions usually return on the order [-pi,pi] or [-180,180], so if you’re looking to make sure it wraps correctly, you’ll need to check to see if the y-component of your vector is negative. In C, you can use atan2 instead of atan, and it’ll use the sign of each component to figure out the sign of the angle (http://www.cplusplus.com/reference/clibrary/cmath/atan2/).

    For example, if you have the vector points start=<1,2> and end=<-5,-5>, adjust it back to the origin by subtracting the start from the end, giving you <-6,-7>. So you’re looking at that point. The angle with the x-axis is atan2(y,x), atan2(-7,-6), which is -130.6.

    double x = -6;
    double y = -7;
    
    fprintf(stderr,"angle is %.2f\n",atan2(y,x)*180/3.14159);
    

    angle is -130.60

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two points, a and b . I need to calculate the angle
I have two points. Now is it possible to tell what windDirection one point
I need to get two points that have biggest distance between. The easiest method
Trying to work out distance between two points (lat & lng) I have an
lets say i have two points A & B in my 3D Space now
I have two points a and b, and a bounding box at 0,0,w,h. Both
I have two pipes that both get different data at random points. What I
I have two points having lolLat as 0,10 and 30,0 Now to draw a
Basically I have two 2D points and there is a line between them. A
I have two array of points: Point [] original; AND Point [] transformed; These

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.