VrOne/Python Programming

ON-LINE REFERENCE DOCUMENTATION

CARDINAL SYSTEMS, LLC

www.cardinalsystems.net
 

 

PyVrGeom Class Reference

The VrOne/Python Geometry class includes helper coordinate geometry routines.  More...

Members


Detailed Description

The Python VrOne Geometry Class contains useful coordinate geometry routines.  The Python calls into this call use the same coordinate geometry routines used by VrOne.  This class is provided to reduce user development time by using time-tested VrOne C++ routines


Member Function Documentation

AziConv (Angle)

Converts an angle from (to) clockwise North to (from) counterclockwise from East.

Angle

 

AziNorth (x1, y1, x2, y2)

Computes North Azimuth from 2 coordinate positions.

x1

Point 1

y1

Point 1

x2

Point 2

y2

Point 2

returns

(ret)

 

ret

Azimuth clockwise from North in radians.

AziSouth (x1, y1, x2, y2)

Computes South Azimuth from 2 coordinate positions.

x1

Point 1

y1

Point 1

x2

Point 2

y2

Point 2

returns

(ret)

 

ret

Azimuth clockwise from South in radians.

AziEast (x1, y1, x2, y2)

Computes East Azimuth from 2 coordinate positions. This angle is normally used for text rotations.

x1

Point 1

y1

Point 1

x2

Point 2

y2

Point 2

returns

(ret)

 

ret

Azimuth counterclockwise from East in radians.

DeltaAng (Azi1, Azi2)

Returns the delta angle between two azimuths. Always returns the acute angle.

Azi1

Azimuths 1 to compare (radians)

Azi2

Azimuths 2 to compare (radians)

returns

(ret)

 

ret

Delta angle Example (in degrees): Azi1 = 350 Azi2 = 10 returns 20

Dist (x1, y1, x2, y2)

Computes the 2D distance between two points.

x1

Point 1

y1

Point 1

x2

Point 2

y2

Point 2

returns

(ret)

 

ret

Distance.

ZenithAng (x1, y1, z1, x2, y2, z2)

Computes zenith angle from two 3D points.

x1

Point 1

y1

Point 1

z1

Point 1

x2

Point 2

y2

Point 2

z2

Point 1

returns

(ret)

 

ret

Zenith angle (radians)

IsShorter (x1, y1, x2, y2, x3, y3, x4, y4)

Determines if line1 is shorter than line2

x1

Line 1 Point 1.

y1

Line 1 Point 1.

x2

Line 1 Point 2.

y2

Line 1 Point 2.

x3

Line 2 Point 1.

y3

Line 2 Point 1.

x4

Line 2 Point 2.

y4

Line 2 Point 2.

returns

(ret)

 

ret

0 Line1 is shorter that Line2 1 Line1 is longer than or equal to Line2

SlopeDist (x1, y1, z1, x2, y2, z2)

Computes slope distance between two 3D points.

x1

Point 1

y1

Point 1

z1

Point 1

x2

Point 2

y2

Point 2

z2

Point 2

returns

(ret)

 

ret

Slope distance

Wind (MinX, MinY, MaxX, MaxY, TestX, TestY)

 
  Returns the relationship of a point within a window
  
         |       |
     9   |   1   |   5
         |       |
  -----------------------  < MaxY
         |///////|
     8   |///0///|   4
         |///////|
  -----------------------  < MinY
         |       |
     10  |   2   |   6
         |       |
         ^       ^
      MinX       MaxX
    

MinX

Window bounds

MinY

Window bounds

MaxX

Window bounds

MaxY

Window bounds

TestX

Test point

TestY

Test point

InterY2D (X1, Y1, X2, Y2, X3, )

Interpolates the unknown Y of three points.

X1

Point 1 X.

Y1

Point 1 Y.

X2

Point 2 X.

Y2

Point 2 Y.

X3

Known X of point 3.

 

 

returns

(UnknownY)

 

UnknownY

 

InterX2D (Y3, X1, Y1, X2, Y2, )

Interpolates the unknown X of three points.

Y3

Known Y of point 3.

X1

Point 1.

Y1

Point 1.

X2

Point 2.

Y2

Point 2.

 

 

returns

(UnknownX)

 

UnknownX

 

InterXY (x1, y1, z1, x2, y2, z2, z3)

Interpolates the XY position along a line based on the elevation

x1

Point one

y1

Point one

z1

Point one

x2

Point two

y2

Point two

z2

Point two

z3

Known elevation

returns

(x3, y3)

 

