Learn R Programming

spheresmooth (version 0.1.3)

spherical_to_cartesian: Convert spherical coordinates to Cartesian coordinates

Description

This function converts spherical coordinates (theta, phi) to Cartesian coordinates.

Usage

spherical_to_cartesian(theta_phi, byrow = TRUE)

Value

A matrix where each row contains the Cartesian coordinates (x, y, z) of a point.

Arguments

theta_phi

A matrix where each row contains the spherical coordinates (theta, phi) of a point.

byrow

logical. If TRUE (the default) the matrix is filled by rows, otherwise the matrix is filled by columns.

Examples

Run this code
theta_phi <- matrix(c(pi/4, pi/3, pi/6, pi/4), ncol = 2, byrow = TRUE)
spherical_to_cartesian(theta_phi)

Run the code above in your browser using DataLab