-
Notifications
You must be signed in to change notification settings - Fork 7
/
ospray_math.h
61 lines (49 loc) · 1.24 KB
/
ospray_math.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
// anari
#include <anari/anari_cpp/ext/linalg.h>
#include <anari/anari_cpp.hpp>
// std
#include <cstring>
#include <limits>
namespace anari_ospray {
// Types //////////////////////////////////////////////////////////////////////
using namespace linalg::aliases;
using mat4 = float4x4;
using mat3x4 = float3x4;
constexpr float4 DEFAULT_ATTRIBUTE_VALUE(0.f, 0.f, 0.f, 1.f);
enum class Attribute
{
ATTRIBUTE_0 = 0,
ATTRIBUTE_1,
ATTRIBUTE_2,
ATTRIBUTE_3,
COLOR,
NONE
};
// Functions //////////////////////////////////////////////////////////////////
inline float radians(float degrees)
{
return degrees * float(M_PI) / 180.f;
}
inline float degrees(float radians)
{
return radians * 180.f / float(M_PI);
}
inline Attribute attributeFromString(const std::string &str)
{
if (str == "color")
return Attribute::COLOR;
else if (str == "attribute0")
return Attribute::ATTRIBUTE_0;
else if (str == "attribute1")
return Attribute::ATTRIBUTE_1;
else if (str == "attribute2")
return Attribute::ATTRIBUTE_2;
else if (str == "attribute3")
return Attribute::ATTRIBUTE_3;
else
return Attribute::NONE;
}
} // namespace anari_ospray