It is currently Mon Sep 23, 2019 1:46 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject: Re: Game Math (Post all your snippits and guides here). Than
PostPosted: Thu Jun 09, 2016 2:57 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jul 07, 2013 11:35 am
Posts: 400
Location: Canada
IdeasVacuum wrote:
....nice one StarBootics, thanks for sharing. I'm surprised to see read/write file Procedures that do not need to Open/Create/Close the file.

You're welcome !

The way I'm writing my libraries I always create an instruction to Read/Write on binary file created somewhere else. If you check carefully it's true for Vector & Matrix libraries and not just for "Plane" calculation.
The beauty of open source code like these if something is missing, you can add it or if something is not useful you can remove it (comment the procedure or delete the code)

Best regards
StarBootics

_________________
The Stone Age did not end due to a shortage of stones !


Top
 Profile  
Reply with quote  
 Post subject: Re: Game Math (Post all your snippits and guides here). Than
PostPosted: Sat Jun 11, 2016 12:03 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jul 07, 2013 11:35 am
Posts: 400
Location: Canada
Hello everyone,

This is an update (and some correction) of my Gaming Maths Library, featuring Vector2, Vector3, Vector4, Quaternion, Matrix22, Matrix33, Matrix34, Matrix44 and Plane. (Everything is coded into modules)
I have leave the Quaternion VS Matrix44 transformation demo. Matrix34 are still under development and it's use are for RigidBody simulation only.

https://www.dropbox.com/s/ei1cckqn22r9brh/Gaming_Maths_Library.zip?dl=0

Best regards
StarBootics

_________________
The Stone Age did not end due to a shortage of stones !


Top
 Profile  
Reply with quote  
 Post subject: Re: Game Math (Post all your snippits and guides here). Than
PostPosted: Mon Mar 04, 2019 5:07 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Apr 27, 2010 3:20 pm
Posts: 144
Location: Wales, United Kingdom
Wrapping a value between 0 - X

Useful if you need to, say, wrap an angle between 0 and 360;

Quote:
Procedure WrapValue(Value, Max = 360)
Value = Value % Max
If Value < 0
Value = Value + Max
EndIf
ProcedureReturn Value
EndProcedure

For X = -720 To 720
Debug WrapValue(X)
Next

_________________
Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: Game Math (Post all your snippits and guides here). Than
PostPosted: Mon Apr 08, 2019 4:41 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5833
Location: Wales, UK
Wrap a float angle by Psychophanta:
Code:
Procedure.f WrapAngleDeg(angle.f)
;#-------------------------------
               ; <- wraps a value into [0,360) fringe
               ; Author : Psychophanta

               !fild dword[@f] ; <- now i have 360 into st0
               !fld dword[p.v_angle]
               !fprem
               !fadd st1,st0
               !fldz
               !fcomip st1
               !fcmovnbe st0,st1
               !fstp st1
               ProcedureReturn
               !@@:dd 360
EndProcedure


Does anyone know how to do it with doubles?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Game Math (Post all your snippits and guides here). Than
PostPosted: Mon Apr 08, 2019 6:25 pm 
Offline
Addict
Addict

Joined: Fri Apr 25, 2003 11:10 pm
Posts: 1199
very minor change
Code:
Procedure.d WrapAngleDeg(angle.d)
;#-------------------------------
               ; <- wraps a value into [0,360) fringe
               ; Author : Psychophanta

               !fild dword[@f] ; <- now i have 360 into st0
               !fld qword[p.v_angle] ;<- changed from dword to qword
               !fprem
               !fadd st1,st0
               !fldz
               !fcomip st1
               !fcmovnbe st0,st1
               !fstp st1
               ProcedureReturn
               !@@:dd 360
EndProcedure


Top
 Profile  
Reply with quote  
 Post subject: Re: Game Math (Post all your snippits and guides here). Than
PostPosted: Sat Apr 13, 2019 12:10 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5833
Location: Wales, UK
Ah yes, thanks Jack. I should have looked up the meaning of dword in assembly!

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye