From f8de91ae41929286b1cf43c72093e5c996b1f949 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 18 Sep 2005 19:19:36 +0000 Subject: Added documentation --- vector.mod/doc/commands.html | 56 +++++++++++++++++++++++++ vector.mod/vector.bmx | 98 ++++++++++++++++++++++++++++---------------- 2 files changed, 119 insertions(+), 35 deletions(-) create mode 100644 vector.mod/doc/commands.html (limited to 'vector.mod') diff --git a/vector.mod/doc/commands.html b/vector.mod/doc/commands.html new file mode 100644 index 0000000..4cb9c08 --- /dev/null +++ b/vector.mod/doc/commands.html @@ -0,0 +1,56 @@ + + +BlitzMax Module Reference + + + +

Type Reference

+

+
Type TVector Implements a 3D vector. Can be used as a 2D vector by ignoring Z.

+
Field x:Float The X component of the vector.


+

+
Field y:Float The Y component of the vector.


+

+
Field z:Float The Z component of the vector.


+

+
Method IsNull:Int() Is the vector null.

Returns: True if the vector is null (all components zero), False otherwise.



+

+
Method Length:Float() The length of the vector.

Returns: The length of the vector.



+

+
Method Normalise() Normalise the vector so its length is 1.


+

+
Method SetLength( sc:Float ) Set the vector so its length is sc.


+

+
Method AddScalar( sc:Float ) Adds sc to all components.


+

+
Method Minus() Reverse the direction of the vector.


+

+
Method Scale( sc:Float ) Scale all components by sc.


+

+
Method Add( v:TVector ) Add another vector to this vector.


+

+
Method Subtract( v:TVector ) Subtract another vector from this vector.


+

+
Method ScaleVector( v:TVector ) Scale this vector by another vector.


+

+
Method InverseScaleVector( v:TVector ) Inverse scale this vector by another vector.


+

+
Method Cross:TVector( v:TVector ) Calculate the cross product of this vector with another.

Returns: A new TVector holding the cross product.



+

+
Method Dot:Float( v:TVector ) Calculate the dot product of this vector with another.

Returns: The dot product.



+

+
Function Create:TVector( dx:Float=0.0, dy:Float=0.0, dz:Float=0.0 ) Create a vector.

Returns: The created vector.

dx, dy and dz are the initial component values.



+

+

Module Information

+ + + + + + + + + +
Framework Simple Vector class
Copyright Public Domain
Author Ian Cowburn
Version $Revision$
+ + diff --git a/vector.mod/vector.bmx b/vector.mod/vector.bmx index f32035b..67818fe 100644 --- a/vector.mod/vector.bmx +++ b/vector.mod/vector.bmx @@ -1,3 +1,6 @@ +Rem +bbdoc: noddybox.vector +EndRem Module noddybox.vector ModuleInfo "Framework: Simple Vector class" @@ -10,21 +13,30 @@ ModuleInfo "Version: $Revision$" Strict Import brl.math +Rem +bbdoc: Implements a 3D vector. Can be used as a 2D vector by ignoring Z. +EndRem Type TVector + Rem + bbdoc: The X component of the vector. + EndRem Field x:Float + Rem + bbdoc: The Y component of the vector. + EndRem Field y:Float + Rem + bbdoc: The Z component of the vector. + EndRem Field z:Float - ' Creates a new vector - ' - ' dx - X componenent - ' dy - Y componenent - ' dz - Z componenent - ' - ' Returns null for invalid parameters. - ' + Rem + bbdoc: Create a vector. + returns: The created vector. + about: @dx, @dy and @dz are the initial component values. + EndRem Function Create:TVector(dx:Float=0.0, dy:Float=0.0, dz:Float=0.0) Local o:TVector @@ -37,14 +49,18 @@ Type TVector Return o End Function - ' Is this vector null - ' + Rem + bbdoc: Is the vector null. + returns: True if the vector is null (all components zero), False otherwise. + EndRem Method IsNull:Int() Return x=0 And y=0 And z=0 End Method - ' Get the length of the vector - ' + Rem + bbdoc: The length of the vector. + returns: The length of the vector. + EndRem Method Length:Float() If (IsNull()) Return 0 @@ -53,8 +69,9 @@ Type TVector EndIf End Method - ' Normalise the vector - ' + Rem + bbdoc: Normalise the vector so its length is 1. + EndRem Method Normalise() Local l:Float=Length() If (l<>0) @@ -64,78 +81,89 @@ Type TVector EndIf End Method - ' Set the vector to a length - ' + Rem + bbdoc: Set the vector so its length is @sc. + EndRem Method SetLength(sc:Float) Normalise() Scale(sc) End Method - ' Add a scalar to the vector - ' + Rem + bbdoc: Adds @sc to all components. + EndRem Method AddScalar(sc:Float) x:+sc y:+sc z:+sc End Method - ' Flip the vector - ' + Rem + bbdoc: Reverse the direction of the vector. + EndRem Method Minus() x=-x y=-y z=-z End Method - ' Scale the vector by a scalar - ' + Rem + bbdoc: Scale all components by @sc. + EndRem Method Scale(sc:Float) x:*sc y:*sc z:*sc End Method - ' Add another vector to this - ' + Rem + bbdoc: Add another vector to this vector. + EndRem Method Add(v:TVector) x:+v.x y:+v.y z:+v.z End Method - ' Subtract another vector from this - ' + Rem + bbdoc: Subtract another vector from this vector. + EndRem Method Subtract(v:TVector) x:-v.x y:-v.y z:-v.z End Method - ' Scale this with another vector - ' + Rem + bbdoc: Scale this vector by another vector. + EndRem Method ScaleVector(v:TVector) x:*v.x y:*v.y z:*v.z End Method - ' Inverse scale this with another vector - ' + Rem + bbdoc: Inverse scale this vector by another vector. + EndRem Method InverseScaleVector(v:TVector) x:/v.x y:/v.y z:/v.z End Method - ' Calculate the cross product of this vector with another. - ' Returns a new vector. - ' + Rem + bbdoc: Calculate the cross product of this vector with another. + returns: A new @TVector holding the cross product. + EndRem Method Cross:TVector(v:TVector) Return TVector.Create(y * v.z - v.y * z, z * v.x - v.z * x, x * v.y - v.x * y) End Method - ' Calculate the dot product of this vector with another. - ' + Rem + bbdoc: Calculate the dot product of this vector with another. + returns: The dot product. + EndRem Method Dot:Float(v:TVector) Return x*v.x + y*v.y + z*v.z End Method -- cgit v1.2.3