• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Some Vector and Matrix operations

Level 29
Joined
Jul 29, 2007
Messages
5,174
Because I like being graveyard'ed.

This is useful (if it wasn't made before) for people who want to make some 3d transformations.
Don't ask me why any sane human will use this in Warcraft (aside from the one I made this for).

Basically what you can do with this is easily rotate 3d points around whatever you want.

Do notice (if there's any insane human that wants to use this) that EVERY ANGLE IS IN RADIANS.

There's an example of usage below the code.



JASS:
globals
    // just for the lulz
    // can this even compile? :)
    constant real PI = 3.1415926535897932384626433832795
    constant real deg2Rad = 0.01745329251994329576923690768488
    constant real rad2Deg = 57.2957795130823208767981548141052

endglobals

//****************************************************************
// struct vec3 represents a 3d vector
//
// members:
//     real x - x coordinate of the vector
//     real y - y coordinate of the vector
//     real z - z coordinate of the vector
//
// methods:
//     setv takes real x,real y,real z returns nothing
//         sets self to the given values respectively
//
//     squaredLength takes nothing returns real
//         returns the squared length of the vector
// 
//     normalize takes nothing returns nothing
//         sets the length of the vector to one (unit vector)
// 
//     add takes vec3 v returns vec3
//         adds v to self and returns the solution
// 
//     sub takes vec3 v returns vec3
//         substracts v from self and returns the solution
// 
//     scale takes real s returns nothing
//         scales the vector by s
//
//     dot takes vec3 v returns real
//         returns the dot value of v with self
//****************************************************************

struct vec3

    real x
    real y
    real z
    
    method setv takes real x,real y,real z returns nothing
        set .x = x
        set .y = y
        set .z = z
    endmethod
    
    method squaredLength takes nothing returns real
        return (.x * .x) + (.y * .y) + (.z * .z)
    endmethod

    method normalize takes nothing returns nothing
        local real length = .squaredLength()

        if length > 1  then // to avoid unnecessary square roots
            set length = SquareRoot(length)

            set .x = .x / length
            set .y = .y / length
            set .z = .z / length
        elseif length > 0 then
            set length = SquareRoot(length)

            set .x = .x * (1 / length)
            set .y = .y * (1 / length)
            set .z = .z * (1 / length)
        else // any unit vector will do, might as well pick the X axis
            set .x = 1
            set .y = 0
            set .z = 0
        endif
    endmethod

    method add takes vec3 v returns vec3
        local vec3 ret = vec3.create()

        set ret.x = .x + v.x
        set ret.y = .y + v.y
        set ret.z = .z + v.z

        return ret
    endmethod

    method sub takes vec3 v returns vec3
        local vec3 ret = vec3.create()

        set ret.x = .x - v.x
        set ret.y = .y - v.y
        set ret.z = .z - v.z

        return ret
    endmethod

    method scale takes real s returns nothing
        set .x = .x * s
        set .y = .y * s
        set .z = .z * s
    endmethod
    
    method dot takes vec3 v returns real
        return (.x * v.x) + (.y * v.y) + (.z * v.z)
    endmethod

endstruct


//****************************************************************
// struct mat3 represents a 3x3 matrix
//
// members:
//     real m[9] - all the 9 indexes of the matrix
//
// methods:
//     multVector takes vec3 v returns vec3
//         returns v multiplied by self
// 
//     multMatrix takes mat3 m returns mat3
//         returns m multiplied by self
// 
//     rotationAxis takes real radians, vec3 axis returns nothing
//         creates a rotation matrix around axis
// 
//     rotationX takes real radians returns nothing
//         creates a rotation matrix around the X axis
// 
//     rotationY takes real radians returns nothing
//         creates a rotation matrix around the Y axis
//
//     rotationZ takes real radians returns nothing
//         creates a rotation matrix around the Z axis
//****************************************************************

struct mat3

    real array m[9]

    method multVector takes vec3 v returns vec3
        local vec3 ret = vec3.create()

        set ret.x = .m[0] * v.x + .m[1] * v.y + .m[2] * v.z
        set ret.y = .m[3] * v.x + .m[4] * v.y + .m[5] * v.z
        set ret.z = .m[6] * v.x + .m[7] * v.y + .m[8] * v.z

        return ret
    endmethod

    method multMatrix takes mat3 m returns mat3
        local mat3 ret = mat3.create()

        local integer row = 0
        local integer col = 0
        local integer i

        loop
            exitwhen row == 3

            set i = 3 * row

            loop
                exitwhen col == 3
                
                set ret.m[i + col] = .m[i] * m.m[col] + .m[i + 1] * m.m[3 + col] + .m[i + 2] * m.m[6 + col]

                set col = col + 1
            endloop

            set row = row + 1
            set col = 0
        endloop

        return ret
    endmethod


    method rotationAxis takes real radians, vec3 axis returns nothing
        local real fcos = Cos(radians)
        local real fsin = Sin(radians)
        local real foneMinusCos = 1.0 - fcos
        local real fx2 = axis.x * axis.x
        local real fy2 = axis.y * axis.y
        local real fz2 = axis.z * axis.z
        local real fxym = axis.x * axis.y * foneMinusCos
        local real fxzm = axis.x * axis.z * foneMinusCos
        local real fyzm = axis.y * axis.z * foneMinusCos
        local real fxSin = axis.x * fsin
        local real fySin = axis.y * fsin
        local real fzSin = axis.z * fsin
    
        set .m[0] = fx2 * foneMinusCos + fcos
        set .m[1] = fxym - fzSin
        set .m[2] = fxzm + fySin
        set .m[3] = fxym + fzSin
        set .m[4] = fy2 * foneMinusCos + fcos
        set .m[5] = fyzm - fxSin
        set .m[6] = fxzm - fySin
        set .m[7] = fyzm + fxSin
        set .m[8] = fz2 * foneMinusCos + fcos
    endmethod

    method rotationX takes real radians returns nothing
        local real fcos = Cos(radians)
        local real fsin = Sin(radians)

        set .m[0] = 1
        set .m[1] = 0
        set .m[2] = 0
        set .m[3] = 0
        set .m[4] = fcos
        set .m[5] = fsin
        set .m[6] = -fsin
        set .m[7] = fcos
        set .m[8] = 0
    endmethod

    method rotationY takes real radians returns nothing
        local real fcos = Cos(radians)
        local real fsin = Sin(radians)

        set .m[0] = fcos
        set .m[1] = 0
        set .m[2] = -fsin
        set .m[3] = 0
        set .m[4] = 1
        set .m[5] = 0
        set .m[6] = fsin
        set .m[7] = 0
        set .m[8] = fcos
    endmethod

    method rotationZ takes real radians returns nothing
        local real fcos = Cos(radians)
        local real fsin = Sin(radians)

        set .m[0] = fcos
        set .m[1] = fsin
        set .m[2] = 0
        set .m[3] = -fsin
        set .m[4] = fcos
        set .m[5] = 0
        set .m[6] = 0
        set .m[7] = 0
        set .m[8] = 1
    endmethod

endstruct


Here's an example of making a plane (a simple square) and rotating it around the Z axis, which is the same as unit facing in Warcraft.

JASS:
globals
    vec3 a = vec3.create()
    vec3 b = vec3.create()
    vec3 c = vec3.create()
    vec3 d = vec3.create()
endglobals

function InitPlane takes nothing returns nothing
    set a.setv(-1, 0, 1) // left-top corner
    set b.setv( 1, 0, 1) // right-top corner
    set c.setv( 1, 0,-1) // right-bottom corner
    set d.setv(-1, 0,-1) // left-bottom corner
endfunction

function RotatePlaneZ takes real radians returns nothing
    local mat3 m = mat3.create()
    call m.rotationZ(radians)
    
    set a = m.multVector(a)
    set b = m.multVector(b)
    set c = m.multVector(c)
    set d = m.multVector(d)
endfunction
 
Last edited:
Level 9
Joined
Mar 25, 2005
Messages
252
You should put your structs in libraries and turn your global variables into private constants.
--

When I first read your rotation methods I assumed they would rotate the matrix (mostly based on their names), but only when I looked at your example I realized what they actually do. Perhaps I should have put more attention to reading your documentation, but I think renaming the methods could help prevent confusion. Basicly just into: rotationMatrix(X|Y|>), or createRotation(X|Y|Z) or anything else that would indicate their 'factory' behaviour.

Anyways, if I wanted to rotate vectors in WcIII this would be a really tempting solution.

@PurplePoot
bj_PI has very few digits of precision for some reason, so a perfectionist might want to use his own constants.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Ghostwolf, if you want i can turn those vJass 2d arrays into oldschool 2d arrays.
EDIT: Actually you can just search for all the ][ tags and change them into *3+

And change the struct member in real array [9]


And thanks for making this! It really helps alot!
 
Last edited:
Level 11
Joined
Feb 22, 2006
Messages
752
I made a matrix library a while back. It allows for NxN sized matrices as well as N-dimensional vectors. It also uses a "2d array" syntax (for the matrices) by overloading [] and []= operators. You can take a look at it if it helps you to figure out how to properly implement your matrices without doing the i*j-sized arrays.


JASS:
library Matrix

globals
    public constant integer MAX_ROW_COUNT = 5
    public constant integer MAX_COLUMN_COUNT = 5
endglobals

// ==============================================================================

private type RealArray extends real array [MAX_COLUMN_COUNT]

private struct MatrixRow
    private Matrix m
    private RealArray elements
    private integer elementN
    
    static method create takes Matrix m, integer elementCount returns MatrixRow
        local MatrixRow this = MatrixRow.allocate()
        local integer i = 0
        
        set this.m = m
        set this.elements = RealArray.create()
        set this.elementN = elementCount
        loop
            exitwhen (i >= .elementN)
            set this.elements[i] = 0
            set i = i + 1
        endloop
        
        return this
    endmethod
    
    method operator [] takes integer index returns real
        if (index > 0 and index <= .elementN) then
            return .elements[index - 1]
        endif
        debug call BJDebugMsg("Index out of bounds: Attempted to access column " + I2S(index) + " in " + I2S(m.getRowCount()) + "x" + I2S(m.getColumnCount()) + " matrix.")
        return 0.0
    endmethod
    
    method operator []= takes integer index, real r returns nothing
        if (index > 0 and index <= .elementN) then
            set .elements[index - 1] = r
        endif
        debug call BJDebugMsg("Index out of bounds: Attempted to access column " + I2S(index) + " in " + I2S(m.getRowCount()) + "x" + I2S(m.getColumnCount()) + " matrix.")
    endmethod
    
    method operator size takes nothing returns integer
        return .elements.size
    endmethod
    
    private method onDestroy takes nothing returns nothing
        call .elements.destroy()
    endmethod
endstruct

private type MatrixRowArray extends MatrixRow array [MAX_ROW_COUNT]

struct Matrix
    private MatrixRowArray rows
    private integer rowN
    private integer columnN
    
    static method create takes integer rowCount, integer columnCount returns Matrix
        local Matrix this = Matrix.allocate()
        local integer i = 0
        
        set this.rows = MatrixRowArray.create()
        loop
            exitwhen (i >= rowCount)
            set this.rows[i] = MatrixRow.create(this, columnCount)
            set i = i + 1
        endloop
        set this.rowN = rowCount
        set this.columnN = columnCount
        
        return this
    endmethod
    
    method operator [] takes integer index returns MatrixRow
        if (index > 0 and index <= .getRowCount()) then
            return .rows[index - 1]
        endif
        debug call BJDebugMsg("Index out of bounds: Attempted to access row " + I2S(index) + " in " + I2S(.getRowCount()) + "x" + I2S(.getColumnCount()) + " matrix.")
        return 0
    endmethod
    
    method getRowCount takes nothing returns integer
        return .rowN
    endmethod
    
    method getColumnCount takes nothing returns integer
        return .columnN
    endmethod
    
    method transpose takes nothing returns Matrix
        local Matrix new = Matrix.create(.getColumnCount(), .getRowCount())
        local integer i = 1
        local integer j
        
        loop
            exitwhen (i > .getRowCount())
            set j = 1
            loop
                exitwhen (j > .getColumnCount())
                set new[j][i] = this[i][j]
                set j = j + 1
            endloop
            set i = i + 1
        endloop
        return new
    endmethod
    
    method add takes Matrix other returns Matrix
        local integer i = 1
        local integer j
        
        if (.getRowCount() == other.getRowCount() and .getColumnCount() == other.getColumnCount()) then
            loop
                exitwhen (i > .getRowCount())
                set j = 1
                loop
                    exitwhen (j > .getColumnCount())
                    set this[i][j] = this[i][j] + other[i][j]
                    set j = j + 1
                endloop
                set i = i + 1
            endloop
        else
            debug call BJDebugMsg("Error: Attempted to add " + I2S(.getRowCount()) + "x" + I2S(.getColumnCount()) + " matrix by " + I2S(other.getRowCount()) + "x" + I2S(other.getColumnCount()) + " matrix.")
        endif
        return this
    endmethod
    
    method plus takes Matrix other returns Matrix
        local Matrix new = 0
        local integer i = 1
        local integer j
        
        if (.getRowCount() == other.getRowCount() and .getColumnCount() == other.getColumnCount()) then
            set new = Matrix.create(.getRowCount(), .getColumnCount())
            loop
                exitwhen (i > .getRowCount())
                set j = 1
                loop
                    exitwhen (j > .getColumnCount())
                    set new[i][j] = this[i][j] + other[i][j]
                    set j = j + 1
                endloop
                set i = i + 1
            endloop
        else
            debug call BJDebugMsg("Error: Attempted to add " + I2S(.getRowCount()) + "x" + I2S(.getColumnCount()) + " matrix by " + I2S(other.getRowCount()) + "x" + I2S(other.getColumnCount()) + " matrix.")
        endif
        return new
    endmethod
    
    method subtract takes Matrix other returns Matrix
        local integer i = 1
        local integer j
        
        if (.getRowCount() == other.getRowCount() and .getColumnCount() == other.getColumnCount()) then
            loop
                exitwhen (i > .getRowCount())
                set j = 1
                loop
                    exitwhen (j > .getColumnCount())
                    set this[i][j] = this[i][j] - other[i][j]
                    set j = j + 1
                endloop
                set i = i + 1
            endloop
        else
            debug call BJDebugMsg("Error: Attempted to subtract " + I2S(.getRowCount()) + "x" + I2S(.getColumnCount()) + " matrix by " + I2S(other.getRowCount()) + "x" + I2S(other.getColumnCount()) + " matrix.")
        endif
        return this
    endmethod
    
    method minus takes Matrix other returns Matrix
        local Matrix new = 0
        local integer i = 1
        local integer j
        
        if (.getRowCount() == other.getRowCount() and .getColumnCount() == other.getColumnCount()) then
            set new = Matrix.create(.getRowCount(), .getColumnCount())
            loop
                exitwhen (i > .getRowCount())
                set j = 1
                loop
                    exitwhen (j > .getColumnCount())
                    set new[i][j] = this[i][j] - other[i][j]
                    set j = j + 1
                endloop
                set i = i + 1
            endloop
        else
            debug call BJDebugMsg("Error: Attempted to subtract " + I2S(.getRowCount()) + "x" + I2S(.getColumnCount()) + " matrix by " + I2S(other.getRowCount()) + "x" + I2S(other.getColumnCount()) + " matrix.")
        endif
        return new
    endmethod
    
    method multiply takes real r returns Matrix
        local integer i = 1
        local integer j
        
        loop
            exitwhen (i > .getRowCount())
            set j = 1
            loop
                exitwhen (j > .getColumnCount())
                set this[i][j] = this[i][j] * r
                set j = j + 1
            endloop
            set i = i + 1
        endloop
        return this
    endmethod
    
    method times takes real r returns Matrix
        local Matrix new = Matrix.create(.getRowCount(), .getColumnCount())
        local integer i = 1
        local integer j
        
        loop
            exitwhen (i > .getRowCount())
            set j = 1
            loop
                exitwhen (j > .getColumnCount())
                set new[i][j] = this[i][j] * r
                set j = j + 1
            endloop
            set i = i + 1
        endloop
        return new
    endmethod
    
    method product takes Matrix other returns Matrix
        local Matrix new = 0
        local integer i = 1
        local integer j
        local integer k
        local real sum
        
        if (.getColumnCount() == other.getRowCount()) then
            set new = Matrix.create(.getRowCount(), other.getColumnCount())
            loop
                exitwhen (i > new.getRowCount())
                set j = 1
                loop
                    exitwhen (j > new.getColumnCount())
                    set sum = 0
                    set k = 1
                    loop
                        exitwhen (k > .getColumnCount())
                        set sum = sum + this[i][k] * other[k][j]
                        set k = k + 1
                    endloop
                    set new[i][j] = sum
                    set j = j + 1
                endloop
                set i = i + 1
            endloop
        else
            debug call BJDebugMsg("Error: Attempted to multiply " + I2S(.getRowCount()) + "x" + I2S(.getColumnCount()) + " matrix by " + I2S(other.getRowCount()) + "x" + I2S(other.getColumnCount()) + " matrix.")
        endif
        return new
    endmethod
    
    method determinant takes nothing returns real
        local integer k = 1
        local integer i
        local integer j
        local integer j2
        local integer switch = 1
        local real det = 0
        local Matrix m
        
        if (.getRowCount() == .getColumnCount()) then
            if (.getRowCount() == 2) then
                return this[1][1] * this[2][2] - this[2][1] * this[1][2]
            endif
            
            loop
                exitwhen (k > .getColumnCount())

                set j2 = 1
                set m = Matrix.create(.getRowCount() - 1, .getColumnCount() - 1)
                set j = 1
                loop
                    exitwhen (j > .getColumnCount())
                    
                    if (j != k) then
                        set i = 2
                        loop
                            exitwhen (i > .getRowCount())
                            set m[i - 1][j2] = this[i][j]
                            set i = i + 1
                        endloop
                        set j2 = j2 + 1
                    endif
                    
                    set j = j + 1
                endloop

                set det = det + switch * this[1][k] * m.determinant()
                set switch = switch * -1
                call m.destroy()

                set k = k + 1
            endloop
            return det
        endif
        debug call BJDebugMsg("Error: attempted to find the determinant of " + I2S(.getRowCount()) + "x" + I2S(.getColumnCount()) + " matrix.")
        return 0.0
    endmethod
    
    method copy takes nothing returns Matrix
        local Matrix new = Matrix.create(.getRowCount(), .getColumnCount())
        local integer i = 1
        local integer j
        
        loop
            exitwhen (i > .getRowCount())
            set j = 1
            loop
                exitwhen (j > .getColumnCount())
                set new[i][j] = this[i][j]
                set j = j + 1
            endloop
            set i = i + 1
        endloop
        return new
    endmethod
    
    method print takes nothing returns nothing
        local string s
        local integer i = 1
        local integer j
        
        call BJDebugMsg("[[")
        loop
            exitwhen (i > .getRowCount())
            set s = ""
            set j = 1
            loop
                exitwhen (j > .getColumnCount())
                set s = s + R2S(this[i][j]) + " "
                set j = j + 1
            endloop
            call BJDebugMsg(s)
            set i = i + 1
        endloop
        call BJDebugMsg("]]")
    endmethod
    
    private method onDestroy takes nothing returns nothing
        local integer i = 0
        loop
            exitwhen (i > .getRowCount())
            call .rows[i].destroy()
            set i = i + 1
        endloop
        call .rows.destroy()
    endmethod
endstruct

struct Vector
    private Matrix m
    
    static method create takes integer dimension returns Vector
        local Vector this = Vector.allocate()
        set this.m = Matrix.create(dimension, 1)
        return this
    endmethod
    
    method operator [] takes integer index returns real
        return .m[index][1]
    endmethod
    
    method operator []= takes integer index, real r returns nothing
        set .m[index][1] = r
    endmethod
    
    method getDimension takes nothing returns integer
        return .m.getRowCount()
    endmethod
    
    method add takes Vector other returns Vector
        call .m.add(other.m)
        return this
    endmethod
    
    method plus takes Vector other returns Vector
        if (.getDimension() == other.getDimension()) then
            return .copy().add(other)
        endif
        return 0
    endmethod
    
    method subtract takes Vector other returns Vector
        call .m.subtract(other.m)
        return this
    endmethod
    
    method minus takes Vector other returns Vector
        if (.getDimension() == other.getDimension()) then
            return .copy().subtract(other)
        endif
        return 0
    endmethod
    
    method multiply takes real r returns Vector
        call .m.multiply(r)
        return this
    endmethod
    
    method times takes real r returns Vector
        return .copy().multiply(r)
    endmethod
    
    method innerProduct takes Vector other returns real
        local Matrix transpose
        local Matrix product
        local real r
        
        if (.getDimension() == other.getDimension()) then
            set transpose = .m.transpose()
            set product = transpose.product(other.m)
            set r = product[1][1]
            call transpose.destroy()
            call product.destroy()
            return r
        endif
        debug call BJDebugMsg("Error: Attempted to compute inner product of " + I2S(.getDimension()) + "dimensional vector and " + I2S(other.getDimension()) + "dimensional vector.")
        return 0.0
    endmethod
    
    method outerProduct takes Vector other returns Matrix
        local Matrix transpose
        local Matrix product
        
        if (.getDimension() == other.getDimension()) then
            set transpose = other.m.transpose()
            set product = .m.product(transpose)
            call transpose.destroy()
            return product
        endif
        debug call BJDebugMsg("Error: Attempted to compute outer product of " + I2S(.getDimension()) + "dimensional vector and " + I2S(other.getDimension()) + "dimensional vector.")
        return 0
    endmethod
    
    method copy takes nothing returns Vector
        local Vector new = Vector.create(.getDimension())
        local integer i = 1
        
        loop
            exitwhen (i > .getDimension())
            set new[i] = this[i]
            set i = i + 1
        endloop
        return new
    endmethod
    
    method print takes nothing returns nothing
        local string s = "[ "
        local integer i = 1
        
        loop
            exitwhen (i > .getDimension())
            set s = s + R2S(this[i]) + " "
            set i = i + 1
        endloop
        call BJDebugMsg(s + "]")
    endmethod
    
    static method crossProduct takes Vector v1, Vector v2 returns Vector
        local Vector product
        
        if (v1.getDimension() == v2.getDimension() and v1.getDimension() == 3) then
            set product = Vector.create(v1.getDimension())
            set product[1] = v1[2] * v2[3] - v1[3] * v2[2]
            set product[2] = v1[3] * v2[1] - v1[1] * v2[3]
            set product[3] = v1[1] * v2[2] - v1[2] * v2[1]
            return product
        endif
        debug call BJDebugMsg("Error: Attempted to compute cross product of " + I2S(.getDimension()) + "dimensional vector and " + I2S(other.getDimension()) + "dimensional vector.")
        return 0
    endmethod
endstruct

endlibrary
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
JASS:
    method multMatrix takes mat3 m returns mat3
        local mat3 ret = mat3.create()
 
        local integer row = 0
        local integer col = 0
 
        loop
            exitwhen row == 3
 
            loop
                exitwhen col == 3
 
                set ret.m[row][col] = .m[row][0] * m.m[0][col] + .m[row][1] * m.m[1][col] + .m[row][2] * m.m[2][col]
 
                set col = col + 1
            endloop
 
            set row = row + 1
        endloop
 
        return ret
    endmethod

You forgot to set 'col' to 0 again,, And you wrote 'const' instead of 'constant'
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Quote:
Originally Posted by Yixx View Post
You forgot to set 'col' to 0 again
Didn't get that one.

JASS:
loop
                exitwhen col == 3

It'd only do 1 row

JASS:
        loop
            exitwhen row == 3
            //if col isn't set to 0, it comes back in at 3 here..
            loop
                exitwhen col == 3 //see, instant exit

                set ret.m[row][col] = .m[row][0] * m.m[0][col] + .m[row][1] * m.m[1][col] + .m[row][2] * m.m[2][col]

                set col = col + 1
            endloop

            set row = row + 1
            //set col = 0??
        endloop

See, Yixx is smert ^^.
 
Level 11
Joined
Feb 22, 2006
Messages
752
Better than 7 decimal places actually. And why are all of you making such a big deal about whether he uses his own PI constant? Is bj_PI really that sacred?

BUT...if you're going to redefine pi, I'd rather see PI defined as

JASS:
constant real PI = 3.14159265

That way jasshelper inlines a literal instead of a function with an arithmetic expression.

And using structs as the array members is just...over kill.

Only way I could overload the second array get/array set operators.
 
Level 9
Joined
Mar 25, 2005
Messages
252
The question is "does it matter?".

It never was. I was talking about a perfectionist, and my only intention was to point out that there is a reason why someone might want to use his own PI constant, other than that he doesn't know that bj_PI exists. Whether or not you think it's precision is enough has nothing to do with what you said it in response to, unless you can speak generally for all perfectionists in the world.


PS: bj_PI has well enough precision for me.
 
Level 8
Joined
Oct 3, 2008
Messages
367
Unless this code is properly encapsuled within a library and the documentation is properly placed at the top of the script, I'm going to have to graveyard this.

EDIT:

Graveyarded. The author will sadly not be fixing this.
 
Last edited:
Top