Exemplo n.º 1
0
        //////////////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)
            });
        }
Exemplo n.º 2
0
        /// <returns>If the line intersects the oval</returns>
        public bool isIntersects(GlLineR2 L)
        {
            if (L == null || L.isNullLine())
            {
                return(false);
            }

            GlVectorR2 LV = L.DirectVector.getRotatedVector(this.SIN, this.COS);

            return(Math.Pow(this.RadA * LV.deltaY, 2.0) + Math.Pow(this.RadB * LV.deltaX, 2.0) != 0);
        }
Exemplo n.º 3
0
 public static bool Equals(GlLineR2 L1, GlLineR2 L2)
 {
     return((L1 == null || L2 == null || L1.isNullLine() || L2.isNullLine()) ? false : GlVectorR2.isParallel(L1.DirectVector, L2.DirectVector) && GlVectorR2.isParallel(L1.DirectVector, new GlVectorR2(L2.pointOfLine.X - L1.pointOfLine.X, L2.pointOfLine.Y - L1.pointOfLine.Y)));
 }