diff options
Diffstat (limited to 'libdimensionxx/dimensionxx')
-rw-r--r-- | libdimensionxx/dimensionxx/array.hpp | 7 | ||||
-rw-r--r-- | libdimensionxx/dimensionxx/canvas.hpp | 4 | ||||
-rw-r--r-- | libdimensionxx/dimensionxx/color.hpp | 4 | ||||
-rw-r--r-- | libdimensionxx/dimensionxx/cookie.hpp | 4 | ||||
-rw-r--r-- | libdimensionxx/dimensionxx/error.hpp | 6 | ||||
-rw-r--r-- | libdimensionxx/dimensionxx/geometry.hpp | 55 | ||||
-rw-r--r-- | libdimensionxx/dimensionxx/object.hpp | 4 | ||||
-rw-r--r-- | libdimensionxx/dimensionxx/png.hpp | 4 | ||||
-rw-r--r-- | libdimensionxx/dimensionxx/progress.hpp | 4 |
9 files changed, 73 insertions, 19 deletions
diff --git a/libdimensionxx/dimensionxx/array.hpp b/libdimensionxx/dimensionxx/array.hpp index dfbf1c8..735e17a 100644 --- a/libdimensionxx/dimensionxx/array.hpp +++ b/libdimensionxx/dimensionxx/array.hpp @@ -18,14 +18,14 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ +// dmnsn_array* wrapper. + #ifndef DIMENSIONXX_ARRAY_HPP #define DIMENSIONXX_ARRAY_HPP #include <tr1/memory> // For tr1::shared_ptr #include <cstdlib> // For size_t -// dmnsn_array* wrapper. - namespace Dimension { // RAII scoped read-lock @@ -148,6 +148,8 @@ namespace Dimension return ret; } + // Access the underlying dmnsn_array* + template <typename T> dmnsn_array* Array<T>::dmnsn() @@ -170,6 +172,7 @@ namespace Dimension return *m_array; } + // Release the dmnsn_array*, if we are the only Array holding it template <typename T> dmnsn_array* Array<T>::release() diff --git a/libdimensionxx/dimensionxx/canvas.hpp b/libdimensionxx/dimensionxx/canvas.hpp index eda9ad3..f9e77e5 100644 --- a/libdimensionxx/dimensionxx/canvas.hpp +++ b/libdimensionxx/dimensionxx/canvas.hpp @@ -18,11 +18,11 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ +// dmnsn_canvas* wrapper. + #ifndef DIMENSIONXX_CANVAS_HPP #define DIMENSIONXX_CANVAS_HPP -// dmnsn_canvas* wrapper. - namespace Dimension { // Base canvas class. Wraps a dmnsn_canvas*. diff --git a/libdimensionxx/dimensionxx/color.hpp b/libdimensionxx/dimensionxx/color.hpp index c79f86b..9289479 100644 --- a/libdimensionxx/dimensionxx/color.hpp +++ b/libdimensionxx/dimensionxx/color.hpp @@ -18,11 +18,11 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ +// Wrappers for libdimension colors. + #ifndef DIMENSIONXX_COLOR_HPP #define DIMENSIONXX_COLOR_HPP -// Wrappers for libdimension colors. - namespace Dimension { // Forward declarations diff --git a/libdimensionxx/dimensionxx/cookie.hpp b/libdimensionxx/dimensionxx/cookie.hpp index df26b93..0d8b4da 100644 --- a/libdimensionxx/dimensionxx/cookie.hpp +++ b/libdimensionxx/dimensionxx/cookie.hpp @@ -18,11 +18,11 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ +// Some internal magic to use C FILE* I/O with C++ streams. + #ifndef DIMENSIONXX_COOKIE_HPP #define DIMENSIONXX_COOKIE_HPP -// Some internal magic to use C FILE* I/O with C++ streams. - #include <istream> #include <ostream> #include <cstdio> diff --git a/libdimensionxx/dimensionxx/error.hpp b/libdimensionxx/dimensionxx/error.hpp index 99670cb..7fb0e53 100644 --- a/libdimensionxx/dimensionxx/error.hpp +++ b/libdimensionxx/dimensionxx/error.hpp @@ -18,14 +18,14 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ -#ifndef DIMENSIONXX_ERROR_HPP -#define DIMENSIONXX_ERROR_HPP - // Wrappers for libdimension error handling, and an exception class. // dmnsn_error is still used by libdimensionxx whenever an exception shouldn't // be thrown, like in destructors, and whenever libdimension or libdimension-* // use it internally. Exceptions are thrown otherwise to report errors. +#ifndef DIMENSIONXX_ERROR_HPP +#define DIMENSIONXX_ERROR_HPP + #include <dimension.h> #include <stdexcept> #include <string> diff --git a/libdimensionxx/dimensionxx/geometry.hpp b/libdimensionxx/dimensionxx/geometry.hpp index f623eda..606f83a 100644 --- a/libdimensionxx/dimensionxx/geometry.hpp +++ b/libdimensionxx/dimensionxx/geometry.hpp @@ -18,15 +18,17 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ +// Wrappers for geometric types (Vectors, Matricies, Lines (rays)). + #ifndef DIMENSIONXX_GEOMETRY_HPP #define DIMENSIONXX_GEOMETRY_HPP -// Wrappers for geometric types (Vectors, Matricies, Lines (rays)). - #include <dimension.h> namespace Dimension { + class Vector; + // Wrapper for dmnsn_matrix class Matrix { @@ -56,6 +58,12 @@ namespace Dimension // Get the wrapped matrix dmnsn_matrix dmnsn() const { return m_matrix; } + // Special constructors + static inline Matrix identity(); + static inline Matrix scale(const Vector& factor); + static inline Matrix translation(const Vector& d); + static inline Matrix rotation(const Vector& theta); + private: dmnsn_matrix m_matrix; }; @@ -126,6 +134,49 @@ namespace Dimension dmnsn_line m_line; }; + // Matrix operators + + inline Matrix + operator*(const Matrix& lhs, const Matrix& rhs) + { + // This order is important! + Matrix r = rhs; + r *= lhs; + return r; + } + + inline Matrix + inverse(const Matrix& M) + { + return Matrix(dmnsn_matrix_inverse(M.dmnsn())); + } + + // Special Matrix constructors + + inline Matrix + Matrix::identity() + { + return Matrix(dmnsn_identity_matrix()); + } + + inline Matrix + Matrix::scale(const Vector& factor) + { + return Matrix(dmnsn_scale_matrix(factor.dmnsn())); + } + + inline Matrix + Matrix::translation(const Vector& d) + { + return Matrix(dmnsn_translation_matrix(d.dmnsn())); + } + + inline Matrix + Matrix::rotation(const Vector& theta) + { + return Matrix(dmnsn_rotation_matrix(theta.dmnsn())); + } + // Vector operators inline Vector diff --git a/libdimensionxx/dimensionxx/object.hpp b/libdimensionxx/dimensionxx/object.hpp index 3b2c6c1..40dcb25 100644 --- a/libdimensionxx/dimensionxx/object.hpp +++ b/libdimensionxx/dimensionxx/object.hpp @@ -18,11 +18,11 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ +// dmnsn_object* wrapper. + #ifndef DIMENSIONXX_OBJECT_HPP #define DIMENSIONXX_OBJECT_HPP -// dmnsn_object* wrapper. - namespace Dimension { // Abstract base object class. Wraps a dmnsn_object*. diff --git a/libdimensionxx/dimensionxx/png.hpp b/libdimensionxx/dimensionxx/png.hpp index d768287..980840c 100644 --- a/libdimensionxx/dimensionxx/png.hpp +++ b/libdimensionxx/dimensionxx/png.hpp @@ -18,11 +18,11 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ +// C++ wrapper for libdimension PNG support. PNG_Canvas derives from Canvas. + #ifndef DIMENSIONXX_PNG_HPP #define DIMENSIONXX_PNG_HPP -// C++ wrapper for libdimension PNG support. PNG_Canvas derives from Canvas. - #include <istream> #include <ostream> diff --git a/libdimensionxx/dimensionxx/progress.hpp b/libdimensionxx/dimensionxx/progress.hpp index b9df870..3fff1bc 100644 --- a/libdimensionxx/dimensionxx/progress.hpp +++ b/libdimensionxx/dimensionxx/progress.hpp @@ -18,14 +18,14 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ +// dmnsn_progress* wrapper. + #ifndef DIMENSIONXX_PROGRESS_HPP #define DIMENSIONXX_PROGRESS_HPP #include <tr1/memory> // For tr1::shared_ptr #include <list> -// dmnsn_canvas* wrapper. - namespace Dimension { // Base class for persisting objects |