News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

64Bit Floating Point Math Library for PlayBASIC (Dev Blog)

Started by kevin, July 20, 2020, 08:31:54 AM

Previous topic - Next topic

kevin


     PlayBASIC Math64  - IF / ENDIF block statements


      Trying to pick this up after about a month away from the keyboard is an interesting challenge and if tonight is anything to go by,  it's not going well :)   - Thus far I've added the IF / ENDIF parsing and code generation but when I test it it hangs..    Been picking through it but can't quite put my finger on the issue at this time. 

      We'll try again when i'm not so tired i guess. 

kevin

  PlayBASIC Math64  - IF / ENDIF block statements #2

     Fired up the project the other night and discovered the initial problem that was preventing the IF / ENDIF parsing and code generation from working, which turned out to be a missing break.   Ya get that..   Then manged to ran into a bit of odd logic problem, but that's been located and easily fixed now too.  

     So all this means is there's now ability to make decisions within the script.  ELSE is missing for the time being, but i'll have to drop that in next time.  



---[ Source Code ] ---------------------------------------------------
Var A,B,C,D,E
VaR Result,s,count
VaR CopyOfResult
A=50+50
B = (A=100.0)
if C<>0
 C=123.456
endif
if D=0 and B=1
    D=123456.678
endif
if D>1000
   if B=1
     E=5544.11
   endif
endif




Becomes the folowing byte code..    There's a couple of things could be tweaked, but i'll get over it.





---[ BYTE CODE VIEW ]---------------------------------

#0>> Move Value [0] = [$00000000$40590000]Val=100.0
#16>> CMP [1] = [0] = [9]
#32>> CMP [10] = [2] <> [11]
#48>>  CMP_BOZ [10] = 0  -> BRANCH 76
#60>> Move Value [2] = [$1A9FBE77$405EDD2F]Val=123.45
#76>> CMP [10] = [3] = [11]
#92>> CMP [13] = [1] = [12]
#108>> AND [14] = [10] & [13]
#124>>  CMP_BOZ [14] = 0  -> BRANCH 152
#136>> Move Value [3] = [$D916872B$40FE240A]Val=123456.67
#152>> CMP [10] = [3] > [15]
#168>>  CMP_BOZ [10] = 0  -> BRANCH 224
#180>> CMP [10] = [1] = [12]
#196>>  CMP_BOZ [10] = 0  -> BRANCH 224
#208>> Move Value [4] = [$28F5C28F$40B5A81C]Val=5544.109999999999
#224>> END






kevin


   PlayBASIC Math64  - IF / ELSE / ENDIF block statements

        So dropped in parsing and instruction support so that the scripts can be include ELSE path ways in the output code.   I guess we should add and ElseIF statement too which is basically slightly tweaked IF parser.  The main thing missing is ERRORs from the library,  which I think i'll just embedd a test hash rather than a numeric error code.  So the library will that there's an parsing error, but return a string.   I dunno..





---[ Source Code ] ---------------------------------------------------
Var A,B,C,D,E,F
VaR Result,s,count
VaR CopyOfResult
if D<1000
     E=1
   else
     E=2
endif
if D>1000
     F=1
   else
     F=2
endif

Error Status:0  $00000000




  Byte code




---[ BYTE CODE VIEW ]---------------------------------

#0>> CMP [11] = [3] < [10]
#16>>  CMP_BOZ [11] = 0  -> BRANCH 52
#28>> Move Value [4] = [$00000000$3FF00000]Val=1.0
#44>>  JMP REAL  -> BRANCH 68
#52>> Move Value [4] = [$00000000$40000000]Val=2.0
#68>> CMP [11] = [3] > [10]
#84>>  CMP_BOZ [11] = 0  -> BRANCH 120
#96>> Move Value [5] = [$00000000$3FF00000]Val=1.0
#112>>  JMP REAL  -> BRANCH 136
#120>> Move Value [5] = [$00000000$40000000]Val=2.0
#136>> END



kevin


PlayBASIC Live -  PB Math64  - Status Update #3 - Adding IF ELSE ENDIF LOGIC  (2020-10-31)


   Today we take a look at the latest changes to the Math64 library for PlayBASIC.   Since  last update the main changes would have to the be the addition of the IF/ELSE/ENDIF control statements.  Allowing your script to make decisions and act upon them. 


kevin

  PlayBASIC Math64  V003 - Public Test  (2020-11-01)

       Here's the third release of the Math64 library.  In this one we've added support for the IF / ELSE / ENDIF decisions.

       Here's the sample code that is build within the project.   You can import your own of course, but that's up to you.



