public double GetCentreToBoundaryDistance(ILinearEquation line) { if (HorizontalRadius <= VerticalRadius) { return HorizontalRadius; } return VerticalRadius; }
public double GetCentreToBoundaryDistance(ILinearEquation line) { if (HorizontalRadius <= VerticalRadius) { return(HorizontalRadius); } return(VerticalRadius); }
public double GetCentreToBoundaryDistance(ILinearEquation line) { var relativeOrigin = new Point(0, 0); var relativeBoundaryIntersection = GetRelativeIntersectionPoint(line); double distanceToBoundary = relativeOrigin.Distance(relativeBoundaryIntersection); return distanceToBoundary; }
public double GetCentreToBoundaryDistance(ILinearEquation line) { var relativeOrigin = new Point(0, 0); var relativeBoundaryIntersection = GetRelativeIntersectionPoint(line); double distanceToBoundary = relativeOrigin.Distance(relativeBoundaryIntersection); return(distanceToBoundary); }
public Solver() { //DEZ = new DiscriminantEqualZeroLibraryCapitalLetters(); //DGTZ = new DiscriminantGreaterThanZeroCapitalLetters(); //DLTZ = new DiscriminantLessThanZeroCapitalLetters(); //LE = new LinearEquationCapitalLetters(); DEZ = new DiscriminantEqualZero(); DGTZ = new DiscriminantGreaterThanZero(); DLTZ = new DiscriminantLessThanZero(); LE = new LinearEquation(); }
public Point[] FindIntersections(ILinearEquation line) { double xOffset; double antiXOffset; double yOffset; double antiYOffset; if (line.Gradient.Equals(0)) { xOffset = HorizontalRadius; antiXOffset = HorizontalRadius * -1; yOffset = 0.0; antiYOffset = 0.0; } else if (double.IsInfinity(line.Gradient)) { xOffset = 0.0; antiXOffset = 0.0; yOffset = VerticalRadius; antiYOffset = VerticalRadius * -1; } else { double hSquared = HorizontalRadius * HorizontalRadius; double vSquared = VerticalRadius * VerticalRadius; double gSquared = line.Gradient * line.Gradient; xOffset = Math.Sqrt((hSquared * vSquared) / (hSquared * gSquared + vSquared)); antiXOffset = xOffset * -1; yOffset = line.Gradient * xOffset; antiYOffset = line.Gradient * antiXOffset; } double x = Centre.X + xOffset; double y = Centre.Y + yOffset; double antiX = Centre.X + antiXOffset; double antiY = Centre.Y + antiYOffset; var intersections = new Point[2]; intersections[0] = new Point(x, y); intersections[1] = new Point(antiX, antiY); return(intersections); }
public Point[] FindIntersections(ILinearEquation line) { double xOffset; double antiXOffset; double yOffset; double antiYOffset; if (line.Gradient.Equals(0)) { xOffset = HorizontalRadius; antiXOffset = HorizontalRadius * -1; yOffset = 0.0; antiYOffset = 0.0; } else if (double.IsInfinity(line.Gradient)) { xOffset = 0.0; antiXOffset = 0.0; yOffset = VerticalRadius; antiYOffset = VerticalRadius * -1; } else { double hSquared = HorizontalRadius * HorizontalRadius; double vSquared = VerticalRadius * VerticalRadius; double gSquared = line.Gradient * line.Gradient; xOffset = Math.Sqrt((hSquared * vSquared) / (hSquared * gSquared + vSquared)); antiXOffset = xOffset * -1; yOffset = line.Gradient * xOffset; antiYOffset = line.Gradient * antiXOffset; } double x = Centre.X + xOffset; double y = Centre.Y + yOffset; double antiX = Centre.X + antiXOffset; double antiY = Centre.Y + antiYOffset; var intersections = new Point[2]; intersections[0] = new Point(x, y); intersections[1] = new Point(antiX, antiY); return intersections; }
private Point GetRelativeIntersectionPoint(ILinearEquation line) { double yValueOnXAxisBoundary = line.Gradient * HalfWidth; double xValueOnYAxisBoundary = HalfHeight / line.Gradient; var intersection = new Point(); if (Math.Abs(yValueOnXAxisBoundary) <= HalfHeight) { // This line intersects with the x-axis boundary. intersection.X = HalfWidth; intersection.Y = yValueOnXAxisBoundary; } else { // This line intersects with the y-axis boundary. intersection.X = xValueOnYAxisBoundary; intersection.Y = HalfHeight; } return intersection; }
public Point[] FindIntersections(ILinearEquation line) { var boundaryIntersectionOffset = new Point(); var antiBoundaryIntersectionOffset = new Point(); if (line.Gradient == 0) { boundaryIntersectionOffset.X = HalfWidth; antiBoundaryIntersectionOffset.X = HalfWidth * -1; boundaryIntersectionOffset.Y = 0.0; antiBoundaryIntersectionOffset.Y = 0.0; } else if (double.IsInfinity(line.Gradient)) { boundaryIntersectionOffset.X = 0.0; antiBoundaryIntersectionOffset.X = 0.0; boundaryIntersectionOffset.Y = HalfHeight; antiBoundaryIntersectionOffset.Y = HalfHeight * -1; } else { boundaryIntersectionOffset = GetRelativeIntersectionPoint(line); antiBoundaryIntersectionOffset.X = boundaryIntersectionOffset.X * -1; antiBoundaryIntersectionOffset.Y = boundaryIntersectionOffset.Y * -1; } var boundaryIntersection = Centre.Add(boundaryIntersectionOffset); var antiBoundaryIntersection = Centre.Add(antiBoundaryIntersectionOffset); var intersections = new Point[2]; intersections[0] = boundaryIntersection; intersections[1] = antiBoundaryIntersection; return(intersections); }
private Point GetRelativeIntersectionPoint(ILinearEquation line) { double yValueOnXAxisBoundary = line.Gradient * HalfWidth; double xValueOnYAxisBoundary = HalfHeight / line.Gradient; var intersection = new Point(); if (Math.Abs(yValueOnXAxisBoundary) <= HalfHeight) { // This line intersects with the x-axis boundary. intersection.X = HalfWidth; intersection.Y = yValueOnXAxisBoundary; } else { // This line intersects with the y-axis boundary. intersection.X = xValueOnYAxisBoundary; intersection.Y = HalfHeight; } return(intersection); }
public Point[] FindIntersections(ILinearEquation line) { var boundaryIntersectionOffset = new Point(); var antiBoundaryIntersectionOffset = new Point(); if (line.Gradient == 0) { boundaryIntersectionOffset.X = HalfWidth; antiBoundaryIntersectionOffset.X = HalfWidth * -1; boundaryIntersectionOffset.Y = 0.0; antiBoundaryIntersectionOffset.Y = 0.0; } else if (double.IsInfinity(line.Gradient)) { boundaryIntersectionOffset.X = 0.0; antiBoundaryIntersectionOffset.X = 0.0; boundaryIntersectionOffset.Y = HalfHeight; antiBoundaryIntersectionOffset.Y = HalfHeight * -1; } else { boundaryIntersectionOffset = GetRelativeIntersectionPoint(line); antiBoundaryIntersectionOffset.X = boundaryIntersectionOffset.X * -1; antiBoundaryIntersectionOffset.Y = boundaryIntersectionOffset.Y * -1; } var boundaryIntersection = Centre.Add(boundaryIntersectionOffset); var antiBoundaryIntersection = Centre.Add(antiBoundaryIntersectionOffset); var intersections = new Point[2]; intersections[0] = boundaryIntersection; intersections[1] = antiBoundaryIntersection; return intersections; }