public static Point2d[] HyperbolaHyperbola(Hyperbola2d hyp1, Hyperbola2d hyp2) { Transform2d tr = hyp1.ToStandardPosition; hyp2 = new Hyperbola2d(hyp2); //copy for modification hyp2.Transform(tr); Point2dSet res = StdHyperbolaConic(hyp1.Ratio, hyp2); res.InverseTransform(tr); return(res.ToArray()); }
public static Point2d[] ParabolaHyperbola(Parabola2d pab, Hyperbola2d hyp) //tested ok { Transform2d tr = pab.ToStandardPosition; //y=x^2 hyp = new Hyperbola2d(hyp); //copy for transformation hyp.Transform(tr); //to standard space of parabola for stabillity GeneralConic2d gencon = hyp.ToGeneralConic(); var ptset = StandardPosParabolaGeneralConic(gencon); ptset.Transform(tr.Inversed); return(ptset.ToArray()); }
public static Point2d[] HyperbolaEllipse(Hyperbola2d hyp, Ellipse2d elp) { //TODO: this is probably more stable intersecting hyperbola with unitcircle. Rewrite. Transform2d tr = hyp.ToStandardPosition; hyp = new Hyperbola2d(hyp); elp = new Ellipse2d(elp); hyp.Transform(tr); elp.Transform(tr); GeneralConic2d hcon = new GeneralConic2d(1, 0.0, -1 / (hyp.B * hyp.B), 0.0, 0.0, -1); Point2dSet pset = new Point2dSet(); pset.AddRange(ConicConic(hcon, elp.ToGeneralConic())); pset.Transform(tr.Inversed); return(pset.ToArray()); }
public static Circle2d[] CirclePointPoint(Circle2d ci, Point2d pt1, Point2d pt2) { // Solution by Robert.P. 2013-02-10 // solved by intersecting the line which has equal distance to pt1 and pt2 at every point, // with the hyperbola that has equal distance to ci and pt1 at every point. List <Circle2d> res = null; //get squared constants of hyperbola double c2 = ci.Center.SquaredDistance(pt1) / 4.0; //center->focus distance squared double a = 0.5 * ci.Radius; double b = Math.Sqrt(c2 - a * a); if (double.IsNaN(b)) { return(null); //negative square root, no such hyperbola } // this hyperbola has equal distance to ci and pt1 at every point. // it also has focus at ci.Center and pt1 Hyperbola2d hyper = new Hyperbola2d(new Point2d((ci.X + pt1.X) * 0.5, (ci.Y + pt1.Y) * 0.5), a, b, ci.Center.Angle(pt1)); //get constants of line dx+ey+f=0, which is equal distance from p1,p2 on every point double dx = pt2.X - pt1.X, dy = pt2.Y - pt1.Y; double mx = pt1.X + dx * 0.5; double my = pt1.Y + dy * 0.5; Line2d perp = new Line2d(mx, my, mx - dy, my + dx); //starts from mipoint pt1-pt2 and is perpendicular to that line var intpts = Intersect2d.HyperbolaLine(hyper, perp); if (intpts == null) { return(null); } foreach (Point2d intpt in intpts) { AddResult(ref res, intpt.X, intpt.Y, intpt.Distance(pt1)); } return(MakeResult(res)); }
public override bool Transform(Transform2d t) { //transform hyperbola centered at origin, because it's more stable general conic Hyperbola2d hyp = new Hyperbola2d(this); hyp.center = Point2d.Origo; var gencon = hyp.ToGeneralConic(); if (!gencon.Transform(new Transform2d(t.AX, t.AY, t.BX, t.BY, 0.0, 0.0))) { return(false); } hyp = gencon.Reduce() as Hyperbola2d; if (hyp == null) { return(false); } //now transform centerpoint separately, //and write bac to this center = center.GetTransformed(t); ratio = hyp.ratio; majoraxis = hyp.majoraxis; return(true); /* double majax = majoraxis.Length; * double minax = -majax * ratio; * double rot = Rotation; * bool reverse; * Hyperbola_Transform(ref majax, ref minax, ref rot, ref center, t, out reverse); * * majoraxis = Vector2d.FromAngleAndLength(rot, majax); * ratio = minax / majax; * * return true;*/ }
public static double[] HyperbolaLineParametric(Hyperbola2d hyp, Line2d lin) { // Computes intersection points with a hyperbola and a line // solved and created by Robert.P. 2013-02-11 // // solution is created by transforming system to hyperbola standard position, // and then solving the system x^2/a^2-y^2/b^2-1=0 , x=x0+t*dx and y=y0+t*dy (note that a is 1 in std. pos.) Transform2d tr = hyp.ToStandardPosition; //extract standard spaced line double x0, y0, x1, y1, dx, dy, b = hyp.Ratio; tr.Apply(lin.X1, lin.Y1, out x0, out y0, true); tr.Apply(lin.X2, lin.Y2, out x1, out y1, true); dx = x1 - x0; dy = y1 - y0; double t2 = -dy * dy + b * b * dx * dx; double t1 = -2 * dy * y0 + 2 * b * b * dx * x0; double t0 = -y0 * y0 + b * b * x0 * x0 - b * b; return(RealPolynomial.SolveQuadric(t2, t1, t0, 0.0)); }
public static Point2d[] HyperbolaRay(Hyperbola2d hyp, Line2d ray) { return(LineParamsToPoints(HyperbolaLineParametric(hyp, ray), ray, seg_minparam, double.PositiveInfinity)); }
public static Point2d[] HyperbolaLine(Hyperbola2d hyp, Line2d lin) { return(LineParamsToPoints(HyperbolaLineParametric(hyp, lin), lin, double.NegativeInfinity, double.PositiveInfinity)); }
public static Point2d[] HyperbolaSeg(Hyperbola2d hyp, Line2d seg) { return(LineParamsToPoints(HyperbolaLineParametric(hyp, seg), seg, seg_minparam, seg_maxparam)); }
public Hyperbola2d(Hyperbola2d tocopy) { center = tocopy.center; majoraxis = tocopy.majoraxis; ratio = tocopy.Ratio; }