learn-physics-0.6.3: Haskell code for learning physics

Copyright (c) Scott N. Walck 2011-2018 BSD3 (see LICENSE) Scott N. Walck experimental Safe Haskell98

Physics.Learn.CarrotVec

Contents

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 # Instance detailsDefined in Physics.Learn.CommonVec Methods(==) :: Vec -> Vec -> Bool #(/=) :: Vec -> Vec -> Bool # Source # Instance detailsDefined in Physics.Learn.CommonVec MethodsshowsPrec :: Int -> Vec -> ShowS #show :: Vec -> String #showList :: [Vec] -> ShowS # # Instance detailsDefined in Physics.Learn.CarrotVec Associated Typestype Scalar Vec :: * # Methods(*^) :: Scalar Vec -> Vec -> Vec # # Instance detailsDefined in Physics.Learn.CarrotVec Methods(<.>) :: Vec -> Vec -> Scalar Vec # # Instance detailsDefined in Physics.Learn.CarrotVec Methods(^+^) :: Vec -> Vec -> Vec #negateV :: Vec -> Vec #(^-^) :: Vec -> Vec -> Vec # Source # Instance detailsDefined in Physics.Learn.StateSpace Associated Typestype Diff Vec :: * Source # Methods type Scalar Vec # Instance detailsDefined in Physics.Learn.CarrotVec type Scalar Vec = Double type Diff Vec Source # Instance detailsDefined in Physics.Learn.StateSpace type Diff Vec = Vec

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 infixl 6 #

(^-^) :: AdditiveGroup v => v -> v -> v infixl 6 #

Group subtraction

(*^) :: VectorSpace v => Scalar v -> v -> v infixr 7 #

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 infixr 7 #

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 #

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

Sum over several vectors

Unit vector in the x direction.

Unit vector in the y direction.

Unit vector in the z direction.

# Orphan instances

 Source # Instance details Associated Typestype Scalar Vec :: * # Methods(*^) :: Scalar Vec -> Vec -> Vec # Source # Instance details Methods(<.>) :: Vec -> Vec -> Scalar Vec # Source # Instance details Methods(^+^) :: Vec -> Vec -> Vec #negateV :: Vec -> Vec #(^-^) :: Vec -> Vec -> Vec #