learn-physics-0.6.6: Haskell code for learning physics
Copyright(c) Scott N. Walck 2011-2019
LicenseBSD3 (see LICENSE)
MaintainerScott N. Walck <walck@lvc.edu>
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

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

Instances details
Show Vec Source # 
Instance details

Defined in Physics.Learn.CommonVec

Methods

showsPrec :: Int -> Vec -> ShowS #

show :: Vec -> String #

showList :: [Vec] -> ShowS #

Eq Vec Source # 
Instance details

Defined in Physics.Learn.CommonVec

Methods

(==) :: Vec -> Vec -> Bool #

(/=) :: Vec -> Vec -> Bool #

StateSpace Vec Source # 
Instance details

Defined in Physics.Learn.StateSpace

Associated Types

type Diff Vec Source #

Methods

(.-.) :: Vec -> Vec -> Diff Vec Source #

(.+^) :: Vec -> Diff Vec -> Vec Source #

AdditiveGroup Vec Source # 
Instance details

Defined in Physics.Learn.CarrotVec

Methods

zeroV :: Vec #

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

negateV :: Vec -> Vec #

(^-^) :: Vec -> Vec -> Vec #

InnerSpace Vec Source # 
Instance details

Defined in Physics.Learn.CarrotVec

Methods

(<.>) :: Vec -> Vec -> Scalar Vec #

VectorSpace Vec Source # 
Instance details

Defined in Physics.Learn.CarrotVec

Associated Types

type Scalar Vec #

Methods

(*^) :: Scalar Vec -> Vec -> Vec #

type Diff Vec Source # 
Instance details

Defined in Physics.Learn.StateSpace

type Diff Vec = Vec
type Scalar Vec Source # 
Instance details

Defined in Physics.Learn.CarrotVec

type Scalar Vec = R

type R = Double Source #

xComp :: Vec -> R Source #

x component

yComp :: Vec -> R Source #

y component

zComp :: Vec -> R Source #

z component

vec Source #

Arguments

:: R

x component

-> R

y component

-> R

z component

-> Vec 

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

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

Add vectors

(^-^) :: 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 #

Additive inverse

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

Sum over several vectors

iHat :: Vec Source #

Unit vector in the x direction.

jHat :: Vec Source #

Unit vector in the y direction.

kHat :: Vec Source #

Unit vector in the z direction.

Orphan instances

AdditiveGroup Vec Source # 
Instance details

Methods

zeroV :: Vec #

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

negateV :: Vec -> Vec #

(^-^) :: Vec -> Vec -> Vec #

InnerSpace Vec Source # 
Instance details

Methods

(<.>) :: Vec -> Vec -> Scalar Vec #

VectorSpace Vec Source # 
Instance details

Associated Types

type Scalar Vec #

Methods

(*^) :: Scalar Vec -> Vec -> Vec #