x3

Return X

 

y3

Return Y

InterElev (x1, y1, z1, x2, y2, z2, x3, y3)

Interpolates the unknown elevation of three points.

x1

Point one

y1

Point one

z1

Point one

x2

Point two

y2

Point two

z2

Point two

x3

Known x of third point.

y3

Known y of third point.

returns

(z3)

 

z3

Unknown elevation of third point. If there is no distance between points one and two then Z3 returns with the elevation of Z1.

InterZ3 (x1, y1, z1, x2, y2, z2, x3, y3, z3, x, y)

Interpolates a Z from a 3D surface defined by a triangle.

x1

Point one on triangle

y1

Point one on triangle

z1

Point one on triangle

x2

Point two on triangle

y2

Point two on triangle

z2

Point two on triangle

x3

Point three on triangle

y3

Point three on triangle

z3

Point three on triangle

x

Point to interpolate Z for.

y

Point to interpolate Z for.

returns

(z)

 

z

Return elevation.

RotPoint (BaseX, BaseY, x, y, Rot)

Rotates a point about a base point.

BaseX

Base point.

BaseY

Base point.

x

Point to be rotated.

y

Point to be rotated.

Rot

Rotation clockwise in radians.

returns

(x, y)

 

x

Return point x.

 

y

Return point y.

OfsInt (LineX1, LineY1, LineX2, LineY2, PointX, PointY)

Computes the offset and distance from a point to a line.

LineX1

Point one of the line.

LineY1

Point one of the line.

LineX2

Point two of the line.

LineY2

Point two of the line.

PointX

Point

PointY

Point

returns

(Offset, Distance)

 

Offset

Resulting offset with the following conditions: Positive - Point is to the right of the line. Negative - Point is to the left of the line.

 

Distance

Resulting distance from point to line.

PntToLine1 (LineX1, LineY1, LineX2, LineY2, PointX, PointY)

Snaps a point to a line 2D.

LineX1

Point one of the line.

LineY1

Point one of the line.

LineX2

Point two of the line.

LineY2

Point two of the line.

PointX

Point to snap to line.

PointY

Point to snap to line.

returns

(ret, xr, yr, Dist)

 

ret

 
  0=Point falls between line endpoints
  1=Point falls below the line   * x---------->
  2=Point falls above the line    x---------> *

 

xr

Point x snapped to line.

 

yr

Point y snapped to line.

 

Dist

Return distance (optional) Positive - Point is to the right of the line. Negative - Point is to the left of the line.

PntToLine2 (LineX1, LineY1, LineZ1, LineX2, LineY2, LineZ2, PointX, PointY, PointZ)

Snaps a point to a line 2D but interpolates a Z.

LineX1

Point one of the line.

LineY1

Point one of the line.

LineZ1

Point to snap to line.

LineX2

Point two of the line.

LineY2

Point two of the line.

LineZ2

Point to snap to line.

PointX

Point to snap to line.

PointY

Point to snap to line.

PointZ

Point to snap to line.

returns

(ret, xr, yr, zr, Dist)

 

ret

 
  0=Point falls between line endpoints
  1=Point falls below the line   * x---------->
  2=Point falls above the line    x---------> *

 

xr

Point x snapped to line.

 

yr

Point y snapped to line.

 

zr

Interpolated z on line.

 

Dist

Return distance (optional) Positive - Point is to the right of the line. Negative - Point is to the left of the line.

PntToLine3d (LineX1, LineY1, LineZ1, LineX2, LineY2, LineZ2, xp, yp, zp)

Snaps a 3D point to a 3D line using doubles. This is a true 3D computation

LineX1

Point one of the line.

LineY1

Point one of the line.

LineZ1

Point one of the line.

LineX2

Point two of the line.

LineY2

Point two of the line.

LineZ2

Point one of the line.

xp

Point to snap to line.

yp

Point to snap to line.

zp

Point to snap to line.

returns

(ret, xr, yr, zr, Dist)

 

ret

 
  0=Point falls between line endpoints
  1=Point falls below the line   * x---------->
  2=Point falls above the line    x---------> *

 

xr

Point x snapped to line.

 

yr

Point y snapped to line.

 

zr

Point z snapped to line (interpolated).

 

Dist

Return distance from xp,yp,zp to line intersection (optional)

CanLinesCross (MinX1, MinY1, MaxX1, MaxY1, MinX2, MinY2, MaxX2, MaxY2)

Determines if it is possible for two lines to cross by checking their MBRs.

MinX1

