Mako 8.2.0 API
MakoCore SDK API Documentation
Loading...
Searching...
No Matches
edlmath.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006-2025 Global Graphics Software Ltd. All rights reserved.
3 */
4
11
12#ifndef __EDLMATH_H__
13#define __EDLMATH_H__
14
15#include <vector>
16#include <edl/edlnamespaces.h>
17#include <math.h>
18
25#define PI 3.14159265358979323846
26
30static inline double convertDegreesToRadians(double degrees)
31{
32 const double convConst = PI * 2.0 / 360.0; /* Should compile precalculated */
33
34 return degrees * convConst;
35}
36
40static inline double convertRadiansToDegrees(double radians)
41{
42 const double convConst = 360.0 / (PI * 2.0); /* Should compile precalculated */
43
44 return radians * convConst;
45}
46
48
49// Simple matrix class with flat array storage
50template <class T, int W, int H>
52{
53public:
54#ifdef SWIG
55#if SWIGJAVA
56 %apply T [] { T *values };
57#endif
58#if SWIGCSHARP
59 %apply T INPUT[] { T *values };
60#endif
61#endif
64 CMatrix(T *values)
65 {
66 setValues(values);
67 }
69 {
70 for (int i = 0; i < W * H; i++)
71 {
72 m_values[i] = 0;
73 }
74 }
75
77 {
78 return m_values;
79 }
80
81 std::vector<T> getValuesVect ()
82 {
83 std::vector<T> vec;
84 T *vals;
85
86 vals = getValues ();
87
88 for (int i = 0; i < W * H; i++)
89 vec.push_back (vals [i]);
90
91 return vec;
92 }
93
94#ifdef SWIG
95#if SWIGJAVA
96 %apply T [] { T *values };
97#endif
98#if SWIGCSHARP
99 %apply T INPUT[] { T *values };
100#endif
101#endif
103 void setValues(T *values)
104 {
105 for (int i = 0; i < W * H; i++)
106 {
107 m_values[i] = values[i];
108 }
109 }
110#ifdef SWIG
111 %clear T *values;
112#endif
113
114#ifdef SWIG
115 %apply T &OUTPUT { T &value };
116#endif
117 bool getValue(int x, int y, T &value)
118 {
119 if (x >= W || x < 0 || y >= H || y < 0)
120 {
121 return false;
122 }
123 value = m_values[y * W + x];
124 return true;
125 }
126#ifdef SWIG
127 %clear T &value;
128#endif
129
130 bool setValue(int x, int y, const T &value)
131 {
132 if (x >= W || x < 0 || y >= H || y < 0)
133 {
134 return false;
135 }
136 m_values[y * W + x] = value;
137 return true;
138 }
139
140 // Matrix mult/inverse/etc methods would go here
141private:
142 T m_values[W * H];
143};
144
146
148#endif /* __EDLMATH_H__ */
Definition edlmath.h:52
bool setValue(int x, int y, const T &value)
Definition edlmath.h:130
CMatrix(T *values)
Definition edlmath.h:64
T * getValues()
Get all the values in the Matrix as a flat array.
Definition edlmath.h:76
CMatrix()
Definition edlmath.h:68
std::vector< T > getValuesVect()
Definition edlmath.h:81
bool getValue(int x, int y, T &value)
Definition edlmath.h:117
void setValues(T *values)
Set all the values as a flat array.
Definition edlmath.h:103
#define PI
Local definition of PI to 20 decimal places.
Definition edlmath.h:25
CMatrix< float, 3, 3 > SFMatrix3x3
Definition edlmath.h:145
EDL C++ namespace(s)
#define _BEGIN_EDL_NAMESPACE
Definition edlnamespaces.h:75
#define _END_EDL_NAMESPACE
Definition edlnamespaces.h:76