Example #1
0
void NzPatch::ComputeHeights()
{
    int j;
    for(int j0(-1) ; j0 < 6 ; ++j0)
    {
        j = j0 + 1;

        m_vertices[0].at(j).ComputePosition(m_data->quadtree, m_id,NzVector2i(-1,j0));
        m_vertices[1].at(j).ComputePosition(m_data->quadtree, m_id,NzVector2i(0,j0));
        m_vertices[2].at(j).ComputePosition(m_data->quadtree, m_id,NzVector2i(1,j0));
        m_vertices[3].at(j).ComputePosition(m_data->quadtree, m_id,NzVector2i(2,j0));
        m_vertices[4].at(j).ComputePosition(m_data->quadtree, m_id,NzVector2i(3,j0));
        m_vertices[5].at(j).ComputePosition(m_data->quadtree, m_id,NzVector2i(4,j0));
        m_vertices[6].at(j).ComputePosition(m_data->quadtree, m_id,NzVector2i(5,j0));
    }

    m_aabb.aabb.x = m_vertices[1][1].GetPosition().x;
    m_aabb.aabb.y = m_vertices[1][1].GetPosition().y;
    m_aabb.aabb.z = m_vertices[1][1].GetPosition().z;
    m_aabb.aabb.width = 0.1f;
    m_aabb.aabb.depth = 0.1f;
    m_aabb.aabb.height = 0.1f;

    for(int j(1) ; j < 6 ; ++j)
    {
        m_aabb.aabb.ExtendTo(m_vertices[1][j].GetPosition());
        m_aabb.aabb.ExtendTo(m_vertices[2][j].GetPosition());
        m_aabb.aabb.ExtendTo(m_vertices[3][j].GetPosition());
        m_aabb.aabb.ExtendTo(m_vertices[4][j].GetPosition());
        m_aabb.aabb.ExtendTo(m_vertices[5][j].GetPosition());
    }
}
Example #2
0
#include <Nazara/Math/Vector2.hpp>
#include <catch.hpp>

#include <Nazara/Math/Vector4.hpp>

SCENARIO("Vector2", "[MATH][VECTOR2]")
{
	GIVEN("Two same vectors (1, 1)")
	{
		NzVector2f firstUnit(1.f);
		NzVector2f secondUnit(NzVector2i(NzVector4i(1, 1, 3, 5)));

		WHEN("We compare them")
		{
			THEN("They are the same")
			{
				REQUIRE(firstUnit == secondUnit);
			}
		}

		WHEN("We test the dot product")
		{
			NzVector2f tmp(-1.f, 1.f);

			THEN("These results are expected")
			{
				REQUIRE(firstUnit.AbsDotProduct(tmp) == Approx(2.f));
				REQUIRE(firstUnit.DotProduct(tmp) == Approx(0.f));
				REQUIRE(firstUnit.AngleBetween(tmp) == Approx(90.f));
			}
		}