src/geometry.h

Thu, 27 Feb 2020 23:07:40 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 27 Feb 2020 23:07:40 +0200
changeset 62
3e92760fe00a
parent 58
b7841cd31fb7
child 64
f99d52b1646b
permissions
-rw-r--r--

update locales

#pragma once
#include "basics.h"

namespace geom
{
	struct Plane
	{
		glm::vec3 normal;
		glm::vec3 anchor;
	};

	struct Line
	{
		glm::vec3 direction;
		glm::vec3 anchor;
	};

	template<int N>
	struct Polygon
	{
		glm::vec3 points[N];
	};

	inline const glm::vec3 origin = {0, 0, 0};
	inline const Plane XY = {{0, 0, 1}, origin};
	inline const Plane XZ = {{0, 1, 0}, origin};
	inline const Plane YZ = {{1, 0, 0}, origin};
	using Triangle = Polygon<3>;

	Line lineFromPoints(const glm::vec3& point_1, const glm::vec3 point_2);
	Plane planeFromTriangle(const Triangle& triangle);
	glm::vec3 normalVector(const Triangle& triangle);
	std::optional<glm::vec3> linePlaneIntersection(const Line& line, const Plane& plane, const float epsilon = 1e-6);
}

mercurial