package eu.jonahbauer.raytracing.math;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class Vec3Test {

    @Test
    void plus() {
        var a = new Vec3(1, 2, 3);
        var b = new Vec3(-1, 1, -2);
        assertEquals(new Vec3(0, 3, 1), a.plus(b));
    }

    @Test
    void minus() {
        var a = new Vec3(1, 2, 3);
        var b = new Vec3(-1, 1, -2);
        assertEquals(new Vec3(2, 1, 5), a.minus(b));
    }

    @Test
    void timesVec() {
        var a = new Vec3(1, 2, 3);
        var b = new Vec3(-1, 1, -2);
        assertEquals(-5, a.times(b));
    }

    @Test
    void timeScalar() {
        var a = new Vec3(1, 2, 3);
        var b = 2.5;
        assertEquals(new Vec3(2.5, 5, 7.5), a.times(b));
    }

    @Test
    void div() {
        var a = new Vec3(1, 2, 3);
        var b = 2;
        assertEquals(new Vec3(0.5, 1, 1.5), a.div(b));
    }

    @Test
    void squared() {
        var a = new Vec3(1, 2, 3);
        assertEquals(14, a.squared());
    }

    @Test
    void length() {
        var a = new Vec3(3, 4, 0);
        assertEquals(5, a.length());
    }

    @Test
    void unit() {
        var a = new Vec3(3, 4, 0);
        assertEquals(new Vec3(0.6, 0.8, 0), a.unit());
    }
}