learn-physics-0.4.2: Haskell code for learning physics

Stabilityexperimental
MaintainerScott N. Walck <walck@lvc.edu>
Safe HaskellSafe

Physics.Learn.SimpleVec

Description

Basic operations on the vector type Vec, such as vector addition and scalar multiplication. This module is simple in the sense that the operations on vectors all have simple, concrete types, without the need for type classes. This makes using and reasoning about vector operations easier for a person just learning Haskell.

Synopsis

Documentation

data Vec Source

A type for vectors.

xComp :: Vec -> DoubleSource

x component

yComp :: Vec -> DoubleSource

y component

zComp :: Vec -> DoubleSource

z component

vecSource

Arguments

:: Double

x component

-> Double

y component

-> Double

z component

-> Vec 

Form a vector by giving its x, y, and z components.

(^+^) :: Vec -> Vec -> VecSource

Vector addition.

(^-^) :: Vec -> Vec -> VecSource

Vector subtraction.

(*^) :: Double -> Vec -> VecSource

Scalar multiplication, where the scalar is on the left and the vector is on the right.

(^*) :: Vec -> Double -> VecSource

Scalar multiplication, where the scalar is on the right and the vector is on the left.

(^/) :: Vec -> Double -> VecSource

Division of a vector by a scalar.

(<.>) :: Vec -> Vec -> DoubleSource

Dot product of two vectors.

(><) :: Vec -> Vec -> VecSource

Cross product.

magnitude :: Vec -> DoubleSource

Magnitude of a vector.

zeroV :: VecSource

The zero vector.

negateV :: Vec -> VecSource

The additive inverse of a vector.

sumV :: [Vec] -> VecSource

Sum of a list of vectors.

iHat :: VecSource

Unit vector in the x direction.

jHat :: VecSource

Unit vector in the y direction.

kHat :: VecSource

Unit vector in the z direction.