Var A,B,C,D,E,F
VaR Result,s,count
VaR CopyOfResult
if D<1000
    E=1
  else
    E=2
endif
if D>1000
    F=1
  else
    F=2
endif



      Note: the project is being built using PlayBASIC V1.65,  but you should be able to get it running from V1.64P  editions or older.  (untested)



  Video:

 




  Download
 
     Attached

kevin


  PlayBASIC Math64  - ERROR MESSAGES /  COMMENTS & COPYTO / COPYFROM Variables


        I've had the morning off of sorts and have used that time to improve the library one more step, with the addition of come group copying functions that allow us to copy variables from the PLAYBASIC side to the math64 side.  These take the form of some CopyTOVariable and CopyFromVariable functions.  There's a few editions of them but basically you tag the variable in the script you watch to copy to or from and the location in memory where it should read or write.        So what you'll do is write a structure on the PlayBASIC side and then and then mirror that structure on the script side. 


         Example:



  //   PlayBASIC code
      type tParticle
          Status#
          X#,Y#
          Xspeed#,ySpeed#
      endtype



   // Script would have these declared as variables

        var  Status,x,y,xspeed,yspeed




     So setup the script we use the CopyToVariables function to copy the 5 fields in the script, then once the script is over,  we use the CopyFromVariables function to get them back.   This gives us less interactions and less hands on conversion, but does place the onus on the user (YOU) to make sure both sides variables are in the correct order and data type. 


kevin

 PlayBASIC Math64  V004 - Public Test  (2020-11-26)


      Here's revision 4 of the library, this one includes support for comments , Basic Error Messages and group variable copying.





  PlayBASIC LIVE -  Math64   STATUS -  Adding ERRORS & COPY FUNCTIONS and VECTORS ? (2020-11-26)

 



     Also See->  Vector Stacks (login required)





  Download
 
     Attached.

kevin

 PlayBASIC Math64  - Adding support for Vector2 / Vector3 and Vector4



     So while on the way to somewhere else this apparently happened..   The current build only parses the declaration and classifies them in the variable stack, but we can't access the fields nor does it have any code generation for the operations between vectors.  But  

     Bellow is the current status of the Vector example, hardly all that interesting.  



//  -------------------------------------------------
//  -----------[ VEcTOR EXAMPLE ]--------------------
//  -------------------------------------------------


var A,B,C,D,E

vector2  Pos, Speed




      One of the barriers for entry to adding more data types, is the whole thing was based around there only being one data type, 64bit floats,  thus this has to fit with the defined limitations of what i already have.  So vectors are also 64bit.

      You can think of your program as defining a TYPE in PlayBASIC actually, so the fields all stack up on top of each other,  there's one limitation is fields need to be 64bits wide, all of them.  So even if I added a BYTE / WORD / FLOAT32 type they'd take 64bits in this design.  So we'll just suck it up for the time being, but I don't foresee this being a show stopper.  


      This also means that variables are single instance,  So you can't have a variable called POS and a Vector called POS, it'll give you a syntax error for the time being but ideally it'll pop a redefined error.  

     The trick is going to be how we access the fields within a vector.  In PlayBASIC when a type is declared, it creates a list of the potential expanded field names,  but we might just be able to to detect these during expression evaluation and output them as normal variables.   Both have up and down sides,  I think i'll try the latter first.   If it causes some dumb issue down the road, then i'll have to suck it up and put on my big boy pants and do it correctly, whatever that means.

        So now the questions,  what FUNCTIONS would be handy when dealing with VECTORS ??
 



kevin

A little over and hour and the Math64 Parser thinks we have Vectors2/3 & 4...  well, it can parse and generate the simple code to read the fields bellow.


var A,B,C,D,E

vector2  Pos, Speed

A = pos.x + pos.y


All that for a this




---[ BYTE CODE VIEW ]---------------------------------

#0>> Add [0] = [5] + [6]
#16>> END

---[ VARIABLE DEFINES TABLE ]---------------------------------

#0=A   Type:1 -  Stack:0 -  Hash:$01000041 -  StringOffset:16-1 -
#1=B   Type:1 -  Stack:1 -  Hash:$01000042 -  StringOffset:18-1 -
#2=C   Type:1 -  Stack:2 -  Hash:$01000043 -  StringOffset:20-1 -
#3=D   Type:1 -  Stack:3 -  Hash:$01000044 -  StringOffset:22-1 -
#4=E   Type:1 -  Stack:4 -  Hash:$01000045 -  StringOffset:24-1 -
#5=Pos   Type:1 -  Stack:5 -  Hash:$030000F2 -  StringOffset:26-3 -
#6=Speed   Type:1 -  Stack:7 -  Hash:$05000171 -  StringOffset:30-5 -



