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

  • SEARCH
  • Home
  • 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 3492044
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:42:38+00:00 2026-05-18T11:42:38+00:00

I have two points, a and b . I need to calculate the angle

  • 0

I have two points, a and b. I need to calculate the angle between them, so I treat them like vectors. However vector a will always be defined as [0 0 0]. Reading over the MATLAB Newsreader, “Angle between two vectors“, three solutions are provided:

x1 = 0;
y1 = 0;
z1 = 0;
x2 = 0;
y2 = 1;
z2 = 0;
a = [x1,y1,z1]; b= [x2,y2,z2];

theta = rad2deg(atan2(norm(cross(a,b)),dot(a,b)))
theta = rad2deg(acos(dot(a,b)))
theta = rad2deg(atan2(x1*y2-x2*y1,x1*x2+y1*y2)) 

However as acos has accuracy problems as theta nears zero, yet out of the three equations, only acos provides the correct solution.

Should I continue to use acos or is there a better solution?

  • 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-18T11:42:38+00:00Added an answer on May 18, 2026 at 11:42 am

    The mistake is setting a = [0 0 0]. The point of interest is centered at the origin, and to calculate the angle with respect to vector b, you need to specify the direction the point is traveling. This can by done by setting a is a unit vector.

    If the point is traveling in the “x” direction, then x1=1

    x1 = 1;
    y1 = 0;
    z1 = 0;
    x2 = 0;
    y2 = 1;
    z2 = 0;
    a = [x1,y1,z1]; b= [x2,y2,z2];
    
    theta = rad2deg(atan2(norm(cross(a,b)),dot(a,b)))
    theta = rad2deg(acos(dot(a,b)))
    theta = rad2deg(atan2(x1*y2-x2*y1,x1*x2+y1*y2))
    
    theta =
        90
    theta =
        90
    theta =
        90
    

    Problem Solved, forget to use the unit vector 😛

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

Sidebar

Related Questions

Hi I have the need to calculate the distance between two points having the
Basically I have two 2D points and there is a line between them. A
I need to calculate the distance between two points, but not in the regular
I have two vectors of values and one vector of weights, and I need
For my application I need to calculate an angle between two different lines: 1)
I have a program where I want to draw a line between two points.
I have two points A,B so they form a line AB. I'd like to
I have a need to calculate the adjacent angle of a right angle triangle
I need to calculate distance between two coordinates (lon,lat) on embedded system which doesn't
I have two vectors defining two separate points in a three-dimensional space. One is

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.