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


2 Answers 2


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.


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: http://paulbourke.net/geometry/pointlineplane/)

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;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .