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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:07:22+00:00 2026-06-13T21:07:22+00:00

Given two 2D vectors, how can you tell whether the second is to the

  • 0

Given two 2D vectors, how can you tell whether the second is to the right (clockwise) of the first, or to the left (counter-clockwise)?

For instance, in these diagram B is to the right (counter-clockwise) of A

A   B   .       .----> A
^  ¬    |\      |   
| /     | \     |  
|/      V  \    V 
.       B   A   B
  • 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-06-13T21:07:24+00:00Added an answer on June 13, 2026 at 9:07 pm

    You can achieve this using a dot product. dot(a, b) == a.x*b.x + a.y*b.y can be used to find whether vectors are perpendicular:

    var dot = a.x*b.x + a.y*b.y
    if(dot > 0)
        console.log("<90 degrees")
    else if(dot < 0)
        console.log(">90 degrees")
    else
        console.log("90 degrees")
    

    Put another way. dot > 0 tells you if a is “in front of” b.


    Assume b is on the right of a. Rotating b 90 degrees counterclockwise puts it in front of a.
    Now assume b is on the left of a. Rotating b 90 degrees counterclockwise puts it behind a.

    Therefore, the sign of dot(a, rot90CCW(b)) tells you whether b is on the right or left of a, where rot90CCW(b) == {x: -b.y, y: b.x}.

    Simplyifying:

    var dot = a.x*-b.y + a.y*b.x;
    if(dot > 0)
        console.log("b on the right of a")
    else if(dot < 0)
        console.log("b on the left of a")
    else
        console.log("b parallel/antiparallel to a")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given any two sequences/vectors of M real numbers, I can easily compute their closeness
Given two tuples of the same arity, how can I lexicographically compare them? It
The dot product of two n-dimensional vectors u=[u1,u2,...un] and v=[v1,v2,...,vn] is is given by
Given two orthogonal unit vectors, A and B, and two different orthogonal unit vectors
Given two vectors r and c that hold row and column subscripts into a
Given two data frames: C1<-c(3,4,4,4,5) C2<-c(3,7,3,4,5) C3<-c(5,6,3,7,4) DF<-data.frame(C1=C1,C2=C2,C3=C3) DF C1 C2 C3 1 3
Given two arrays, how to find the maximum element which is common to both
Given two sorted arrays of integers, a and b , and an integer c
Given two strings text1 and text2 : public SOMEUSABLERETURNTYPE Compare(string text1, string text2) {
Given two identical boost::variant instances a and b , the expression ( a ==

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.