2014-07-08 03:11:14 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Utils.h"
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Affine2D class.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
namespace EmberNs
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Uses matrix composition to handle the
|
|
|
|
/// affine matrix. Taken almost entirely from
|
|
|
|
/// Fractron, but using glm, and in C++.
|
|
|
|
/// Note that the matrix layout differs from flam3 so it's best to use
|
|
|
|
/// the A, B, C, D, E, F wrappers around the underlying matrix indices. But if the matrix must
|
|
|
|
/// be accessed directly, the two are laid out as such:
|
|
|
|
/// flam3: 3 columns of 2 rows each. Accessed col, row.
|
|
|
|
/// [a(0,0)][b(1,0)][c(2,0)]
|
|
|
|
/// [d(0,1)][e(1,1)][f(2,1)]
|
|
|
|
/// Ember: 2 columns of 3 rows each. Accessed col, row.
|
|
|
|
/// [a(0,0)][d(1,0)]
|
|
|
|
/// [b(0,1)][e(1,1)]
|
|
|
|
/// [c(0,2)][f(1,2)]
|
|
|
|
/// Template argument expected to be float or double.
|
|
|
|
/// </summary>
|
|
|
|
template <typename T>
|
|
|
|
class EMBER_API Affine2D
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Affine2D();
|
2014-09-01 00:25:15 -04:00
|
|
|
Affine2D(const Affine2D<T>& affine);
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Copy constructor to copy an Affine2D object of type U.
|
2014-09-01 00:25:15 -04:00
|
|
|
/// Special case that must be here in the header because it has
|
|
|
|
/// a second template parameter.
|
2014-07-08 03:11:14 -04:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="affine">The Affine2D object to copy</param>
|
|
|
|
template <typename U>
|
|
|
|
Affine2D(const Affine2D<U>& affine)
|
|
|
|
{
|
|
|
|
Affine2D<T>::operator=<U>(affine);
|
|
|
|
}
|
|
|
|
|
|
|
|
Affine2D(v2T& x, v2T& y, v2T& t);
|
|
|
|
Affine2D(T xx, T xy, T yx, T yy, T tx, T ty);
|
|
|
|
Affine2D(m4T& mat);
|
2014-09-01 00:25:15 -04:00
|
|
|
Affine2D<T>& operator = (const Affine2D<T>& affine);
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Assignment operator to assign an Affine2D object of type U.
|
2014-09-01 00:25:15 -04:00
|
|
|
/// Special case that must be here in the header because it has
|
|
|
|
/// a second template parameter.
|
2014-07-08 03:11:14 -04:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="affine">The Affine2D object to copy.</param>
|
|
|
|
/// <returns>Reference to updated self</returns>
|
|
|
|
template <typename U>
|
|
|
|
Affine2D<T>& operator = (const Affine2D<U>& affine)
|
|
|
|
{
|
|
|
|
A(T(affine.A()));
|
|
|
|
B(T(affine.B()));
|
|
|
|
C(T(affine.C()));
|
|
|
|
D(T(affine.D()));
|
|
|
|
E(T(affine.E()));
|
|
|
|
F(T(affine.F()));
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-01-25 14:12:49 -05:00
|
|
|
bool operator == (const Affine2D<T>& affine) const;
|
|
|
|
v2T operator * (const v2T& v) const;
|
|
|
|
Affine2D<T> operator * (T t) const;
|
2014-07-08 03:11:14 -04:00
|
|
|
|
2014-09-01 00:25:15 -04:00
|
|
|
void MakeID();
|
|
|
|
bool IsID() const;
|
|
|
|
bool IsZero() const;
|
2015-03-25 23:47:57 -04:00
|
|
|
bool IsEmpty() const;
|
2016-02-02 20:51:58 -05:00
|
|
|
void Scale(T amount);
|
--User changes
-Add a palette editor.
-Add support for reading .ugr/.gradient/.gradients palette files.
-Allow toggling on spinners whose minimum value is not zero.
-Allow toggling display of image, affines and grid.
-Add new variations: cylinder2, circlesplit, tile_log, truchet_fill, waves2_radial.
--Bug fixes
-cpow2 was wrong.
-Palettes with rapid changes in color would produce slightly different outputs from Apo/Chaotica. This was due to a long standing bug from flam3.
-Use exec() on Apple and show() on all other OSes for dialog boxes.
-Trying to render a sequence with no frames would crash.
-Selecting multiple xforms and rotating them would produce the wrong rotation.
-Better handling when parsing flames using different encoding, such as unicode and UTF-8.
-Switching between SP/DP didn't reselect the selected flame in the Library tab.
--Code changes
-Make all types concerning palettes be floats, including PaletteTableWidgetItem.
-PaletteTableWidgetItem is no longer templated because all palettes are float.
-Include the source colors for user created gradients.
-Change parallel_for() calls to work with very old versions of TBB which are lingering on some systems.
-Split conditional out of accumulation loop on the CPU for better performance.
-Vectorize summing when doing density filter for better performance.
-Make all usage of palettes be of type float, double is pointless.
-Allow palettes to reside in multiple folders, while ensuring only one of each name is added.
-Refactor some palette path searching code.
-Make ReadFile() throw and catch an exception if the file operation fails.
-A little extra safety in foci and foci3D with a call to Zeps().
-Cast to (real_t) in the OpenCL string for the w variation, which was having trouble compiling on Mac.
-Fixing missing comma between paths in InitPaletteList().
-Move Xml and PaletteList classes into cpp to shorten build times when working on them.
-Remove default param values for IterOpenCLKernelCreator<T>::SharedDataIndexDefines in cpp file.
-Change more NULL to nullptr.
2017-02-26 03:02:21 -05:00
|
|
|
void ScaleXY(T amount);
|
2016-02-02 20:51:58 -05:00
|
|
|
Affine2D<T> ScaleCopy(T amount);
|
2016-02-12 00:38:21 -05:00
|
|
|
void Rotate(T rad);
|
|
|
|
void RotateTrans(T rad);
|
2014-12-11 00:50:15 -05:00
|
|
|
void Translate(const v2T& v);
|
|
|
|
void RotateScaleXTo(const v2T& v);
|
|
|
|
void RotateScaleYTo(const v2T& v);
|
2014-09-01 00:25:15 -04:00
|
|
|
Affine2D<T> Inverse() const;
|
|
|
|
v2T TransformNormal(const v2T& v) const;
|
|
|
|
v2T TransformVector(const v2T& v) const;
|
|
|
|
m2T ToMat2ColMajor() const;
|
|
|
|
m2T ToMat2RowMajor() const;
|
|
|
|
m4T ToMat4ColMajor(bool center = false) const;
|
|
|
|
m4T ToMat4RowMajor(bool center = false) const;
|
2016-02-12 00:38:21 -05:00
|
|
|
m4T TransToMat4ColMajor() const;
|
2014-09-01 00:25:15 -04:00
|
|
|
|
2015-05-19 22:31:33 -04:00
|
|
|
//Note that returning a copy is actually faster than a const ref&.
|
2014-09-01 00:25:15 -04:00
|
|
|
T A() const;
|
|
|
|
T B() const;
|
|
|
|
T C() const;
|
|
|
|
T D() const;
|
|
|
|
T E() const;
|
|
|
|
T F() const;
|
|
|
|
|
|
|
|
void A(T a);
|
|
|
|
void B(T b);
|
|
|
|
void C(T c);
|
|
|
|
void D(T d);
|
|
|
|
void E(T e);
|
|
|
|
void F(T f);
|
|
|
|
|
|
|
|
v2T X() const;
|
|
|
|
v2T Y() const;
|
|
|
|
v2T O() const;
|
|
|
|
|
|
|
|
void X(const v2T& x);
|
|
|
|
void Y(const v2T& y);
|
|
|
|
void O(const v2T& t);
|
|
|
|
|
2016-02-12 00:38:21 -05:00
|
|
|
string ToString() const;
|
|
|
|
|
2014-09-01 00:25:15 -04:00
|
|
|
static Affine2D CalcRotateScale(const v2T& from, const v2T& to);
|
|
|
|
static void CalcRSAC(const v2T& from, const v2T& to, T& a, T& c);
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
m23T m_Mat;
|
|
|
|
};
|
2014-12-05 21:30:46 -05:00
|
|
|
}
|