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 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

I need to calculate the distance between two points, but not in the regular
I have two points (a line segment) and a rectangle. I would like to
I have an image with two points, aligned something like this: |----------------| | |
I have two questions: 1) How can I make an array which points to
Let's say you have a two dimensional plane with 2 points (called a and
I have two identical tables and need to copy rows from table to another.
I have got two WGS84 coordinates, latitude and longitude in degrees. These points are
I need to calculate the overlap (amount or yes/no) that two rectangles make on
I need to paint the line which links two points. I am doing it,
I have two webservices that have exactly the same methods and signatures but point

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.