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 163013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:29:34+00:00 2026-05-11T11:29:34+00:00

I have three vectors V1, V2, and V3. Their origin points are on the

  • 0

I have three vectors V1, V2, and V3. Their origin points are on the axes’ origin. How could I determine whether V3 is between V1 and V2 when I move around counterclockwise from V1 to V2?

alt text http://www.freeimagehosting.net/uploads/1448ea8896.jpg

It can’t be done with obtaining their angles and evaluating these kind of conditions (pseudo-code):

if angle(V3) > angle(V1) && angle(V3) < angle(V2)     printf('V3 is between V1 and V2')  else     printf('out of the interval') 

To see its defect, suppose that the angle function gives angles in the range of [-pi pi]. So, if angle(V1) = 120 (in degree), angle(V2) = -130 and angle(V3) = 150 then the answer (according to the above code) is ‘out of the interval’ although if you move around counterclockwise from V1 to V2, it is between them.

You may suggest adding 2*pi to angle(V2) or something like that, but I’ve tried such things and it doesn’t work.

I’m programming in MATLAB.

EDIT 1 : it is in 2D.

  • 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. 2026-05-11T11:29:35+00:00Added an answer on May 11, 2026 at 11:29 am

    Since you are doing this in MATLAB, here is one solution that should work:

    crossProds = [V1(1)*V2(2)-V1(2)*V2(1) ...               V1(1)*V3(2)-V1(2)*V3(1) ...               V3(1)*V2(2)-V3(2)*V2(1)]; if (all(crossProds >= 0) || ...     (crossProds(1) < 0) && ~all(crossProds(2:3) < 0)),   disp('V3 is between V1 and V2'); else   disp('out of the interval'); end 

    EXPLANATION:

    The cross product between the 2-D vectors V1 and V2 is stored in the first element of crossProds. This value will be greater than or equal to zero if the counter-clockwise angle between V1 and V2 is between 0 and 180 degrees, inclusive. In this case, when V3 is between V1 and V2 in the counter-clockwise direction then the cross products (V1,V3) and (V3,V2) are also greater than or equal to zero. This explains the first logical check:

    all(crossProds >= 0) 

    If the counter-clockwise angle between V1 and V2 is greater than 180 degrees, then the cross product of these two vectors will be less than zero. In this case, when V3 is between V1 and V2 in the clockwise direction then the cross products (V1,V3) and (V3,V2) are also less than zero. Therefore, if these cross products are not both less than zero then V3 must be between V1 and V2 in the counter-clockwise direction. This explains the next two logical checks:

    (crossProds(1) < 0) && ~all(crossProds(2:3) < 0) 

    The above logical checks should cover all possible situations. The operators || and && are short circuit operators in MATLAB: they will skip the second statements if they are not necessary. For example, if the first statement in an OR is true, there is no reason to check the second statement since only one argument in an OR needs to be true for the result to be true.

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

Sidebar

Ask A Question

Stats

  • Questions 83k
  • Answers 83k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First read this article by Joel Spolsky: The Absolute Minimum… May 11, 2026 at 4:51 pm
  • Editorial Team
    Editorial Team added an answer Before investing too much time into designing a hierarchical data… May 11, 2026 at 4:51 pm
  • Editorial Team
    Editorial Team added an answer If you want a minimalistic file structure, you could just… May 11, 2026 at 4:51 pm

Related Questions

From wikipedia: the cross product is a binary operation on two vectors in a
I'd like to know some best practice when designing c++ classes. To put it
Forgive me, for I am fairly new to C++, but I am having some
template <class T> bool BST<T>::search(const T& x, int& len) const { return search(BT<T>::root, x);

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.