public bool IntersecteazaSegment(Linie linie) { if ((Start.Y < linie.Start.Y && Start.Y < linie.End.Y) || (Start.Y > linie.Start.Y && Start.Y > linie.End.Y)) { return(false); } return(true); }
private bool PunctInInteriorulObiectului(Point punct, Obiect obiect, int x) { var linie = new Linie(punct, new Point(x, punct.Y)); var count = 0; foreach (var linieObiect in obiect.LiniiPerimetru) { if (linie.IntersecteazaSegment(linieObiect)) { count++; } } if (count % 2 == 1) { return(true); } else { return(false); } }
public bool IntersecteazaLinie(Linie otherLine, out Point intersectionPoint) { intersectionPoint = new Point(0, 0); if (IsVertical && otherLine.IsVertical) { return(false); } //if (IsVertical || otherLine.IsVertical) //{ // intersectionPoint = GetIntersectionPointIfOneIsVertical(otherLine, this); // return true; //} double delta = A * otherLine.B - otherLine.A * B; bool hasIntersection = Math.Abs(delta - 0) > 0.0001f; if (hasIntersection) { double x = (otherLine.B * C - B * otherLine.C) / delta; double y = (A * otherLine.C - otherLine.A * C) / delta; intersectionPoint = new Point((int)x, (int)y); } return(hasIntersection); }
public Linie(Linie l) { Start = new Point(l.Start.X, l.Start.Y); End = new Point(l.End.X, l.End.Y); }