Scolring - Forum

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.

#1 19-Dec-2013 18:52:47

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,543
Website

testing equality of two quaternions?

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

#2 19-Dec-2013 20:36:36

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,162
Website

Re: testing equality of two quaternions?

hmm no there is not ^^
you're right this should be usefull, you can add a ticket on redmine for this

for now you can compare each values

Offline

#3 19-Dec-2013 21:03:32

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: testing equality of two quaternions?

// 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

#4 19-Dec-2013 21:06:30

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: testing equality of two quaternions?

Arkeon : dan is right, quaternions are a bad performance. A table would be better and faster, what do you think, on the long time ?

Offline

#5 19-Dec-2013 21:25:01

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,543
Website

Re: testing equality of two quaternions?

Thx guys

Offline

#6 19-Dec-2013 22:05:33

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,162
Website

Re: testing equality of two quaternions?

Actually I think that is quite the same performance in the VM.
the model have been taken from the zooengine and it's euler rotations

Offline

#7 20-Dec-2013 00:17:13

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: testing equality of two quaternions?

Not in the VM, but in Scol (a pkg if you want), a tuple manipulation is slower than a table manipulation. This is why I say that.

Offline

#8 20-Dec-2013 14:10:26

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,162
Website

Re: testing equality of two quaternions?

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

Offline

#9 20-Dec-2013 14:26:47

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: testing equality of two quaternions?

arkeon wrote:

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

#10 20-Dec-2013 15:12:02

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,162
Website

Re: testing equality of two quaternions?

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

#11 20-Dec-2013 16:05:55

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: testing equality of two quaternions?

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

#12 20-Dec-2013 16:41:35

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,162
Website

Re: testing equality of two quaternions?

you can also do

let tuple -> [_ _ elem _] in

Offline

#13 20-Dec-2013 21:12:18

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: testing equality of two quaternions?

euh yes, i know ! thanks !! big_smile

let tuple -> [_ _ elem _] in // +1 locale variable
myFunction elem; // 2 statments
myFunction table.2; // 1 statment, 0 locale variable

Offline

Board footer

Powered by FluxBB