Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology
Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered
You are not logged in.
Pages: 1
is there a function for comparing two quaternions.....I want to know if two rotation values are equal to one another. Do I have to break each quaternion into four floats to do the test, or is there a simpler way?
-thx
Offline
// return 1 if equal otherwise 0
fun check (q1, q2)=
let q1 -> [a1 b1 c1 d1] in
let q2 -> [a2 b2 c2 d2] in
if a1 != a2 then
0
else if b1 != b2 then
0
else if c1 != c2 then
0
else if d1 != d2 then
0
else
1;;
Offline
Thx guys
Offline
Offline
ha ok you mean to type the code not the execution time
maybe that we could add a new tuple syntax, something like "tuple[pos]" to get a value
a tuple such as [a b c d]
For some operation, it need to do
let tuple -> [a b c d] in
// operations only on d, by example
With a table :
// operation on tab.3, directly and easily. In this case, one statment instead two.
Other thing, with a table, it is easy to do a recursion or perform a WHILE. It is difficult with a tuple. To do, not to write with a keyboard.
So, yes, i mean to the execution time. That is why I wonder whether it is not better to replace tuple by table generally (not only on these quaternons).
Otherwise, i had done this, in Syspack : http://www.scolring.org/files/doc_html/ … tuple.html
Offline
It can be useful for recursion but tuple with different types won't make this use possible.
since lists are tuples with the same types in this case the developer should use lists.
I still don't see where it can be faster in execution time since tabs and tuples are the same in the VM.
Offline
Of course, when this replacement is possible (same type) ....
When you manipulate a tuple, you shpuld often do
a let tuple -> [ ...] in
even if you've only need the third element.
when a table, you create it once time, that's all.
Aloop /recursion can be faster, else equal.
For ONE statment, i'm ok, the performance is the same and the access time is the same. I'm not sure that they are equals in an application such as os3d.
Offline
euh yes, i know ! thanks !!
let tuple -> [_ _ elem _] in // +1 locale variable
myFunction elem; // 2 statments
myFunction table.2; // 1 statment, 0 locale variable
Offline
Pages: 1