示例#1
0
文件: Line2.cs 项目: fearog/axecalc
        public Line2 perpendicular( Vec2 direction )
        {
            // return a normal vector from this line, generally pointing in the direction provided
            Vec2 normal = new Vec2( -direction.y, direction.x );

            double directionality = normal.dot( direction );
            if( directionality >= 0 )
                return new Line2( v1, v1 + normal * distance );
            else
                return new Line2( v1, v1 - normal * distance );
        }
示例#2
0
文件: Line2.cs 项目: fearog/axecalc
        public Line2 offset( double distance, Vec2 direction )
        {
            // make a normal vector
            Vec2 normal = new Vec2( -this.direction.y, this.direction.x );

            // make sure its in the same direction as the direction hint vector
            if( normal.dot( direction ) < 0.0 )
                normal = normal * -1;

            // now create an offset line
            Vec2 offset = normal * distance;
            return new Line2( v1 + offset, v2 + offset );
        }