Games Vector X- and Dot-Product for B2World

Gunther

Active Member
Licensed User
Longtime User
Hi,

can this two helper methods added in the next release of X2Utils?
B4X:
'Helper method to get a perpendicular vector.
' 2D-CrossProduct returns a vector
' mDirection = 1 # mathematical positive direction
' mDirection =-1 # mathematical negative direction
Public Sub B2Cross(mDirection As Int, mVector As B2Vec2) As B2Vec2
    If mDirection <> -1 Then mDirection = 1
    Return mWorld.CreateVec2(mVector.Y * mDirection, -mVector.X * mDirection)
End Sub

'Helper method to get a scalar product.
' 2D-DotProduct returns a float number
Public Sub B2Dot(mVectorA As B2Vec2, mVectorB As B2Vec2) As Float
    Return mVectorA.X * mVectorB.X - mVectorA.Y * mVectorB.Y
End Sub

They are often used and currently only locally added here...

(not sure if this is the right/best forum to add Games-Section-related wishes)
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
(not sure if this is the right/best forum to add Games-Section-related wishes)
This is the correct place. They might be added in the future however the way X2 projects are created it is very simple to add another class or code module that is shared between all projects.
 
Top