Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the game I'm designing there is a blast that shoots out from an origin point towards the direction of the mouse. The width of this blast is always going to be the same.

Along the bottom of the screen (what's currently) squares move about which should be effected by the blast that the player controls.

Currently I am trying to work out a way to discover if the corners of these squares are within the blast's two bounding lines. I thought the best way to do this would be to rotate the corners of the square around an origin point as if the blast were completely horizontal and see if the Y values of the corners were less than or equal to the width of the blast which would mean that they lie within the effected region, but I can't work out

share|improve this question
up vote 11 down vote accepted

The point is between the 2 parallel lines if it's one side of one line and the other side of the other line (providing the lines point in the same direction).

You can use the top answer from this question at stackoverflow to work out which side of a line (defined by 2 points on it) a point lies on.

An alternative method would be to calculate the distance from point to a middle line and comparing that to half the thickness of your blast.

share|improve this answer

This is how I do it (with an additional check whether or not the planes provided are actually parallel. The Plane objects contain the plane equation in this form: Ax + By + Cz + D = 0, which you can easily generate from 3 given points, or from a point and a normal (see this page if you're unsure about the math:

bool isPointBetweenParallelPlanes(const vec3 point, const Plane a, const Plane b){
// test if planes are parallel
vec3 cross = a.normal CROSS b.normal;
assert((a.normal CROSS b.normal) == vec3(0,0,0) && "These planes should be parallel.");
return ((a.normal DOT point) + a.D) * ((b.normal DOT point) + b.D) < 0.0;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.