kevin

   Couple of sessions later and it actually has working Vector2 support, managed to run into one of those structure unbalanced issues today, so lost most of my free time chasing my own tail, only to then realize that the C compiler was padding a structure.  This causes problems because PlayBASIC doesn't do this,  so even though the fields are the same, the C back end thinks variable table structure was 40 bytes wide, when only 36 bytes are in use..   what joy !  Meaning it'd crash.


   Bellow we have our junk test, the expression side is being evaluated but the result vector isn't being written out as yet..   Tomorrow

 




//  -------------------------------------------------
//  -----------[ VEcTOR EXAMPLE ]--------------------
//  -------------------------------------------------


var A,B,C,D,E

vector2  Pos, Speed

//A = pos.x + pos.y

     // This expression doesn't make any sense, but the parser currently allows it
A = pos + Speed







   and here's the output.




---[ VARIABLE DEFINES TABLE ]---------------------------------

Variables:8
#0=A   Class:1 - Class:2 -  Stack:0 -  Hash:$01000041 -  StringOffset:16-1 -
#1=B   Class:1 - Class:2 -  Stack:1 -  Hash:$01000042 -  StringOffset:18-1 -
#2=C   Class:1 - Class:2 -  Stack:2 -  Hash:$01000043 -  StringOffset:20-1 -
#3=D   Class:1 - Class:2 -  Stack:3 -  Hash:$01000044 -  StringOffset:22-1 -
#4=E   Class:1 - Class:2 -  Stack:4 -  Hash:$01000045 -  StringOffset:24-1 -
#5=Pos   Class:1 - Class:100 -  Stack:5 -  Hash:$030000F2 -  StringOffset:26-3 -
#6=Speed   Class:1 - Class:100 -  Stack:7 -  Hash:$05000171 -  StringOffset:30-5 -
#7=~TEMP0000   Class:1 - Class:100 -  Stack:9 -  Hash:$09000274 -  StringOffset:36-9 -



---[ BYTE CODE VIEW ]---------------------------------

#0>> Add [9].Vector2 = [5].Vector2 + [7].Vector2
#16>> END

 


    Notice the  Add [9].Vector2 = [5].Vector2 + [7].Vector2  instruction with does the addition. 

kevin

PlayBASIC LIVE:  PB Math64  -  Adding VECTORS  (2020-12-07)


  Here's the latest addition to Math64 library VECTORS








   Download
 
      Attached.

kevin



  PlayBASIC LIVE:  PB Math64  -  Adding VECTORS  (2020-12-09)


     Continuing on from the post above, I ended up biting the bullet and implementing the VECTOR support in the parser allowing for the fields to be not only read, but written to..   The initial version was a hack and this creates the fields as individual variables in the stack, so accessing a field within a VECTOR is the same as a VARIABLE.


     Next problem is going to be how to handle Functions for Vectors.  Initially I think we'll end up with copies of various function for the particular data type,  as internally it has no way of understanding what fields are what.   Remember this was only ever meant to use a single data type..  So were breaking out our rules here.     I actually think that have different functions names for function isn't the end of the world, but if I can implementing sometype of simple overloading I'll see about shoving it in later on.       





--[ Source Code ] ---------------------------------------------------

//  -------------------------------------------------
//  -----------[ VEcTOR EXAMPLE ]--------------------
//  -------------------------------------------------


var A,B,C,D,E

vector2  Pos, Speed

speed.x = 100
speed.y = 220

speed.x = 1111

a = Speed.X

pos = pos + Speed
pos = pos - Speed
pos = pos * Speed
pos = pos / Speed






---[ End Of Source Code ] ---------------------------------------------------
Error  Status:0  $00000000
Error Message:


---[ VARIABLE DEFINES TABLE ]---------------------------------

