[FEAT] add dot and cross
This commit is contained in:
@@ -64,6 +64,18 @@ TEST_CASE("a tuple with w=0 is a vector", "[Tuple]")
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("Tuple could be copy", "[Tuple]")
|
||||
{
|
||||
Tuple p = Tuple::Point(4, -4, 3);
|
||||
Tuple n;
|
||||
|
||||
n = p;
|
||||
|
||||
REQUIRE(n == p);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("Point() creates tuples with w=1", "[Tuple][Point]")
|
||||
{
|
||||
Tuple p = Tuple::Point(4, -4, 3);
|
||||
@@ -231,3 +243,24 @@ TEST_CASE("The magnitude of a normalized vector", "[Tuple][Normalize]")
|
||||
|
||||
REQUIRE(norm.magnitude() == 1);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("The dot product of two tuples", "[Tuple][Dot]")
|
||||
{
|
||||
Tuple a = Tuple::Vector(1, 2, 3);
|
||||
Tuple b = Tuple::Vector(2, 3, 4);
|
||||
|
||||
REQUIRE(a.dot(b) == 20);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("The cross product of two vector", "[Tuple][Cross]")
|
||||
{
|
||||
Tuple a = Tuple::Vector(1, 2, 3);
|
||||
Tuple b = Tuple::Vector(2, 3, 4);
|
||||
|
||||
REQUIRE(a.cross(b) == Tuple::Vector(-1, 2, -1));
|
||||
REQUIRE(b.cross(a) == Tuple::Vector(1, -2, 1));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user