Determine if a point/ball is above a line

This post is the second installment from my previous post (How to detect a collision between a circle and a line).  In this post I will show how to determine if a circle or point is above a line. If you know anything about a dot product of two vectors then you probably could come up with the ‘if’ statement yourself. Without going in to too deep of details about dot products, it is basically means if two vectors point the same direction then their dot product will be greater then zero.


Here is the code:

boolean overLine(pt C, pt A, pt B){
  vec AC = new vec(A, C);
  vec AB = new vec(A,B);
  vec BC = new vec (B,C);
  vec BA = new vec (B, A);
  if ((dot(AC,AB) > 0 )  && (dot(BP,BA) > 0) ) return true;
  return false;

// dot product code
float dot(vec U, vec V) {
  return U.x*V.x+U.y*V.y;

Here is a crude drawing I made for what is happening:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Graveyard Database Logo

Has everything you want to know about grave yards. Plus has many celebrites and world leaders graves. Pssst it is my other site

Google + Profile
Check out Android Photo Mapping, its a app/site I been working on
Fabulou wholesale Petr Mrazek jersey is back. Best choice to get the wholesale Petr Mrazek jersey is suitable for all style of people.