2023-07-04 08:17 AM - last edited on 2023-07-10 09:33 PM by Laszlo Nagy
I want to get the intersection of intersecting walls.
Is there a sample file?
Should I solve it with a code I can find on Google?
ex)
bool IntersectionLine(Vector2 A1, Vector2 A2, Vector2 B1, Vector2 B2, Vector2 & result) {
double t;
double s;
double under = (B2.y - B1.y)*(A2.x - A1.x) - (B2.x - B1.x)*(A2.y - A1.y);
if (under == 0) return false;
double _t = (B2.x - B1.x)*(A1.y - B1.y) - (B2.y - B1.y)*(A1.x - B1.x);
double _s = (A2.x - A1.x)*(A1.y - B1.y) - (A2.y - A1.y)*(A1.x - B1.x);
t = _t / under;
s = _s / under;
if (t<0.0 || t>1.0 || s<0.0 || s>1.0) return false;
if (_t == 0 && _s == 0) return false;
result.x = (int)(A1.x + t * (double)(A2.x - A1.x));
result.y = (int)(A1.y + t * (double)(A2.y - A1.y));
return true;
}
Solved! Go to Solution.
2023-07-04 01:24 PM - edited 2023-07-04 01:25 PM
I changed this code to place windows at intersections. So you don't have to answer this.
I want to have permission to delete unanswered questions. ^^
2023-07-04 01:24 PM - edited 2023-07-04 01:25 PM
I changed this code to place windows at intersections. So you don't have to answer this.
I want to have permission to delete unanswered questions. ^^