CImage:DistanceWcs


 

The DistanceWcs method calculates the distance in WCS units between 2 image points measured in world coordinates. The related Distance method computes the distance for pixel coordinates.

Syntax

nDistance = CImage:DistanceWcs( x1, y1, x2, y2 )

where

    x1,y1 are world coordinate values for the coordinate of the first point.

    x2,y2 are world coordinate values for the coordinate of the first point.

    nDistance is a number giving the wold coordinate distance (see below).

    On success, this method returns nDistance.

    On failure, this method returns 0.

  

The DistanceWcs method returns a distance in world coordinate units. For angular coordinate systems, this would be measured in degrees. If the image does not contain a world coordinate calibration, then Mira interprets the values as pixel coordinates and the distance is reported in distance units. If the coordinate calibration is in equatorial form, you can retrieve distance in string format using DistanceWcsStr.

Example

Assume an image is displayed and attached to a CImageView named V. The following script measures the distance between between two points (x1,y1) and (x2,y2) when the coordinates are in distance units (pixels, mm, microns, etc.):

I = V:GetImage()

-- load the image from a

x1 = 442.5 ; y1 = 220.44

-- point 1

x2 = 1.554 ; y2 = 20.552

-- point 2

D = I:DistanceWcs(x1,y1,x2,y2)

-- make the measurement

Alternatively, the following example supposes an astronomical image with an equatorial calibration and that the points are expressed in angular units:

V:GetImage()

-- load the image from a

x1 = "05:42:15.52" ; y1 = "20:40:12.5"

-- point 1

x2 = "05:42:44.12" ; y2 = "20:42:42.1"

-- point 2

D = I:DistanceWcs(x1,y1,x2,y2)

-- make the measurement

Related Topics

Distance

DistanceWcsStr

CImage class

Image Coordinate System

Subpixel Coordinate Definition