learn-physics-0.6.0.0: Haskell code for learning physics

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.

Instances

 Source Source Source type Scalar Vec = Double type Diff Vec = Vec Source

x component

y component

z component

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

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

Group subtraction

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

Scale a vector

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

Vector multiplied by scalar

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

Vector divided by scalar

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

Inner/dot product

(><) :: Vec -> Vec -> Vec infixl 7 Source

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