Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Cartesian 3-Vectors

by Zaxo (Archbishop)
on Jun 18, 2001 at 10:56 UTC ( #89236=snippet: print w/replies, xml ) Need Help??

These functions implement common operations on three dimensional vectors. Applications may use these by transforming to rectangular coordinates before calling the functions.

# These functions all take references to arrays over [0..2] without
# modifying the arguments. Arguments assume Cartesian(x,y,z) geometry
# This could be expanded to a module.

# Cartesian 3-vector dot product
sub dot {

# Cartesian 3-vector cross product
# returns reference to array over [0..2]
sub cross {

# length of a Cartesian 3-vector
# returns number
sub norm {

# angle between two Cartesian 3-vectors
# returns number: angle in radians
sub arc {
    atan2 norm(cross($_[0],$_[1])), dot($_[0],$_[1]);
Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://89236]
[atcroft]: stevieb: I have berrybrew installed on a Win machine, and I noticed that with perlbrew you can "upgrade" a particular installed version... any chance of doing something similar in the
[atcroft]: future with berrybrew?
[atcroft]: stevieb: Also, one other odd question... is it possible to set it up so that all the versions installed can use a single directory that they pull module sources into, rather than duplicating files? (Am I making sense, or do I have too high a CBC
[atcroft]: (caffeine-blood content) atm?)

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2017-04-29 05:09 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.