GetMatElement - What is the matrix size row/cols ?
Blitz3D Forums/Blitz3D Beginners Area/GetMatElement - What is the matrix size row/cols ?
| ||
hello, I'd like to know the size of the transformation matrix. What is the matrix size when using the function GetMatElement? 3x3, 4x4, 4x3, 3x4? The documentation says nothing about the number of columns and rows. sincerely |
| ||
Four rows and three columns. Technically I think there should be another column, but it never changes and can be ignored. It would be: 0 0 0 1 |
| ||
It trouble me. What is the official amount row/cols? |
| ||
. (comment removed) Last edited 2011 |
| ||
What does it mean ? |
| ||
I believe 4x4 is the default. |
| ||
hi, probably if you can read/decode the following you get an answer: http://blitzbasic.com/Community/posts.php?topic=42657 i have some functions (from sswift i think) that get the scale of an entity reading directly form this matrix: ; ------------------------------------------------------------------------------------------------------------------- ; This function returns the X axis scale of an entity, as set by ScaleEntity(). ; ------------------------------------------------------------------------------------------------------------------- Function EntityScaleX#(Entity) Local Scale#, X#, Y#, Z# X# = GetMatElement(Entity, 0, 0) Y# = GetMatElement(Entity, 0, 1) Z# = GetMatElement(Entity, 0, 2) Scale# = Sqr(X#*X# + Y#*Y# + Z#*Z#) Return Scale# End Function ; ------------------------------------------------------------------------------------------------------------------- ; This function returns the Y axis scale of an entity, as set by ScaleEntity(). ; ------------------------------------------------------------------------------------------------------------------- Function EntityScaleY#(Entity) Local Scale#, X#, Y#, Z# X# = GetMatElement(Entity, 1, 0) Y# = GetMatElement(Entity, 1, 1) Z# = GetMatElement(Entity, 1, 2) Scale# = Sqr(X#*X# + Y#*Y# + Z#*Z#) Return Scale# End Function ; ------------------------------------------------------------------------------------------------------------------- ; This function returns the Z axis scale of an entity, as set by ScaleEntity(). ; ------------------------------------------------------------------------------------------------------------------- Function EntityScaleZ#(Entity) Local Scale#, X#, Y#, Z# X# = GetMatElement(Entity, 2, 0) Y# = GetMatElement(Entity, 2, 1) Z# = GetMatElement(Entity, 2, 2) Scale# = Sqr(X#*X# + Y#*Y# + Z#*Z#) Return Scale# End Function doing some tests, aparently there are no restrictions made by GetMatElement in the row/col indexes..?? the following work but i didn't analize the correctness of this result: ; GetMatElement Example ; --------------------- Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,-5 light=CreateLight() RotateEntity light,90,0,0 ; Create sphere sphere=CreateSphere() ; Position, scale, rotate entity - try messing with these values to change GetMatElement value PositionEntity sphere,0.2,0.3,0.4 ScaleEntity sphere,1,2,3 RotateEntity sphere,0.5,10,30 For i=0 To 4 ;i think that obviously the matrix should be any thing between 3 or 4 but not 5! For j=0 To 4 Print i+", "+j+" : "+GetMatElement(sphere,i,j) Next Next WaitKey While Not KeyDown(1) RenderWorld Text 0,0,GetMatElement#(sphere,1,1) Flip Wend End hope that helps Juan |
| ||
Repeating my earlier comment (so you see it) because on second thoughts it's not offensive after all: There are four rows and three columns, numbered from zero. There doesn't appear to be any formal restriction on the numbers you can put in though, so using negative or too-great indices will probably give you unpredictable and useless data. For a full explanation, see the Transform class's source code, available here: http://www.blitzbasic.com/Community/posts.php?topic=42657 Rows 0, 1, 2 access the three rows of the Matrix field and row 3 accesses the Vector field. |
| ||
Thank you for all your answers that are useful for progressing my current project Blitzlike |