learn-physics-0.2: Haskell code for learning physics

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

Physics.Learn.CarrotVec

Description

This module defines some basic vector functionality. It uses the same internal data representation as SimpleVec, but declares Vec to be an instance of VectorSpace. We import zeroV, negateV, sumV, ^+^, ^-^ from AdditiveGroup, and *^, ^*, ^/, <.>, magnitude from VectorSpace.

CarrotVec exports exactly the same symbols as SimpleVec; they are just defined differently.

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.

(^+^) :: AdditiveGroup v => v -> v -> v

Add vectors

(^-^) :: AdditiveGroup v => v -> v -> v

Group subtraction

(*^) :: VectorSpace v => Scalar v -> v -> v

Scale a vector

(^*) :: (VectorSpace v, ~ * s (Scalar v)) => v -> s -> v

Vector multiplied by scalar

(^/) :: (VectorSpace v, ~ * s (Scalar v), Fractional s) => v -> s -> v

Vector divided by scalar

(<.>) :: InnerSpace v => v -> v -> Scalar v

Inner/dot product

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

Cross product.

magnitude :: (InnerSpace v, ~ * s (Scalar v), Floating s) => v -> s

Length of a vector. See also magnitudeSq.

zeroV :: AdditiveGroup v => v

The zero element: identity for '(^+^)'

negateV :: AdditiveGroup v => v -> v

Additive inverse

sumV :: (Foldable f, AdditiveGroup v) => f v -> v

Sum over several 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.