5 kyu

[Geometry A-1] Locate point - to the right, to the left or on the vector?

447 of 686MMMAAANNN

Description:

Task

Your task is to determine the relationship between the given point and the vector. Direction of the vector is important! To determine if the point is to the left or to the right, you should imagine yourself standing at the beginning of the vector and looking at the end of the vector.

Arguments

You are given coordinates of a point and coordinates of a vector on 2D plane:

point = [x, y]

vector = [[x, y], [x, y]] (two points, direction is from first to second)

Vectors always have non-zero length, so you don't have to check for that at this point.

Return

Your function must return:

-1 if the point is to the left of the vector,

0 if the point is on the same line as vector,

1 if the point is to the right of the vector.

Do not repeat yourself!

You can consider re-using solution of this kata in some of the next Geometry katas:

Geometry
Algorithms

Stats:

CreatedMay 8, 2015
PublishedMay 8, 2015
Warriors Trained2146
Total Skips434
Total Code Submissions8860
Total Times Completed686
Python Completions447
JavaScript Completions202
Ruby Completions71
CoffeeScript Completions15
COBOL Completions9
Total Stars69
% of votes with a positive feedback rating93% of 127
Total "Very Satisfied" Votes111
Total "Somewhat Satisfied" Votes13
Total "Not Satisfied" Votes3
Ad
Contributors
  • MMMAAANNN Avatar
  • jhoffner Avatar
  • ZozoFouchtra Avatar
  • GiacomoSorbi Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • akar-0 Avatar
  • Just4FunCoder Avatar
Ad