Variables:14
#0=A   Class:1 - Class:2 -  Stack:0 -  Hash:$01000041 -  StringOffset:16-1 -
#1=B   Class:1 - Class:2 -  Stack:1 -  Hash:$01000042 -  StringOffset:18-1 -
#2=C   Class:1 - Class:2 -  Stack:2 -  Hash:$01000043 -  StringOffset:20-1 -
#3=D   Class:1 - Class:2 -  Stack:3 -  Hash:$01000044 -  StringOffset:22-1 -
#4=E   Class:1 - Class:2 -  Stack:4 -  Hash:$01000045 -  StringOffset:24-1 -
#5=Pos   Class:1 - Class:100 -  Stack:5 -  Hash:$030000F2 -  StringOffset:26-3 -
#6=Pos.X   Class:1 - Class:2 -  Stack:5 -  Hash:$05000178 -  StringOffset:30-5 -
#7=Pos.Y   Class:1 - Class:2 -  Stack:6 -  Hash:$05000179 -  StringOffset:36-5 -
#8=Speed   Class:1 - Class:100 -  Stack:7 -  Hash:$05000171 -  StringOffset:42-5 -
#9=Speed.X   Class:1 - Class:2 -  Stack:7 -  Hash:$070001F7 -  StringOffset:48-7 -
#10=Speed.Y   Class:1 - Class:2 -  Stack:8 -  Hash:$070001F8 -  StringOffset:56-7 -
#11=~TEMP0000   Class:1 - Class:100 -  Stack:9 -  Hash:$09000274 -  StringOffset:64-9 -
#12=~TEMP0000.X   Class:1 - Class:2 -  Stack:9 -  Hash:$0B0002FA -  StringOffset:74-11 -
#13=~TEMP0000.Y   Class:1 - Class:2 -  Stack:10 -  Hash:$0B0002FB -  StringOffset:86-11 -



---[ BYTE CODE VIEW ]---------------------------------

#0>> Move Value [7] = [$00000000$40590000]Val=100.0
#16>> Move Value [8] = [$00000000$406B8000]Val=220.0
#32>> Move Value [7] = [$00000000$40915C00]Val=1111.0
#48>> Move [0] = [7]
#60>> Add [9].Vector2 = [5].Vector2 + [7].Vector2
#76>> Copy [5] = [9]+ [2]
#92>> Sub [9].Vector2 = [5].Vector2 + [7].Vector2
#108>> Copy [5] = [9]+ [2]
#124>> Mult [9].Vector2 = [5].Vector2 + [7].Vector2
#140>> Copy [5] = [9]+ [2]
#156>> Div [9].Vector2 = [5].Vector2 + [7].Vector2
#172>> Copy [5] = [9]+ [2]
#188>> END



kevin

  PlayBASIC LIVE:  PB Math64  -  Adding Vector Functions (2020-12-12)


     So... I've been working on this today and have finally got it to a point where a function can be defined that returns a VECTOR2/3 or 4, then have function be parsed during expression evaluation and byte code generated and executed at runtime..    yay...  which is the life cycle of a function.   At this point it only supports one function GetNormalVector2D which is meant to accept a vector2 parameter and return the normal vector2d from it.   But it actually doesn't work due to the function parameter matching not understanding what a vector parameter is,  but you can pass a variable in it's place and it'll treat that variable and the one directly following it in the stack as a vector.   After all a vector2 is nothing more than pair of X/Y variables conceptually fussed together.  


    Here's a dump of the console output tonight..    The byte code still has some redundant operations regarding Vectors and at this point only Vector2 is mostly hooked up.  The other two should be a lot easier and then we'll see what you can get it to do.   




--[ Source Code ] ---------------------------------------------------

//  -------------------------------------------------
//  -----------[ VEcTOR EXAMPLE ]--------------------
//  -------------------------------------------------


var A,B,C,D,E

vector2  Pos, Speed

A = 100
B=200
C= A * B
speed.x = 1
speed.y = 2

a = Speed.X

pos = pos + Speed
pos = pos - Speed
pos = pos * Speed
pos = pos / Speed


a = cos(b)

a = 100
b=100
POS = GetVectorNormal2D(A)




---[ End Of Source Code ] ---------------------------------------------------
Error  Status:0  $00000000
Error Message:


---[ VARIABLE DEFINES TABLE ]---------------------------------

Variables:15
#0=A   Class:1 - Class:2 -  Stack:0 -  Hash:$01000041 -  StringOffset:16-1 -
#1=B   Class:1 - Class:2 -  Stack:1 -  Hash:$01000042 -  StringOffset:18-1 -
#2=C   Class:1 - Class:2 -  Stack:2 -  Hash:$01000043 -  StringOffset:20-1 -
#3=D   Class:1 - Class:2 -  Stack:3 -  Hash:$01000044 -  StringOffset:22-1 -
#4=E   Class:1 - Class:2 -  Stack:4 -  Hash:$01000045 -  StringOffset:24-1 -
#5=Pos   Class:1 - Class:100 -  Stack:5 -  Hash:$030000F2 -  StringOffset:26-3 -
#6=Pos.X   Class:1 - Class:2 -  Stack:5 -  Hash:$05000178 -  StringOffset:30-5 -
#7=Pos.Y   Class:1 - Class:2 -  Stack:6 -  Hash:$05000179 -  StringOffset:36-5 -
#8=Speed   Class:1 - Class:100 -  Stack:7 -  Hash:$05000171 -  StringOffset:42-5 -
#9=Speed.X   Class:1 - Class:2 -  Stack:7 -  Hash:$070001F7 -  StringOffset:48-7 -
#10=Speed.Y   Class:1 - Class:2 -  Stack:8 -  Hash:$070001F8 -  StringOffset:56-7 -
#11=~TEMP0000   Class:1 - Class:2 -  Stack:9 -  Hash:$09000274 -  StringOffset:64-9 -
#12=~VEC20000   Class:1 - Class:100 -  Stack:10 -  Hash:$0900024E -  StringOffset:74-9 -
#13=~VEC20000.X   Class:1 - Class:2 -  Stack:10 -  Hash:$0B0002D4 -  StringOffset:84-11 -
#14=~VEC20000.Y   Class:1 - Class:2 -  Stack:11 -  Hash:$0B0002D5 -  StringOffset:96-11 -



