Merge github.com:KrakenEngine/hydra
This commit is contained in:
@@ -3,12 +3,12 @@ set(CMAKE_CXX_STANDARD 11)
|
|||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
project(kraken-math)
|
project(hydra)
|
||||||
|
|
||||||
set(PUBLIC_HEADERS
|
set(PUBLIC_HEADERS
|
||||||
include/aabb.h
|
include/aabb.h
|
||||||
include/hitinfo.h
|
include/hitinfo.h
|
||||||
include/kraken-math.h
|
include/hydra.h
|
||||||
include/matrix2.h
|
include/matrix2.h
|
||||||
include/matrix2x3.h
|
include/matrix2x3.h
|
||||||
include/matrix4.h
|
include/matrix4.h
|
||||||
@@ -37,4 +37,4 @@ set(SRCS
|
|||||||
src/vector2i.cpp
|
src/vector2i.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(krakenmath STATIC ${SRCS} ${PUBLIC_HEADERS})
|
add_library(hydra STATIC ${SRCS} ${PUBLIC_HEADERS})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// KRAABB.h
|
// KRAABB.h
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// hitinfo.h
|
// hitinfo.h
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Kraken
|
// hydra.h
|
||||||
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -28,8 +29,8 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef KRAKEN_H
|
#ifndef KRAKEN_HYDRA_H
|
||||||
#define KRAKEN_H
|
#define KRAKEN_HYDRA_H
|
||||||
|
|
||||||
#include "scalar.h"
|
#include "scalar.h"
|
||||||
#include "vector2.h"
|
#include "vector2.h"
|
||||||
@@ -44,4 +45,4 @@
|
|||||||
#include "triangle3.h"
|
#include "triangle3.h"
|
||||||
#include "hitinfo.h"
|
#include "hitinfo.h"
|
||||||
|
|
||||||
#endif // KRAKEN_H
|
#endif // KRAKEN_HYDRA_H
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Matrix2.h
|
// Matrix2.h
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Matrix2x3.h
|
// Matrix2x3.h
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Matrix4.h
|
// Matrix4.h
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Quaternion.h
|
// Quaternion.h
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// KRFloat.h
|
// KRFloat.h
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// KRTriangle.h
|
// KRTriangle.h
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// vector2.h
|
// vector2.h
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// vector2i.h
|
// vector2i.h
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Vector3.h
|
// Vector3.h
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Vector4.h
|
// Vector4.h
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// aabb.cpp
|
// aabb.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "krhelpers.h"
|
#include "krhelpers.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// hitinfo.cpp
|
// hitinfo.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
|
|
||||||
namespace kraken {
|
namespace kraken {
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// krhelpers.cpp
|
// krhelpers.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#endif // defined(KRAKEN_USE_OPENGL)
|
#endif // defined(KRAKEN_USE_OPENGL)
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
|
|
||||||
#define KRMIN(x,y) ((x) < (y) ? (x) : (y))
|
#define KRMIN(x,y) ((x) < (y) ? (x) : (y))
|
||||||
#define KRMAX(x,y) ((x) > (y) ? (x) : (y))
|
#define KRMAX(x,y) ((x) > (y) ? (x) : (y))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// matrix2.cpp
|
// matrix2.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// matrix23.cpp
|
// matrix23.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// matrix4.cpp
|
// matrix4.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// quaternion.cpp
|
// quaternion.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
|
|
||||||
#include "krhelpers.h"
|
#include "krhelpers.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// scalar.cpp
|
// scalar.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
|
|
||||||
namespace kraken {
|
namespace kraken {
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// KRTriangle.cpp
|
// KRTriangle.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
|
|
||||||
using namespace kraken;
|
using namespace kraken;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Vector2.cpp
|
// Vector2.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
#include "krhelpers.h"
|
#include "krhelpers.h"
|
||||||
|
|
||||||
namespace kraken {
|
namespace kraken {
|
||||||
|
|||||||
522
src/vector2i.cpp
522
src/vector2i.cpp
@@ -1,265 +1,265 @@
|
|||||||
//
|
//
|
||||||
// Vector2i.cpp
|
// Vector2i.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
//
|
//
|
||||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
// conditions and the following disclaimer.
|
// conditions and the following disclaimer.
|
||||||
//
|
//
|
||||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
// provided with the distribution.
|
// provided with the distribution.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
// The views and conclusions contained in the software and documentation are those of the
|
// The views and conclusions contained in the software and documentation are those of the
|
||||||
// authors and should not be interpreted as representing official policies, either expressed
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
#include "krhelpers.h"
|
#include "krhelpers.h"
|
||||||
|
|
||||||
namespace kraken {
|
namespace kraken {
|
||||||
|
|
||||||
void Vector2i::init() {
|
void Vector2i::init() {
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::Create()
|
Vector2i Vector2i::Create()
|
||||||
{
|
{
|
||||||
Vector2i r;
|
Vector2i r;
|
||||||
r.init();
|
r.init();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector2i::init(int X, int Y) {
|
void Vector2i::init(int X, int Y) {
|
||||||
x = X;
|
x = X;
|
||||||
y = Y;
|
y = Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::Create(int X, int Y)
|
Vector2i Vector2i::Create(int X, int Y)
|
||||||
{
|
{
|
||||||
Vector2i r;
|
Vector2i r;
|
||||||
r.init(X,Y);
|
r.init(X,Y);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector2i::init(int v) {
|
void Vector2i::init(int v) {
|
||||||
x = v;
|
x = v;
|
||||||
y = v;
|
y = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::Create(int v)
|
Vector2i Vector2i::Create(int v)
|
||||||
{
|
{
|
||||||
Vector2i r;
|
Vector2i r;
|
||||||
r.init(v);
|
r.init(v);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector2i::init(int *v) {
|
void Vector2i::init(int *v) {
|
||||||
x = v[0];
|
x = v[0];
|
||||||
y = v[1];
|
y = v[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::Create(int *v)
|
Vector2i Vector2i::Create(int *v)
|
||||||
{
|
{
|
||||||
Vector2i r;
|
Vector2i r;
|
||||||
r.init(v);
|
r.init(v);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector2i::init(const Vector2i &v) {
|
void Vector2i::init(const Vector2i &v) {
|
||||||
x = v.x;
|
x = v.x;
|
||||||
y = v.y;
|
y = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::Create(const Vector2i &v)
|
Vector2i Vector2i::Create(const Vector2i &v)
|
||||||
{
|
{
|
||||||
Vector2i r;
|
Vector2i r;
|
||||||
r.init(v);
|
r.init(v);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vector2 swizzle getters
|
// Vector2 swizzle getters
|
||||||
Vector2i Vector2i::yx() const
|
Vector2i Vector2i::yx() const
|
||||||
{
|
{
|
||||||
return Vector2i::Create(y,x);
|
return Vector2i::Create(y,x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vector2 swizzle setters
|
// Vector2 swizzle setters
|
||||||
void Vector2i::yx(const Vector2i &v)
|
void Vector2i::yx(const Vector2i &v)
|
||||||
{
|
{
|
||||||
y = v.x;
|
y = v.x;
|
||||||
x = v.y;
|
x = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::Min() {
|
Vector2i Vector2i::Min() {
|
||||||
return Vector2i::Create(-std::numeric_limits<int>::max());
|
return Vector2i::Create(-std::numeric_limits<int>::max());
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::Max() {
|
Vector2i Vector2i::Max() {
|
||||||
return Vector2i::Create(std::numeric_limits<int>::max());
|
return Vector2i::Create(std::numeric_limits<int>::max());
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::Zero() {
|
Vector2i Vector2i::Zero() {
|
||||||
return Vector2i::Create(0);
|
return Vector2i::Create(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::One() {
|
Vector2i Vector2i::One() {
|
||||||
return Vector2i::Create(1);
|
return Vector2i::Create(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::operator +(const Vector2i& b) const {
|
Vector2i Vector2i::operator +(const Vector2i& b) const {
|
||||||
return Vector2i::Create(x + b.x, y + b.y);
|
return Vector2i::Create(x + b.x, y + b.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::operator -(const Vector2i& b) const {
|
Vector2i Vector2i::operator -(const Vector2i& b) const {
|
||||||
return Vector2i::Create(x - b.x, y - b.y);
|
return Vector2i::Create(x - b.x, y - b.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::operator +() const {
|
Vector2i Vector2i::operator +() const {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::operator -() const {
|
Vector2i Vector2i::operator -() const {
|
||||||
return Vector2i::Create(-x, -y);
|
return Vector2i::Create(-x, -y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::operator *(const int v) const {
|
Vector2i Vector2i::operator *(const int v) const {
|
||||||
return Vector2i::Create(x * v, y * v);
|
return Vector2i::Create(x * v, y * v);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::operator /(const int v) const {
|
Vector2i Vector2i::operator /(const int v) const {
|
||||||
return Vector2i::Create(x / v, y / v);
|
return Vector2i::Create(x / v, y / v);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i& Vector2i::operator +=(const Vector2i& b) {
|
Vector2i& Vector2i::operator +=(const Vector2i& b) {
|
||||||
x += b.x;
|
x += b.x;
|
||||||
y += b.y;
|
y += b.y;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i& Vector2i::operator -=(const Vector2i& b) {
|
Vector2i& Vector2i::operator -=(const Vector2i& b) {
|
||||||
x -= b.x;
|
x -= b.x;
|
||||||
y -= b.y;
|
y -= b.y;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i& Vector2i::operator *=(const int v) {
|
Vector2i& Vector2i::operator *=(const int v) {
|
||||||
x *= v;
|
x *= v;
|
||||||
y *= v;
|
y *= v;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i& Vector2i::operator /=(const int v) {
|
Vector2i& Vector2i::operator /=(const int v) {
|
||||||
x /= v;
|
x /= v;
|
||||||
y /= v;
|
y /= v;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Vector2i::operator ==(const Vector2i& b) const {
|
bool Vector2i::operator ==(const Vector2i& b) const {
|
||||||
return x == b.x && y == b.y;
|
return x == b.x && y == b.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Vector2i::operator !=(const Vector2i& b) const {
|
bool Vector2i::operator !=(const Vector2i& b) const {
|
||||||
return x != b.x || y != b.y;
|
return x != b.x || y != b.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Vector2i::operator >(const Vector2i& b) const
|
bool Vector2i::operator >(const Vector2i& b) const
|
||||||
{
|
{
|
||||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||||
if(x > b.x) {
|
if(x > b.x) {
|
||||||
return true;
|
return true;
|
||||||
} else if(x < b.x) {
|
} else if(x < b.x) {
|
||||||
return false;
|
return false;
|
||||||
} else if(y > b.y) {
|
} else if(y > b.y) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Vector2i::operator <(const Vector2i& b) const
|
bool Vector2i::operator <(const Vector2i& b) const
|
||||||
{
|
{
|
||||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||||
if(x < b.x) {
|
if(x < b.x) {
|
||||||
return true;
|
return true;
|
||||||
} else if(x > b.x) {
|
} else if(x > b.x) {
|
||||||
return false;
|
return false;
|
||||||
} else if(y < b.y) {
|
} else if(y < b.y) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int& Vector2i::operator[] (unsigned i) {
|
int& Vector2i::operator[] (unsigned i) {
|
||||||
switch(i) {
|
switch(i) {
|
||||||
case 0:
|
case 0:
|
||||||
return x;
|
return x;
|
||||||
case 1:
|
case 1:
|
||||||
default:
|
default:
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Vector2i::operator[](unsigned i) const {
|
int Vector2i::operator[](unsigned i) const {
|
||||||
switch(i) {
|
switch(i) {
|
||||||
case 0:
|
case 0:
|
||||||
return x;
|
return x;
|
||||||
case 1:
|
case 1:
|
||||||
default:
|
default:
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector2i::normalize() {
|
void Vector2i::normalize() {
|
||||||
int m = magnitude();
|
int m = magnitude();
|
||||||
x /= m;
|
x /= m;
|
||||||
y /= m;
|
y /= m;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Vector2i::sqrMagnitude() const {
|
int Vector2i::sqrMagnitude() const {
|
||||||
return x * x + y * y;
|
return x * x + y * y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Vector2i::magnitude() const {
|
int Vector2i::magnitude() const {
|
||||||
return static_cast<int>(sqrt(x * x + y * y));
|
return static_cast<int>(sqrt(x * x + y * y));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::Normalize(const Vector2i &v) {
|
Vector2i Vector2i::Normalize(const Vector2i &v) {
|
||||||
int m = v.magnitude();
|
int m = v.magnitude();
|
||||||
return Vector2i::Create(v.x / m, v.y / m);
|
return Vector2i::Create(v.x / m, v.y / m);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Vector2i::Cross(const Vector2i &v1, const Vector2i &v2) {
|
int Vector2i::Cross(const Vector2i &v1, const Vector2i &v2) {
|
||||||
return v1.x * v2.y - v1.y * v2.x;
|
return v1.x * v2.y - v1.y * v2.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Vector2i::Dot(const Vector2i &v1, const Vector2i &v2) {
|
int Vector2i::Dot(const Vector2i &v1, const Vector2i &v2) {
|
||||||
return v1.x * v2.x + v1.y * v2.y;
|
return v1.x * v2.x + v1.y * v2.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::Min(const Vector2i &v1, const Vector2i &v2) {
|
Vector2i Vector2i::Min(const Vector2i &v1, const Vector2i &v2) {
|
||||||
return Vector2i::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y));
|
return Vector2i::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::Max(const Vector2i &v1, const Vector2i &v2) {
|
Vector2i Vector2i::Max(const Vector2i &v1, const Vector2i &v2) {
|
||||||
return Vector2i::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y));
|
return Vector2i::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namepsace kraken
|
} // namepsace kraken
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Vector3.cpp
|
// Vector3.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
#include "krhelpers.h"
|
#include "krhelpers.h"
|
||||||
|
|
||||||
namespace kraken {
|
namespace kraken {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Vector4.cpp
|
// Vector4.cpp
|
||||||
// Kraken
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
// Copyright 2018 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/hydra.h"
|
||||||
#include "krhelpers.h"
|
#include "krhelpers.h"
|
||||||
|
|
||||||
namespace kraken {
|
namespace kraken {
|
||||||
|
|||||||
Reference in New Issue
Block a user