dsmc-0.1.0.1: DSMC library for rarefied gas dynamics

Safe HaskellSafe-Inferred

DSMC.Util.Vector

Contents

Description

Simple 3-vectors and matrices built atop tuples.

Synopsis

Documentation

type Vec3 = (Double, Double, Double)Source

Vector in R^3.

type Matrix = (Vec3, Vec3, Vec3)Source

Matrix given by its rows.

type Point = Vec3Source

Point in R^3.

origin :: PointSource

Origin point (0, 0, 0).

Vector operations

(<+>) :: Vec3 -> Vec3 -> Vec3Source

Add two vectors.

(<->) :: Vec3 -> Vec3 -> Vec3Source

Subtract two vectors.

(><) :: Vec3 -> Vec3 -> Vec3Source

Vec3 cross product.

(.^) :: Vec3 -> Double -> Vec3Source

Scale vector.

(.*) :: Vec3 -> Vec3 -> DoubleSource

Vec3 dot product.

norm :: Vec3 -> DoubleSource

Euclidean norm of vector.

normalize :: Vec3 -> Vec3Source

Produce unit vector with same direction as the original one.

invert :: Vec3 -> Vec3Source

Scale vector by -1.

distance :: Point -> Point -> DoubleSource

Euclidean distance between two points.

moveBySource

Arguments

:: Point

Current position.

-> Vec3

Velocity.

-> Double

Time step.

-> Point 

Move point by velocity vector for given time and return new position.

Matrix operations

mxv :: Matrix -> Vec3 -> Vec3Source

Multiply matrix (given by row vectors) and vector

vxv :: Vec3 -> Vec3 -> MatrixSource

Transpose vector and multiply it by another vector, producing a matrix.

dotM :: Vec3 -> Vec3 -> Matrix -> DoubleSource

Generic vector dot product.

Multiply transpose of first vector by given matrix, then multiply the result by second vector.

diag :: Double -> MatrixSource

Produce matrix with diagonal elements equal to given value.

addM :: Matrix -> Matrix -> MatrixSource

Add two matrices.

We could add Applicative instance for Matrix and lift (+) to it.

Cartesian system

buildCartesian :: Double -> Double -> (Vec3, Vec3, Vec3)Source

Build cartesian axes from yaw and pitch with 0 roll. Angles are in radians.