CPolygon:Distance


The Distance method calculates the distance between 2 vertices of the CPolygon. The vertices are specified by ther indices.

Syntax

nDistance = CPolygon:Distance( nIndex1, nIndex2 )

where

    nIndex1, nIndex2 are 2 vertex indices. The order is not important.

    nDistance is the area enclosed by the polygon.

Example

The following script creates a CPolygon from 2 arrays and calculates the distance between the last point and first point:

A = NewPolygon( {4,5,6,7}, {1,2,-3,5} )

-- create CPolygon A

Printf("D = %lg", A:Distance( A:Count(), 1 ) )

-- result: D = 5

Related Topics

PathLen

Perimeter

CPolygon class