---[ BYTE CODE VIEW ]---------------------------------

#0>> Move Value [0] = [$00000000$40590000]Val=100.0
#16>> Move Value [1] = [$00000000$40690000]Val=200.0
#32>> MULT [2] = [0] * [1]
#48>> Move Value [7] = [$00000000$3FF00000]Val=1.0
#64>> Move Value [8] = [$00000000$40000000]Val=2.0
#80>> Move [0] = [7]
#92>> Add [10].Vector2 = [5].Vector2 + [7].Vector2
#108>> Copy [5] = [10]+ [2]
#124>> Sub [10].Vector2 = [5].Vector2 + [7].Vector2
#140>> Copy [5] = [10]+ [2]
#156>> Mult [10].Vector2 = [5].Vector2 + [7].Vector2
#172>> Copy [5] = [10]+ [2]
#188>> Div [10].Vector2 = [5].Vector2 + [7].Vector2
#204>> Copy [5] = [10]+ [2]
#220>> [0] = COS( [1])
#236>> Move Value [0] = [$00000000$40590000]Val=100.0
#252>> Move Value [1] = [$00000000$40590000]Val=100.0
#268>> [10] = GetNormal2D( [0])
#284>> Copy [5] = [10]+ [2]
#300>> END


---[ LAST EXPRESSION TABLE ]---------------------------------

#0  Token=1011 -  SrcIndex=105 -  Stack=10 -  LiteralData=$00000000$00000000


---[ EXECUTION  ]---------------------------------

   149 Ticks TO Execute [1000000] Times 
   20 Instructions in byte code
  Approx 134.2282 MILLION 64bit Opcodes Per Second


   91 Ticks - Read / Write Variable Result [1000000] Times 


0
---[ VARIABLES POINTER ]---------------------------------

[Result] Variable Ptr=0
[Result] Variable Flt=0.0


---[ VARIABLES ]---------------------------------

A=100.0
B=100.0
C=20000.0
D=0.0
E=0.0
Pos=0.7071067811865474
Pos.X=0.7071067811865474
Pos.Y=0.7071067811865474
Speed=1.0
Speed.X=1.0
Speed.Y=2.0
~TEMP0000=0.0
~VEC20000=0.7071067811865474
~VEC20000.X=0.7071067811865474
~VEC20000.Y=0.7071067811865474





kevin

PlayBASIC LIVE:  PB Math64  -  Adding VECTORS  (2020-12-14)


  Hey presto here's today's build of math64

  This one includes some very simple function support for VECTOR2 ..   Vector3 & 4 will parse, but there's nothing on the back end as yet to do such things..  

 
    Sample code


//  -------------------------------------------------
//  -----------[ VEcTOR EXAMPLE ]--------------------
//  -------------------------------------------------


var A,B,C,D,E, Size

vector2  Pos, Speed, SpeedNormal


A = 100
B=200
C= A * B
speed.x = 1
speed.y = 2

a = Speed.X

pos = pos + Speed
pos = pos - Speed
pos = pos * Speed
pos = pos / Speed


a = cos(b)


//  Compute normal from Speed vector
SpeedNormal = GetNormal2D(Speed)

//  get the length / size of this vector
Size = GetLength2D(Speed)


a = GetDotProduct2D(Pos,Speed)

// this is if a bit iffy in 2D
a = GetCrossProduct2D(Pos,Speed)

// ------------------------------------------------------
//  copy the normal vector to variables NX + NY
// ---------------------------------------------------------

// delcare a pair of variables
var nx,ny

// Set the speed vector
Speed.X = 200
Speed.Y = 100

// compute normal from Speed and write to NX and NY
Nx = getNormal2D(Speed)

