//////////////TRANSFORM_METHODS//////////////// /////////////////////////////////////////////// /////////////INTERSECTION_METHODS////////////// public override GlPointR2[] getIntersection(GlLineR2 L) { if (L == null || this.isNullParabola() || L.isNullLine()) { return new GlPointR2[] { } } ; GlParabola PC = new GlParabola(this.A, new GlPointR2(0, 0), new GlVectorR2(1, 0)); GlPointR2 LP0 = L.PointOfLine.getPointTranslatedToRotatedSystem(this.SIN, this.COS, this.Vertex); GlPointR2 LP1 = L.DirectVector.getRotatedVector(this.SIN, this.COS).fromPointToPoint(LP0); float fPartRes = LP0.Y - LP1.Y; float sPartRes = (float)Math.Sqrt(4 * PC.A * (LP0.X - LP1.X) * (LP0.X * LP1.Y - LP1.X * LP0.Y + PC.C * (LP1.X - LP0.X)) + (float)Math.Pow(PC.B * (LP0.X - LP1.X) - LP0.Y + LP1.Y, 2.0)); float tPartRes = PC.B * (LP1.X - LP0.X); float devider = 2 * PC.A * (LP0.X - LP1.X); float x1 = (fPartRes + sPartRes + tPartRes) / devider; float x2 = (fPartRes - sPartRes + tPartRes) / devider; float y1 = PC.A * x1 * x1 + PC.B * x1 + PC.C; float y2 = PC.A * x2 * x2 + PC.B * x2 + PC.C; return(new GlPointR2[] { new GlPointR2(x1, y1).getTranslatedBackPoint(this.SIN, this.COS, this.Vertex), new GlPointR2(x2, y2).getTranslatedBackPoint(this.SIN, this.COS, this.Vertex) }); }
public override bool isPointBelongs(GlPointR2 P) { if (P == null || P.isNullPoint()) { return(false); } GlPointR2 RP = P.getPointTranslatedToRotatedSystem(this.SIN, this.COS, this.Vertex); GlParabola RPB = new GlParabola(this.A, new GlPointR2(0, 0), new GlVectorR2(1, 0)); return(Math.Abs(RP.Y - RPB.A * RP.X * RP.X - RPB.B * RP.X - RPB.C) < FAULT); }
/////////////INTERSECTION_METHODS////////////// /////////////////////////////////////////////// ////////////////TANGENT_METHODS//////////////// public override GlLineR2 getTangentFromBelongs(GlPointR2 P) { if (P == null || P.isNullPoint()) { return(new GlLineR2(new GlPointR2(null), new GlVectorR2(null))); } GlParabola TPB = new GlParabola(this.A, new GlPointR2(0, 0), new GlVectorR2(1, 0)); GlPointR2 TP = P.getPointTranslatedToRotatedSystem(this.SIN, this.COS, this.Vertex); float k = 2 * TPB.A * TP.X + TPB.B; GlLineR2 tangent = new GlLineR2(P, new GlVectorR2(1, 0).getRotatedVector((float)Math.Atan(k))); tangent.Rotate(this.SIN, this.COS); return(tangent); }
public GlParabola(GlParabola copyParabola) : this(copyParabola == null ? 0 : copyParabola.A, copyParabola == null ? new GlPointR2(float.NaN, float.NaN) : copyParabola.systemCenter, copyParabola == null ? new GlVectorR2(0, 0) : copyParabola.directVector) { }
/////////////INSIDE_BELONGS_METHODS//////////// /////////////////////////////////////////////// ///////////////ADDITIONAL_METHODS////////////// public override float getFDiff(float X) { GlParabola PB = new GlParabola(a, new GlPointR2(0, 0), new GlVectorR2(1, 0)); return(2 * PB.A * X + PB.B); }