public void ReCalcMe() { if (Point1 != null && Point2 != null) { if (TS_point.TS_AreDoublesEqual(Point1.Y, Point2.Y) && TS_point.TS_AreDoublesEqual(Point1.X, Point2.X)) { SlopeA = Double.NaN; InterceptB = Double.NaN; GenA = Double.NaN; GenB = Double.NaN; GenC = Double.NaN; } else if (TS_point.TS_AreDoublesEqual(Point1.X, Point2.X)) { SlopeA = Double.PositiveInfinity; InterceptB = Double.NaN; GenA = 1; GenB = 0; GenC = -Point1.X; } else { SlopeA = (Point2.Y - Point1.Y) / (Point2.X - Point1.X); InterceptB = Point2.Y - (SlopeA * Point2.X); GenA = SlopeA; GenB = -1; GenC = InterceptB; } } }
public TS_point Intersection(TS_line line2) { double a1 = SlopeA; double b1 = InterceptB; double a2 = line2.SlopeA; double b2 = line2.InterceptB; if (TS_point.TS_AreDoublesEqual(a1, a2)) { return(new TS_point(Double.NaN, Double.NaN)); } /* * double x = (b1-b2)/(a2-a1); * double y = (a2*b1 - b2*a1)/(a2-a1); * return new TS_point(x,y); */ double A1 = GenA; double A2 = line2.GenA; double B1 = GenB; double B2 = line2.GenB; double C1 = GenC; double C2 = line2.GenC; double D1 = (B2 - B1) / (A1 - A2); double D2 = (C2 - C1) / (A1 - A2); double y = -(A1 * D2 + C1) / (A1 * D1 + B1); double x = D1 * y + D2; return(new TS_point(x, y)); }
public TS_side(TS_point StartPoint, TS_point EndPoint) { this.StartPoint = StartPoint; this.EndPoint = EndPoint; Line = new TS_line(StartPoint, EndPoint); //ReCalcMe(); }
public bool IsTheSame(TS_point point2) { if (TS_AreDoublesEqual(X, point2.X) && TS_AreDoublesEqual(Y, point2.Y)) { return(true); } return(false); }
public bool IsContain(TS_point point) { if (TS_point.TS_AreDoublesEqual(GenA * point.X + GenB * point.Y + GenC, 0)) { return(true); } return(false); }
private double SlopeFactorA() { if (TS_point.TS_AreDoublesEqual(Point1.X, Point2.X)) { return(Double.NaN); } return((Point2.Y - Point1.Y) / (Point2.X - Point1.X)); }
public bool IsCrossedWith(TS_line line2) { TS_point crossPoint = Intersection(line2); if (Double.IsNaN(crossPoint.X) || Double.IsNaN(crossPoint.Y)) { return(false); } return(true); }
public bool IsCrossedWith(TS_side side2) { TS_point crossPoint = Line.Intersection(side2.Line); if (IsContain(crossPoint) && side2.IsContain(crossPoint)) { return(true); } return(false); }
public TS_point CrossedPoint(TS_line line2) { TS_point point = Line.Intersection(line2); if (IsContain(point)) { return(point); } return(new TS_point()); }
public TS_point CrossedPoint(TS_side side2) { TS_point point = Line.Intersection(side2.Line); if (IsContain(point)) { return(point); } return(new TS_point()); }
public bool IsAVertex(TS_point point) { foreach (var vertex in _Vertices) { if (AreDoublesEqual(vertex.X, point.X) && AreDoublesEqual(vertex.Y, point.Y)) { return(true); } } return(false); }
public bool IsCrossedWith(TS_line line2) { if (Line.IsCrossedWith(line2)) { TS_point crossPoint = Line.Intersection(line2); if (IsContain(crossPoint)) { return(true); } } return(false); }
private void SetSomeMatchedPoints() { if (TS_point.TS_AreDoublesEqual(GenB, 0)) { _Point1 = new TS_point(_GenC / _GenA, 0); _Point2 = new TS_point(_GenC / _GenA, 1); } else { _Point1 = new TS_point(0, GetValueOf_Yaxis(0)); _Point2 = new TS_point(1, GetValueOf_Yaxis(1)); } }
public bool IsContain(TS_point point) { double x = point.X; double y = point.Y; if (point.IsReal() && Line.IsContain(point)) { double minX1 = Math.Min(StartPoint.X, EndPoint.X); double maxX1 = Math.Max(StartPoint.X, EndPoint.X); double minY1 = Math.Min(StartPoint.Y, EndPoint.Y); double maxY1 = Math.Max(StartPoint.Y, EndPoint.Y); if (x >= minX1 && x <= maxX1 && y >= minY1 && y <= maxY1) { return(true); } return(false); } return(false); }
//public TS_materials.TS_steel_rf SteelClass { get; set; } public TS_bar(TS_point coordinates, double diameter)//, TS_materials.TS_steel_rf steel) { this.Coordinates = coordinates; Diameter = diameter; //SteelClass = steel; }
public TS_point Transform(TS_point punkt0) { return(new TS_point(X - punkt0.X, Y - punkt0.Y)); }
public bool IsPointInside(TS_point point) { if (IsAVertex(point)) { return(false); } foreach (var side in Sides) { if (side.IsContain(point)) { return(false); } } TS_line horLine = new TS_line(0, point.Y); ObservableCollectionEx <TS_point> horPoints = new ObservableCollectionEx <TS_point>(); foreach (var side in Sides) { TS_point pointX = side.CrossedPoint(horLine); if (pointX.X > point.X && !horPoints.Contains(pointX)) { horPoints.Add(pointX); } } int countH = horPoints.Count; if (countH % 2 != 0) { return(true); } TS_line vertLine = new TS_line(1, 0, -point.X); List <TS_point> vertPoints = new List <TS_point>(); foreach (var side in Sides) { TS_point pointY = side.CrossedPoint(vertLine); if (pointY.Y > point.Y && !vertPoints.Contains(pointY)) { vertPoints.Add(pointY); } } int countV = vertPoints.Count; if (countV % 2 != 0) { return(true); } TS_line horLineL = new TS_line(0, point.Y); List <TS_point> horPointsL = new List <TS_point>(); foreach (var side in Sides) { TS_point pointX = side.CrossedPoint(horLineL); if (pointX.X > point.X && !horPointsL.Contains(pointX)) { horPointsL.Add(pointX); } } int countHL = horPointsL.Count; if (countHL % 2 != 0) { return(true); } List <TS_point> vertPointsD = new List <TS_point>(); foreach (var side in Sides) { TS_point pointY = side.CrossedPoint(vertLine); if (pointY.Y > point.Y && !vertPointsD.Contains(pointY)) { vertPointsD.Add(pointY); } } int countVD = vertPointsD.Count; if (countVD % 2 != 0) { return(true); } return(false); }
public TS_line(TS_side division) { Point1 = division.StartPoint; Point2 = division.EndPoint; ReCalcMe(); }
public TS_line(TS_point pointA, TS_point pointB) { Point1 = pointA; Point2 = pointB; ReCalcMe(); }