// Compute normal and write result to the SpeedNormal vector
SpeedNormal = getNormal2D(Speed)





      Functions will accept almost anything which is a by product having no strict parameter matching.    Meaning you can pass a Variable in place of a vector, if you do this, it'll  treat that variable as the parent pointer and thus read/ write the fields from this address.    In the example above I'm testing this when retrieving the normal from the speed vector and writing it variable NX.    The function will copy over the NX variable as well as the NY variable declared after it.  




  Download
 
     Attached.

kevin

 PlayBASIC LIVE:  PB Math64  -  Adding VECTOR3  (2020-12-19)


    Just touching base really, as we've had some more progress with the library,  this time seeing the VECTOR3 support come to life..  

     Check out the debug dump bellow...  




---[ Source Code ] ---------------------------------------------------

//  -------------------------------------------------
//  -----------[ VEcTOR EXAMPLE ]--------------------
//  -------------------------------------------------


var A,B,C,D,E, Size

vector2  Pos, Speed, SpeedNormal


A = 100
B=200
C= A * B
speed.x = 1
speed.y = 2

a = Speed.X

pos = pos + Speed
pos = pos - Speed
pos = pos * Speed
pos = pos / Speed


a = cos(b)


//  Compute normal from Speed vector
SpeedNormal = GetNormal2D(Speed)

//  get the length / size of this vector
Size = GetLength2D(Speed)


a = GetDotProduct2D(Pos,Speed)

// this is if a bit iffy in 2D
a = GetCrossProduct2D(Pos,Speed)

// ------------------------------------------------------
//  copy the normal vector to variables NX + NY
// ---------------------------------------------------------

// delcare a pair of variables
var nx,ny

// Set the speed vector
Speed.X = 200
Speed.Y = 100

// compute normal from Speed and write to NX and NY
Nx = getNormal2D(Speed)

// Compute normal and write result to the SpeedNormal vector
SpeedNormal = getNormal2D(Speed)



// ------------------------------------------------------
//  TEST VECTOR3 OPERATIONS
// ---------------------------------------------------------

var DotProduct3
vector3 pos3, Speed3, Cross3, Normal3

pos3.x = 100
pos3.y = 200
pos3.z = 300

speed3.x = 1
speed3.y = 2
speed3.z = 3

pos3 = pos3 + Speed3
pos3 = pos3 * Speed3
pos3 = pos3 / Speed3
pos3 = pos3 - Speed3

//  
Size = GetLength3D(pos3)
dotProduct3 = GetDotProduct3d(pos3,speed3)
Cross3 = GetCrossProduct3d(pos3,speed3)
Normal3 = getNormal3D(pos3)



---[ End Of Source Code ] ---------------------------------------------------
Error  Status:0  $00000000
Error Message:


---[ VARIABLE DEFINES TABLE ]---------------------------------