Minimum coordinate of MBR 1.

MinY1

Minimum coordinate of MBR 1.

MaxX1

Maximum coordinate of MBR 1.

MaxY1

Maximum coordinate of MBR 1.

MinX2

Minimum coordinate of MBR 2.

MinY2

Minimum coordinate of MBR 2.

MaxX2

Maximum coordinate of MBR 2.

MaxY2

Maximum coordinate of MBR 2.

returns

(ret)

 

ret

TRUE - Lines could cross. FALSE - No way Man.

IsPointOnLine (LineX1, LineY1, LineX2, LineY2, PointX, PointY)

Determines if a point lies on a line.

LineX1

Point one of the line.

LineY1

Point one of the line.

LineX2

Point two of the line.

LineY2

Point two of the line.

PointX

Test point.

PointY

Test point.

returns

(ret)

 

ret

0 - Point is not on line. 1 - Point is on line and not between line endpoints. 2 - Point is on line between line endpoints. 3 - Point is the same as one of the endpoints.

IsLineOnLine (x1, y1, x2, y2, x3, y3, x4, y4)

 
  Determines if line2 lies on line1.
   I.e.
 
       x3y3              x4y4
   *-----*=-=-=-=-=-=-=-=-=*------*         = TRUE
  x1y1                          x2y2
 
             x3y3                x4y4
   *-------------*=-=-=-=-=-=-=-=-=*        = TRUE
  x1y1                           x2y2
 
             x3y3                x4y4
   *-------------*=-=-=-=-=-=-*====*        = FALSE 
  x1y1                      x2y2
 
             x3y3              x4y4
              *==================*
   *--------------------------------*       = FALSE 
  x1y1                             x2y2

x1

Point one of line 1.

y1

Point one of line 1.

x2

Point two of line 1.

y2

Point two of line 1.

x3

Point one of line 2.

y3

Point one of line 2.

x4

Point two of line 2.

y4

Point two of line 2.

returns

(ret)

 

ret

0 - Lines do not lie on top of each other. 1 - Lines lie on top of each other.

OfsLine (Offset, OrgX1, OrgY1, OrgX2, OrgY2)

Offsets a two point line

Offset

Distance to offset new line from original. negative - Offset to left. positive - Offset to right.

OrgX1

Point 1 of original line to be offset.

OrgY1

Point 1 of original line to be offset.

OrgX2

Point 2 of original line to be offset.

OrgY2

Point 2 of original line to be offset.

returns

(NewX1, NewY1, NewX2, NewY2)

 

NewX1

Point 1 of new line.

 

NewY1

Point 1 of new line.

 

NewX2

Point 2 of new line.

 

NewY2

Point 2 of new line.

DoLinesIntersect (Line1X1, Line1Y1, Line1X2, Line1Y2, Line2X1, Line2Y1, Line2X2, Line2Y2)

Line to line intersection.

Line1X1

Line 1 Point 1

Line1Y1

Line 1 Point 1

Line1X2

Line 1 Point 2

Line1Y2

Line 1 Point 2

Line2X1

Line 2 Point 1

Line2Y1

Line 2 Point 1

Line2X2

Line 2 point 2

Line2Y2

Line 2 point 2

returns

(ret)

 

ret

TRUE=Lines intersect,FALSE=Lines don't intersect

CanLineCrossMbr (x1, y1, x2, y2, MinX, MinY, MaxX, MaxY)

Determine if a line segment can possibly cross an MBR area.

x1

Line segment coordinates

y1

Line segment coordinates

x2

Line segment coordinates

y2

Line segment coordinates

MinX

MBR extents

MinY

MBR extents

MaxX

MBR extents

MaxY

MBR extents

LineLineInt (Line1X1, Line1Y1, Line1X2, Line1Y2, Line2X1, Line2Y1, Line2X2, Line2Y2)

Line to line intersection.

Line1X1

Line 1 Point 1

Line1Y1

Line 1 Point 1

Line1X2

Line 1 Point 2

Line1Y2

Line 1 Point 2

Line2X1

Line 2 Point 1

Line2Y1

Line 2 Point 1

Line2X2

Line 2 point 2

Line2Y2

Line 2 point 2

returns

(IntX, IntY, IntFlag)

 

IntX

Intersection point of line1 and line2

 

IntY

Intersection point of line1 and line2

 

