[ create a new paste ] login | about

Link: http://codepad.org/VNK8Swsw    [ raw code | output | fork ]

C++, pasted on Jan 24:
#include <iostream>

class q
{
private:
    float x;
    float y;
    float z;
    float w;

public:
    q() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) {}
    q(float x_, float y_, float z_, float w_) : x(x_), y(y_), z(z_), w(w_) {}

    q conj()
    {
        return q(-x, -y, -z, w);
    }

    q operator*(q& r)
    {
        return q(
            x * r.w + w * r.x - z * r.y + y * r.z,
            y * r.w + z * r.x + w * r.y - x * r.z,
            z * r.w - y * r.x + x * r.y + w * r.z,
            w * r.w - x * r.x - y * r.y - z * r.z
        );
    }
};

int main()
{
   std::printf("hello world");

    return 0;
}


Output:
1
hello world


Create a new paste based on this one


Comments: