src/basics.h

Sun, 03 Nov 2019 18:17:08 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 03 Nov 2019 18:17:08 +0200
changeset 15
9e18ec63eec3
parent 8
44679e468ba9
child 17
a5111f4e6412
permissions
-rw-r--r--

split quadrilateral and triangle into their own source files

/*
 *  LDForge: LDraw parts authoring CAD
 *  Copyright (C) 2019 Teemu Piippo
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <QMatrix4x4>
#include <QObject>
#include <QPointF>
#include <QSet>
#include <QString>
#include <QStringList>
#include <QVariant>
#include <QVector>
#include <QVector3D>

using GLRotationMatrix = QMatrix4x4;

enum Axis
{
	X,
	Y,
	Z
};

enum Winding
{
	NoWinding,
	Anticlockwise,
	Clockwise,
};

/*
 * Special operator definition that implements the XOR operator for windings.
 * However, if either winding is NoWinding, then this function returns NoWinding.
 */
inline Winding operator^(Winding one, Winding other)
{
	if (one == NoWinding or other == NoWinding)
		return NoWinding;
	else
		return static_cast<Winding>(static_cast<int>(one) ^ static_cast<int>(other));
}

inline Winding& operator^=(Winding& one, Winding other)
{
	one = one ^ other;
	return one;
}

static constexpr long double pi = M_PIl;

mercurial