IntFlag

 
                 A             A             A
          ------->      ------->      ------->
        |                  |                  |
        | B                | B                | B
        |                  |                  |
        V                  V                  V
 
                 12            4             6
 
 
 
        |    A             |             A    |
        | ------->      ---+--->      ------->| B
        |                  |                  |
        V                  V                  V
 
                 8             0             2
 
 
 
        |                  |                  |
        | B                | B                | B
        |                  |                  |
        V    A             V             A    V
          ------->      ------->      ------->
 
                 9             1             3
 
 
 
                 A                           A
          ------->                    ------->
                 B             AB
          ------->      ----->->         . B
 
                 15            15            15

 

            

BearBearInt (x1, y1, Azi1, x2, y2, Azi2)

Bearing - bearing intesection.

x1

Point 1

y1

Point 1

Azi1

Azimuth from point 1 in radians from North.

x2

Point 2

y2

Point 2

Azi2

Azimuth from point 2 in radians from North.

returns

(IntX, IntY, Stus)

 

IntX

Intersection point x.

 

IntY

Intersection point y.

 

Stus

Status - 0 - OK -1 Lines are parallel and no solution computed. -2 Point 1 and point 2 are the same.

DistDistInt (x1, y1, dist1, x2, y2, dist2)

Computes distance - distance intersection.

x1

Point 1

y1

Point 1

dist1

Distance 1

x2

Point 2

y2

Point 2

dist2

Distance 2

returns

(ret, IntX, IntY)

 

ret

0=Ok -1=Could not compute intersection. Points 1 and 2 are probably too far apart. Computes the solution clockwise direction from point 1 to point 2. To compute the other solution, call to routine with the points and distances reversed.

 

IntX

Intersection point.

 

IntY

Intersection point.

BearDistInt (x1, y1, Azi1, x2, y2, Dist2)

Computes bearing - distance intersection. To compute the other solution call with azi reversed distances reversed.

x1

Starting point of line

y1

Starting point of line

Azi1

Azimuth of line (Decimal radians from North).

x2

Point to test distance intersection with

y2

Point to test distance intersection with

Dist2

Distance from x2, y2

returns

(ret, IntX, IntY)

 

ret

0 if successfull, -1 if no intersection possible.

 

IntX

Intersection point X (if possible)

 

IntY

Intersection point Y (if possible)

Circ3Pt (x1, y1, x2, y2, x3, y3)

Computes the center of a circle defined by 3 points along edge.

x1

Point 1 on arc.

y1

Point 1 on arc.

x2

Point 2 on arc.

y2

Point 2 on arc.

x3

Point 3 on arc.

y3

Point 3 on arc.

returns

(ret, CenX, CenY, Rad)

 

ret

0=Ok -1=Error, do not use results.

 

CenX

Return center point of circle X.

 

CenY

Return center point of circle Y.

 

Rad

Return radius.

AngleIncr (Radius, Scale)

Returns the angle increment for drawing a smooth circular arc.

Radius

Radius of circle or arc in user units.

Scale

Draw scale in ratio form (1:n).
 
   To decrease (increase the number of points on the arc) the result,
   make 24000 larger.
 
                 ___________________________
                / radius * sqrt(2) * 24000 
               /  ------------------------
             \/           SCALE

returns

(ret)

 

ret

Angle increment for drawing a smooth circular arc

AngleB (x1, y1, xc, yc, x2, y2)

Computes angle B of a triangle from three coordinate positions.

x1

Point one. Point on arc.

y1

Point one. Point on arc.

xc

Center point at angle B.

yc

Center point at angle B.

x2

Point two. Point on arc.

y2

Point two. Point on arc.

returns

(ret)

 

ret

Angle n radians (0-PI).

AngleDeflect (x1, y1, x2, y2, x3, y3)

Computes the deflection angle from three coordinate postions.

x1

Point 1

y1

Point 1

x2

Point 2

y2

Point 2

x3

Point 3

y3

Point 3

returns

(ret)

 

ret

Angle n radians (0-PI).

AziToBear (Azi)

Converts an azimuth to a bearing and quadrant code

Azi

Azimuth to convert (decimal radians from the North)

if azi is not in the range of 0-pi radians (0-360 degrees) it will be
   forced into range.
 
   NOTE : Conversion of angles from h.ms degrees <-> decimal radians.
          azi := dec_deg(azi) / conv;   hms degrees -> dec radians
          azi := hms (azi*conv);        dec radians -> hms degrees

returns

(Bear, Quadrant)

 

Bear

Return bearing (decimal radians)

 

Quadrant

Return quadrant code (1-4). If azi is not in the range of 0-pi radians (0-360 degrees) it will be forced into range.

BearToAzi (Bear, Quad)