Variables:42
#0=A   Class:1 - Class:2 -  Stack:0 -  Hash:$01000041 -  StringOffset:16-1 -
#1=B   Class:1 - Class:2 -  Stack:1 -  Hash:$01000042 -  StringOffset:18-1 -
#2=C   Class:1 - Class:2 -  Stack:2 -  Hash:$01000043 -  StringOffset:20-1 -
#3=D   Class:1 - Class:2 -  Stack:3 -  Hash:$01000044 -  StringOffset:22-1 -
#4=E   Class:1 - Class:2 -  Stack:4 -  Hash:$01000045 -  StringOffset:24-1 -
#5=Size   Class:1 - Class:2 -  Stack:5 -  Hash:$0400013B -  StringOffset:26-4 -
#6=Pos   Class:1 - Class:100 -  Stack:6 -  Hash:$030000F2 -  StringOffset:31-3 -
#7=Pos.X   Class:1 - Class:2 -  Stack:6 -  Hash:$05000178 -  StringOffset:35-5 -
#8=Pos.Y   Class:1 - Class:2 -  Stack:7 -  Hash:$05000179 -  StringOffset:41-5 -
#9=Speed   Class:1 - Class:100 -  Stack:8 -  Hash:$05000171 -  StringOffset:47-5 -
#10=Speed.X   Class:1 - Class:2 -  Stack:8 -  Hash:$070001F7 -  StringOffset:53-7 -
#11=Speed.Y   Class:1 - Class:2 -  Stack:9 -  Hash:$070001F8 -  StringOffset:61-7 -
#12=SpeedNormal   Class:1 - Class:100 -  Stack:10 -  Hash:$0B00033A -  StringOffset:69-11 -
#13=SpeedNormal.X   Class:1 - Class:2 -  Stack:10 -  Hash:$0D0003C0 -  StringOffset:81-13 -
#14=SpeedNormal.Y   Class:1 - Class:2 -  Stack:11 -  Hash:$0D0003C1 -  StringOffset:95-13 -
#15=~TEMP0000   Class:1 - Class:2 -  Stack:12 -  Hash:$09000274 -  StringOffset:109-9 -
#16=~VEC20000   Class:1 - Class:100 -  Stack:13 -  Hash:$0900024E -  StringOffset:119-9 -
#17=~VEC20000.X   Class:1 - Class:2 -  Stack:13 -  Hash:$0B0002D4 -  StringOffset:129-11 -
#18=~VEC20000.Y   Class:1 - Class:2 -  Stack:14 -  Hash:$0B0002D5 -  StringOffset:141-11 -
#19=nx   Class:1 - Class:2 -  Stack:15 -  Hash:$020000A6 -  StringOffset:153-2 -
#20=ny   Class:1 - Class:2 -  Stack:16 -  Hash:$020000A7 -  StringOffset:156-2 -
#21=DotProduct3   Class:1 - Class:2 -  Stack:17 -  Hash:$0B00033B -  StringOffset:159-11 -
#22=pos3   Class:1 - Class:101 -  Stack:18 -  Hash:$04000125 -  StringOffset:171-4 -
#23=pos3.X   Class:1 - Class:2 -  Stack:18 -  Hash:$060001AB -  StringOffset:176-6 -
#24=pos3.Y   Class:1 - Class:2 -  Stack:19 -  Hash:$060001AC -  StringOffset:183-6 -
#25=pos3.Z   Class:1 - Class:2 -  Stack:20 -  Hash:$060001AD -  StringOffset:190-6 -
#26=Speed3   Class:1 - Class:101 -  Stack:21 -  Hash:$060001A4 -  StringOffset:197-6 -
#27=Speed3.X   Class:1 - Class:2 -  Stack:21 -  Hash:$0800022A -  StringOffset:204-8 -
#28=Speed3.Y   Class:1 - Class:2 -  Stack:22 -  Hash:$0800022B -  StringOffset:213-8 -
#29=Speed3.Z   Class:1 - Class:2 -  Stack:23 -  Hash:$0800022C -  StringOffset:222-8 -
#30=Cross3   Class:1 - Class:101 -  Stack:24 -  Hash:$060001BD -  StringOffset:231-6 -
#31=Cross3.X   Class:1 - Class:2 -  Stack:24 -  Hash:$08000243 -  StringOffset:238-8 -
#32=Cross3.Y   Class:1 - Class:2 -  Stack:25 -  Hash:$08000244 -  StringOffset:247-8 -
#33=Cross3.Z   Class:1 - Class:2 -  Stack:26 -  Hash:$08000245 -  StringOffset:256-8 -
#34=Normal3   Class:1 - Class:101 -  Stack:27 -  Hash:$070001FC -  StringOffset:265-7 -
#35=Normal3.X   Class:1 - Class:2 -  Stack:27 -  Hash:$09000282 -  StringOffset:273-9 -
#36=Normal3.Y   Class:1 - Class:2 -  Stack:28 -  Hash:$09000283 -  StringOffset:283-9 -
#37=Normal3.Z   Class:1 - Class:2 -  Stack:29 -  Hash:$09000284 -  StringOffset:293-9 -
#38=~VEC30000   Class:1 - Class:101 -  Stack:30 -  Hash:$0900024F -  StringOffset:303-9 -
#39=~VEC30000.X   Class:1 - Class:2 -  Stack:30 -  Hash:$0B0002D5 -  StringOffset:313-11 -
#40=~VEC30000.Y   Class:1 - Class:2 -  Stack:31 -  Hash:$0B0002D6 -  StringOffset:325-11 -
#41=~VEC30000.Z   Class:1 - Class:2 -  Stack:32 -  Hash:$0B0002D7 -  StringOffset:337-11 -



---[ BYTE CODE VIEW ]---------------------------------

