spherical_to_cart_batch

Function spherical_to_cart_batch 

Source
pub fn spherical_to_cart_batch(
    spherical: &ArrayView2<'_, f64>,
) -> SpatialResult<Array2<f64>>
Expand description

Converts multiple spherical coordinates to Cartesian coordinates

§Arguments

  • spherical - A 2D array of spherical coordinates, each row is [r, theta, phi]

§Returns

A 2D array of Cartesian coordinates, each row is [x, y, z]

§Example

use scirs2_core::ndarray::array;
use scirs2_spatial::transform::spherical::spherical_to_cart_batch;
use std::f64::consts::PI;

let spherical = array![
    [1.0, PI/2.0, 0.0],      // Point on x-axis
    [1.0, PI/2.0, PI/2.0],   // Point on y-axis
    [1.0, 0.0, 0.0],         // Point on z-axis
];
let cart = spherical_to_cart_batch(&spherical.view()).expect("Operation failed");

§Errors

Returns an error if any row of the input array doesn’t have exactly 3 elements