Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quaternion Comparison?

Is quaternion comparison possible? I'm writing a Java class of Quaternions and I want to implement the Comparable interface to use the Collections.sort(List<Quaternion>) facility. I'm not expert at math, I really don't understand the things I read about Quaternions. So, can anyone tell me can I override the compareTo method for Quaternions and how?

My class declarition:

public class Quaternion implements Serializable, Comparable<Quaternion> {

    private double s; // scalar part
    private double i, j, k; // vectorel part


    public Quaternion() {
        super();
    }

    public Quaternion(double s, double i, double j, double k) {
        super();
        this.s = s;
        this.i = i;
        this.j = j;
        this.k = k;
    }
like image 789
anarhikos Avatar asked Apr 27 '11 11:04

anarhikos


People also ask

How do you know if two quaternions are equal?

Just apply the quaternion to a 3-D vector. If the final result from q1 and q2 is the same, then the quaternion has "same direction".

What are the 4 values of a quaternion?

Four values make up a quaternion, namely x, y, z and w. Three of the values are used to represent the axis in vector format, and the forth value would be the angle of rotation around the axis." So you could think of it as the rotation of the rotation, in simple terms!

Are quaternions still used?

Quaternions are used in pure mathematics, but also have practical uses in applied mathematics, particularly for calculations involving three-dimensional rotations, such as in three-dimensional computer graphics, computer vision, and crystallographic texture analysis.


1 Answers

You can implement compareTo, by comparing its fields. However, you need to determine what you want the order to be like. AFAIK, there is no standard definition of what comes before or after for complex numbers let alone a quaternion.

like image 116
Peter Lawrey Avatar answered Oct 14 '22 20:10

Peter Lawrey