suggestion: math.mod
BlitzMax Forums/BlitzMax Module Tweaks/suggestion: math.mod
| ||
- GetDistance - GetAngle |
| ||
splines calculating stuff would be handy too... |
| ||
here's a start:Rem bbdoc: returns the distance between two points in 2D space about: return value is an absolute float EndRem Function GetDistance2D:Float(X1:Float, Y1:Float, X2:Float, Y2:Float) Local l1:float = Abs(x1-x2) Local l2:float = Abs(y1-y2) Return Sqr((l1*l1)+(l2*l2)) End Function Rem bbdoc: returns the distance between two points in 3D space about: return value is an absolute float EndRem Function GetDistance3D:Float(X1:Float, Y1:Float, Z1:Float, X2:Float, Y2:Float, Z2:Float) Local l1:float = Abs(x1-x2) Local l2:float = Abs(y1-y2) Local l3:float = Abs(z1-z2) Return Sqr((l1*l1)+(l2*l2)+(l3*l3)) End Function |
| ||
And here is something to get the 2d angle:Rem bbdoc: returns an angle between 0 and 360 degrees about: return value is an Float EndRem Function GetAngle2D:Float(X1:Float,Y1:Float,X2:Float,Y2:Float) local dx# = x2 - x1 local dy# = y2 - y1 Return ATAN2(dy#,dx#)+360) MOD 360 End Function |
| ||
Pert - why are you NOT using Floats/Doubles for your functions local variables? |
| ||
Friendly-friendly math code for peoples. |
| ||
Maybe this is wrong:Type Quat ... Method MultiplyQuat:Quat( i:Quat ) Local r:Quat = New Quat r.w = w*i.w - x*i.x - y*i.y - z*i.z r.w = w*i.x - x*i.w - y*i.z - z*i.y r.w = w*i.y - y*i.w - z*i.x - x*i.z r.w = w*i.z - z*i.w - x*i.y - y*i.x Return r End Method ... End TypeWhy to redefine the same variable 4 times? |
| ||
Woops, forgot to write all the diferent stuff in :P |
| ||
Thx dude I hope they will be official commands |