sph2cart

From DavinciWiki
Jump to: navigation, search

Description

Convert spherical coordinates to Cartesian (rectangular)

Arguments and Return Values

Parameters: Three inputs specifying the radial, latitude, and longitude coordinates, respectively, with angles in degrees.

Return Value: An array specifying the x, y, and z coordinates, respectively, with angles in degrees.

Usage

Syntax: sph2cart(r, latitude, longitude)

All inputs should be numeric.

These are not the conventional spherical coordinates, but they should be more useful for people doing work in planetary coordinates.

Zero longitude corresponds to the x-axis; 90 E is y-axis. Zero latitude is the equatorial (xy) plane.

This function can handle array inputs, but when entering them, you will probably want their x-dimensions to be one, so that the returned values are easier to read. The function concatenates the output coordinates along their x-axis.

When sph2cart() is entered without any arguments, it prints its description, as shown below.

Examples

dv> sph2cart()

Convert spherical coordinates to Cartesian (rectangular)
sph2cart(r, latitude, longitude) returns (x, y, z) where r is the
 radial coordinate, and latitude and longitude are in degrees.
 r is optional; if only given two inputs, the function assumes they
  are latitude and longitude, respectively, and sets r to 1.
 Input angles must be in degrees. Longitude must be east-positive.
 Zero longitude corresponds to the x-axis; 90 E is y-axis.
 r, latitude, and longitude must be entered as separate arguments
 To make the output easier to read, inputs should only have one row.
S.Marshall 10-30-2009

0
dv> sph2cart(1000, 0, 45)
3x1x1 array of float, bsq format [12 bytes]
707.106750488281        707.106750488281        0.00000000000000
dv> sph2cart(1000, 45, 45)
3x1x1 array of float, bsq format [12 bytes]
499.999969482422        499.999969482422        707.106750488281

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Major Sub-Functions

Related Functions

Recent Library Changes

Created On: 11-18-2009
Modified On: 11-19-2009

Personal tools