Skip to content

Commit

Permalink
Fix 90deg light problem (#28)
Browse files Browse the repository at this point in the history
* Fix 90deg light problem

* do more math check to fix everything
  • Loading branch information
JonathSpirit committed Oct 18, 2021
1 parent ef2830b commit c94703d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ namespace sfu{

//When the lines are parallel, we consider that there is not intersection.
float lineAngle = angle(lineAdirection, lineBdirection);
if(lineAngle < 0.001f || lineAngle > 359.999f){
if( (lineAngle < 0.001f || lineAngle > 359.999f) || ((lineAngle < 180.001f) && (lineAngle > 179.999f)) ){
return false;
}

//Math resolving, you can find more information here : https://ncase.me/sight-and-light/
if (lineAngle > 180.0f)
if ( (std::abs(lineBdirection.y) >= 0.0f) && (std::abs(lineBdirection.x) < 0.001f) || (std::abs(lineAdirection.y) < 0.001f) && (std::abs(lineAdirection.x) >= 0.0f) )
{
normB = (lineAdirection.x*(lineAorigin.y-lineBorigin.y) + lineAdirection.y*(lineBorigin.x-lineAorigin.x))/(lineBdirection.y*lineAdirection.x - lineBdirection.x*lineAdirection.y);
normA = (lineBorigin.x+lineBdirection.x*normB-lineAorigin.x)/lineAdirection.x;
Expand Down

0 comments on commit c94703d

Please sign in to comment.