#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2015 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License // If the library is compiled as a DLL, this ensures symbols are exported #define NUCLEX_GEOMETRY_SOURCE 1 #include "Nuclex/Geometry/Areas/Triangle3.h" #include namespace Nuclex { namespace Geometry { namespace Areas { // ------------------------------------------------------------------------------------------- // TEST(Triangle3Test, ParameterConstructorAssignsValues) { Triangle3 triangle( Point3(1.1f, 2.2f, 3.3f), Point3(4.4f, 5.5f, 6.6f), Point3(7.7f, 8.8f, 9.9f) ); EXPECT_EQ(1.1f, triangle.A.X); EXPECT_EQ(2.2f, triangle.A.Y); EXPECT_EQ(3.3f, triangle.A.Z); EXPECT_EQ(4.4f, triangle.B.X); EXPECT_EQ(5.5f, triangle.B.Y); EXPECT_EQ(6.6f, triangle.B.Z); EXPECT_EQ(7.7f, triangle.C.X); EXPECT_EQ(8.8f, triangle.C.Y); EXPECT_EQ(9.9f, triangle.C.Z); } // ------------------------------------------------------------------------------------------- // TEST(Triangle3Test, CenterOfTriangleCanBeDetermined) { Triangle3 triangle( Point3(1.1f, 2.2f, 3.3f), Point3(4.4f, 5.5f, 6.6f), Point3(7.7f, 8.8f, 9.9f) ); Point3 center = triangle.GetCenter(); EXPECT_EQ(4.4f, center.X); EXPECT_EQ(5.5f, center.Y); EXPECT_EQ(6.6f, center.Z); } // ------------------------------------------------------------------------------------------- // #if 0 TEST(Triangle3Test, TriangleSurfaceAreaCanBeCalculated) { Triangle3 triangle( Point3(1.1f, 2.2f), Point2(3.3f, 9.9f), Point2(5.5f, 1.1f) ); EXPECT_FLOAT_EQ(18.149998886345646f, triangle.GetArea()); } // ------------------------------------------------------------------------------------------- // TEST(Triangle3Test, TrianglePerimeterCanBeCalculated) { Triangle3 triangle( Point2(1.1f, 2.2f), Point2(3.3f, 9.9f), Point2(5.5f, 1.1f) ); EXPECT_FLOAT_EQ(21.614368f, triangle.GetPerimeter()); } // ------------------------------------------------------------------------------------------- // TEST(Triangle3Test, TrianglesCanBeShiftedByCoordinates) { Triangle3 triangle( Point2(1.1f, 2.2f), Point2(3.3f, 9.9f), Point2(5.5f, 1.1f) ); triangle.ShiftBy(10.0f, 100.0f); EXPECT_EQ(11.1f, triangle.A.X); EXPECT_EQ(102.2f, triangle.A.Y); EXPECT_EQ(13.3f, triangle.B.X); EXPECT_EQ(109.9f, triangle.B.Y); EXPECT_EQ(15.5f, triangle.C.X); EXPECT_EQ(101.1f, triangle.C.Y); } // ------------------------------------------------------------------------------------------- // TEST(Triangle3Test, TrianglesCanBeShiftedByVectors) { Triangle3 triangle( Point2(1.1f, 2.2f), Point2(3.3f, 9.9f), Point2(5.5f, 1.1f) ); triangle.ShiftBy(Vector2(100.0f, 10.0f)); EXPECT_EQ(101.1f, triangle.A.X); EXPECT_EQ(12.2f, triangle.A.Y); EXPECT_EQ(103.3f, triangle.B.X); EXPECT_EQ(19.9f, triangle.B.Y); EXPECT_EQ(105.5f, triangle.C.X); EXPECT_EQ(11.1f, triangle.C.Y); } #endif // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Geometry::Areas