Converts a bearing to an azimuth

Bear

Bearing in decimal radians.

Quad

Quadrant code (1-4).

returns

(Azi)

 

Azi

Return azimuth in decimal radians from the north. If quad is out of range of 1-4 or if bear is out of the range of 0-1.5707963271 radians (0-90 degrees) then azi returns 0.0.

FmtAzi (Azi, Accur, Direction)

Formats an azimuth for display in the form ddd mm ss.s

Azi

Azimuth to be formatted (radians from the North)

Accur

Number of decimal places for seconds

Direction

0 = Return azimuth from North. 1 = Return azimuth from South.

returns

(AziStrg)

 

AziStrg

Return string

ParseDms (Dms)

Parses angle expressed in degrees minutes seconds.

Dms

Angle in the form of ddd.mmsec

returns

(Deg, Min, Sec)

 

Deg

Return degress

 

Min

Return minutes

 

Sec

Return seconds

FmtBear (Bearing, Quadrant, Accur, FmtOpt)

Formats a bearing in the form of q hh-mm-ss.tt q

Bearing

Bearing in decimal radians.

Quadrant

Quadrant code (1-4).

Accur

Decimal accuracy of seconds.

FmtOpt

Bearing format option.
     0 - N dd-mm-ss E
     1 - N dd\mm'ss"E
 
   If Bearing is out of the range of 0-pi/2 radians (0-90 degrees)
   then ? **-**-** ? is returned.
   If quad is out of the range of 1-4 then and Bearing is in range then
   ? nn-nn-nn ? is returned.

returns

(BearStrg)

 

BearStrg

Return bearing string.

DoesMbrOverlap (DstStartX, DstStartY, DstEndX, DstEndY, SrcStartX, SrcStartY, SrcEndX, SrcEndY)

Finds the overlap area of the source rectangle to the destination rectangle. Integer based.

DstStartX

Destination rectangle

DstStartY

Destination rectangle

DstEndX

Destination rectangle

DstEndY

Destination rectangle

SrcStartX

Source rectangle

SrcStartY

Source rectangle

SrcEndX

Source rectangle

SrcEndY

Source rectangle

returns

(ret)

 

ret

0 = Areas overlap, -1 = Areas don't overlap

GetOverlapArea (DstStartX, DstStartY, DstEndX, DstEndY, SrcStartX, SrcStartY, SrcEndX, SrcEndY)

Finds the overlap area of the source rectangle to the destination rectangle. Integer based.

DstStartX

Destination rectangle

DstStartY

Destination rectangle

DstEndX

Destination rectangle

DstEndY

Destination rectangle

SrcStartX

Source rectangle

SrcStartY

Source rectangle

SrcEndX

Source rectangle

SrcEndY

Source rectangle

returns

(ret, DstOverStartX, DstOverStartY, SrcOverStartX, SrcOverStartY, OverWdt, OverHgt)

 

ret

0 = Areas overlap, -1 = Areas don't overlap

 

DstOverStartX

Start of overlap area in destination rectangle

 

DstOverStartY

Start of overlap area in destination rectangle

 

SrcOverStartX

Start of overlap area in source rectangle

 

SrcOverStartY

Start of overlap area in source rectangle

 

OverWdt

Width of overlap area

 

OverHgt

Height of overlap area

GetOverlapAreaD (DstStartX, DstStartY, DstEndX, DstEndY, SrcStartX, SrcStartY, SrcEndX, SrcEndY)

Finds the overlap area of the source rectangle to the destination rectangle. Double based.

DstStartX

Destination rectangle

DstStartY

Destination rectangle

DstEndX

Destination rectangle

DstEndY

Destination rectangle

SrcStartX

Source rectangle

SrcStartY

Source rectangle

SrcEndX

Source rectangle

SrcEndY

Source rectangle

returns

(ret, DstOverStartX, DstOverStartY, SrcOverStartX, SrcOverStartY, OverWdt, OverHgt, OverlayMode)

 

ret

0 = Areas overlap, -1 = Areas don't overlap

 

DstOverStartX

Start of overlap area in destination rectangle

 

DstOverStartY

Start of overlap area in destination rectangle

 

SrcOverStartX

Start of overlap area in source rectangle

 

SrcOverStartY

Start of overlap area in source rectangle

 

OverWdt

Width of overlap area

 

OverHgt

Height of overlap area

 

OverlayMode

Optional. Returns primary side that is overlapped. LEFT=0,RIGHT=1,TOP=2,BOTTOM=3