CONV_TO_RECT Function

Converts polar, cylindrical, or spherical (mathematical or global) coordinates to rectangular coordinates (points).

Usage

    result = CONV_TO_RECT(vec1, vec2, vec3)

Input Parameters

vec1—A 1D array containing the polar (longitude) angles.

vec2—A 1D array containing the latitude angles, unless the Polar or Cylin keywords are present and nonzero. If either keyword is specified, then vec2 should contain the radii.

vec3—A 1D array containing the radii for spherical coordinates, unless Polar or Cylin keywords are present and nonzero. If Polar is specified, then vec3 should be the scalar value 0 (it is ignored). If Cylin is specified, then vec3 should contain the z values.

Returned Value

result—If the Polar keyword is present and nonzero, then a FLOAT(2, n) array is returned with (0, *) containing the x-coordinates and (1, *) containing the y-coordinates.

If Polar is zero (or not present), then a FLOAT(3, *) array is returned with (0, *) containing the x-coordinates, (1, *) containing the y-coordinates, and (2, *) containing the z-coordinates.

Keywords

Cylin—Specifies that the input coordinates are cylindrical.

Degrees—If present and nonzero, causes the input coordinates to be in degrees instead of radians.

Global—If present and nonzero, causes the input coordinates to be in global longitude and latitude angles. The longitude angles are the horizontal angles on the Earth’s globe, where the angles east of the Greenwich meridian are positive, and angles to the west are negative. The latitude angles are vertical angles rotated with respect to the equator. They are positive in the northern hemisphere and negative in the southern hemisphere. By default, the function expects these global latitude and longitude values; this keyword can be used, however, to add clarity to the function call.

Polar—Specifies that the input coordinates are polar.

Sphere—If present and nonzero, causes the input coordinates to be in a spherical coordinate system where the vertical angle is rotated with respect to the vertical (or polar) axis instead of the horizontal axis. The horizontal angles and radii are the same as in the global spherical case. This system is based on the set of conversion equations in the CRC Standard Mathematical Tables.

Examples

This program displays 3D fluid flow vector field with random starting points for the vectors.

PRO vol_demo1
   ; Specify the size of the volumes.
   volx = 17
   voly = 17
   volz = 59
   ; Specify the window size.
   winx = 500
   winy = 700
   flow_axial = FLTARR(volx, voly, volz)
   ; Read in the data as cylindrical coordinates.
   OPENR, 1, !Data_Dir + 'cfd_axial.dat', /Xdr 
   READU, 1, flow_axial
   CLOSE, 1
   flow_radial = FLTARR(volx, voly, volz)
   OPENR, 1, !Data_Dir + 'cfd_radial.dat', /Xdr
   READU, 1, flow_radial
   CLOSE, 1
   flow_tangent = FLTARR(volx, voly, volz)
   OPENR, 1, !Data_Dir + 'cfd_tangent.dat', /Xdr
   READU, 1, flow_tangent
   CLOSE, 1
   flow_pressure = FLTARR(volx, voly, volz)
   ; Read in the data to be used for the vector color.
   OPENR, 1, !Data_Dir + 'cfd_pressure.dat', /Xdr
   READU, 1, flow_pressure
   CLOSE, 1
   ; Convert the data from cylindrical coordinates to Cartesian
   ; coordinates.
   points = CONV_TO_RECT(flow_tangent(*),  $
      flow_radial(*), flow_axial(*), /Cylin, /Degrees)
   ; Split points array into three 2D arrays to abstract x, y, z 
   ; values from the converted data.
   flow_x = FLTARR(volx, voly, volz)
   flow_y = FLTARR(volx, voly, volz)
   flow_z = FLTARR(volx, voly, volz)
   flow_x(*) = points(0, *)
   flow_y(*) = points(1, *)
   flow_z(*) = points(2, *)
   ; Set up the transformation matrix for the view.
   T3D, /Reset 
   T3D, Translate=[-0.5, -0.5, -0.5]
   T3D, Scale=[0.9, 0.9, 0.9]
   T3D, Rotate=[0.0, 0.0, -30.0]
   T3D, Rotate=[-60.0, 0.0, 0.0]
   T3D, Translate=[0.5, 0.5, 0.5]
   ; Set up the viewing window and load the color table.
   WINDOW, 0, XSize=winx, YSize=winy,  $
      XPos=256, YPos=128, Colors=128,  $
      Title='3D Velocity Vector Field'
   LOADCT, 4
   ; Plot the converted data as a vector field.
   VECTOR_FIELD3, flow_x, flow_y, flow_z, 1000,  $
   Max_Length=2.5, Vec_Color=flow_pressure,  $
   Min_Color=32, Max_Color=127,  $
   Axis_Color=100, Mark_Symbol=2,  $
   Mark_Color=90, Mark_Size=0.5, Thick=2
END

For another example, see the vec_demo2 demonstration program in

    (UNIX) <wavedir>/demo/arl

    (WIN) <wavedir>\demo\arl

Where <wavedir> is the main PV‑WAVE directory.

See Also

CONV_FROM_RECT

For more information, see the PV‑WAVE User Guide.