#0>> Move Value [0] = [$00000000$40590000]Val=100.0
#16>> Move Value [1] = [$00000000$40690000]Val=200.0
#32>> MULT [2] = [0] * [1]
#48>> Move Value [8] = [$00000000$3FF00000]Val=1.0
#64>> Move Value [9] = [$00000000$40000000]Val=2.0
#80>> Move [0] = [8]
#92>> Add [13].Vector2 = [6].Vector2 , [8].Vector2
#108>> Copy [6] = [13]+ [2]
#124>> Sub [13].Vector2 = [6].Vector2 , [8].Vector2
#140>> Copy [6] = [13]+ [2]
#156>> Mult [13].Vector2 = [6].Vector2 , [8].Vector2
#172>> Copy [6] = [13]+ [2]
#188>> Div [13].Vector2 = [6].Vector2 , [8].Vector2
#204>> Copy [6] = [13]+ [2]
#220>> [0] = COS( [1])
#236>> [13] = GetNormal2D( [8])
#252>> Copy [10] = [13]+ [2]
#268>> [5] = GetLength2D( [8])
#284>> [0] = GetDotProduct2D( [6],[8])
#304>> [0] = GetCrossProduct2D( [6],[8])
#324>> Move Value [8] = [$00000000$40690000]Val=200.0
#340>> Move Value [9] = [$00000000$40590000]Val=100.0
#356>> [13] = GetNormal2D( [8])
#372>> Copy [15] = [13]+ [2]
#388>> [13] = GetNormal2D( [8])
#404>> Copy [10] = [13]+ [2]
#420>> Move Value [18] = [$00000000$40590000]Val=100.0
#436>> Move Value [19] = [$00000000$40690000]Val=200.0
#452>> Move Value [20] = [$00000000$4072C000]Val=300.0
#468>> Move Value [21] = [$00000000$3FF00000]Val=1.0
#484>> Move Value [22] = [$00000000$40000000]Val=2.0
#500>> Move Value [23] = [$00000000$40080000]Val=3.0
#516>> Add [30].Vector3 = [18].Vector3 , [21].Vector3
#532>> Copy [18] = [30]+ [3]
#548>> Mult [30].Vector3 = [18].Vector3 , [21].Vector3
#564>> Copy [18] = [30]+ [3]
#580>> Div [30].Vector3 = [18].Vector3 , [21].Vector3
#596>> Copy [18] = [30]+ [3]
#612>> Sub [30].Vector3 = [18].Vector3 , [21].Vector3
#628>> Copy [18] = [30]+ [3]
#644>> [5] = GetLength3D( [18])
#660>> [17] = GetDotProduct3D( [18],[21])
#680>> [30] = GetCrossProduct3D( [18],[21])
#700>> Copy [24] = [30]+ [3]
#716>> [30] = GetNormal3D( [18])
#732>> Copy [27] = [30]+ [3]
#748>> END


---[ LAST EXPRESSION TABLE ]---------------------------------

#0  Token=1012 -  SrcIndex=308 -  Stack=30 -  LiteralData=$00000000$00000000


---[ EXECUTION  ]---------------------------------

  252 Ticks TO Execute [1000000] Times  
  47 Instructions in byte code
 Approx 186.5079 MILLION 64bit Opcodes Per Second


  129 Ticks - Read / Write Variable Result [1000000] Times  


0
---[ VARIABLES POINTER ]---------------------------------

[Result] Variable Ptr=0
[Result] Variable Flt=0.0


---[ VARIABLES ]---------------------------------

A=0.0
B=200.0
C=20000.0
D=0.0
E=0.0
Size=40700.0
Pos=0.0
Pos.X=0.0
Pos.Y=0.0
Speed=200.0
Speed.X=200.0
Speed.Y=100.0
SpeedNormal=0.8944271909999158
SpeedNormal.X=0.8944271909999158
SpeedNormal.Y=0.4472135954999579
~TEMP0000=0.0
~VEC20000=0.8944271909999158
~VEC20000.X=0.8944271909999158
~VEC20000.Y=0.4472135954999579
nx=0.8944271909999158
ny=0.4472135954999579
DotProduct3=1400.0
pos3=100.0
pos3.X=100.0
pos3.Y=200.0
pos3.Z=300.0
Speed3=1.0
Speed3.X=1.0
Speed3.Y=2.0
Speed3.Z=3.0
Cross3=0.0
Cross3.X=0.0
Cross3.Y=0.0
Cross3.Z=0.0
Normal3=0.4445542244743870
Normal3.X=0.4445542244743870
Normal3.Y=0.8891084489487740
Normal3.Z=1.333662673423161
~VEC30000=0.4445542244743870
~VEC30000.X=0.4445542244743870
~VEC30000.Y=0.8891084489487740
~VEC30000.Z=1.333662673423161






   252 Ticks TO Execute [1000000] Times  
  47 Instructions in byte code
 Approx 186.5079 MILLION 64bit Opcodes Per Second



PlayBASIC Math64  V007 - Public Test  (2020-12-19)

   Here's today WIP build which includes basic Vector2 and Vector3 support.

   if you have ideas for more functions/ operations, then the quickest way forward would be for you to write some examples and i'll just slot them in the best I can.


   Video

 





  Download
 
     Attached.