//////////////TRANSFORM_METHODS//////////////// /////////////////////////////////////////////// /////////////INTERSECTION_METHODS////////////// public override GlPointR2[] getIntersection(GlLineR2 L) { if (L == null || L.pointOfLine.isNullPoint()) { return new GlPointR2[] { } } ; if (GlPointR2.Equals(this.pointOfLine, L.pointOfLine))//already have a result { return new GlPointR2[] { new GlPointR2(L.pointOfLine) } } ; bool isL1Point = this.DirectVector.isNullVector(); bool isL2Point = L.DirectVector.isNullVector(); if (isL1Point && isL2Point)//same points were catched in previous step { return new GlPointR2[] { } } ; if (this.DirectVector.isNullVector() && L.isPointBelongs(this.pointOfLine))//line and a point { return new GlPointR2[] { new GlPointR2(this.pointOfLine) } } ; if (L.DirectVector.isNullVector() && this.isPointBelongs(L.pointOfLine))//line and a point { return new GlPointR2[] { new GlPointR2(L.pointOfLine) } } ; if (GlLineR2.Equals(this, L))//lines are identical { return new GlPointR2[] { new GlPointR2(this.pointOfLine), new GlPointR2(L.PointOfLine) } } ; if (GlVectorR2.isParallel(this.DirectVector, L.DirectVector))//lines are parallel { return new GlPointR2[] { } } ; if (L.DirectVector.deltaX == 0)//L2 is parallel to Y axis { return new GlPointR2[] { new GlPointR2(L.pointOfLine.X, this.DirectVector.deltaY * (L.pointOfLine.X - this.pointOfLine.X) / this.DirectVector.deltaX + this.pointOfLine.Y) } } ; if (this.DirectVector.deltaY == 0)//L1 is parallel to X axis { return new GlPointR2[] { new GlPointR2(L.DirectVector.deltaX * (this.pointOfLine.Y - L.pointOfLine.Y) / L.DirectVector.deltaY + L.pointOfLine.X, this.pointOfLine.Y) } } ; float v2RatYX = L.DirectVector.deltaY / L.DirectVector.deltaX; float v1RatXY = this.DirectVector.deltaX / this.DirectVector.deltaY; float yInter = (v1RatXY * v2RatYX * this.pointOfLine.Y - v2RatYX * this.pointOfLine.X + v2RatYX * L.pointOfLine.X - L.pointOfLine.Y) / (v1RatXY * v2RatYX - 1); float xInter = v1RatXY * (yInter - this.pointOfLine.Y) + this.pointOfLine.X; return(new GlPointR2[] { new GlPointR2(xInter, yInter) });//common situation }