00001 #ifndef _FLOWGRID_H_
00002 #define _FLOWGRID_H_
00003
00004 #include "cml/cml.h"
00005
00014 class FlowGrid
00015 {
00016
00017 public:
00018 float *m_data;
00019
00020 float m_width;
00021 float m_height;
00022
00023 float m_sampleSize;
00024
00025 float m_xNCcoef;
00026 float m_yNCcoef;
00027
00028 float m_widthRR;
00029 float m_heightRR;
00030
00031 float m_aspectRatio;
00032
00033 float RealXToNC(float realX) const;
00034 float RealYToNC(float realY) const;
00035
00036 float RealXToRNC(float realX) const;
00037 float RealYToRNC(float realY) const;
00038
00039 float NCXToReal(float ncX) const;
00040 float NCYToReal(float ncY) const;
00041
00042 float RNCXToReal(float rncX) const;
00043 float RNCYToReal(float rncY) const;
00044
00045 float NCXToRNCX(float ncX) const;
00046 float NCYToRNCY(float ncY) const;
00047
00048 float RNCXToNCX(float rncX) const;
00049 float RNCYToNCY(float rncY) const;
00050
00051 float GetValue(int x, int y, int cnt) const;
00052 float GetValueX(int *coords) { return GetValue(coords[0], coords[1], 0); }
00053 float GetValueY(int *coords) { return GetValue(coords[0], coords[1], 1); }
00054
00055 float Interpolate(int cnt, float x, float y, int *tl, int *bl, int *br, int *tr) const;
00056 public:
00057 FlowGrid();
00058
00059 void Initialize(float widthRR, float heightRR, int width, int height, int sampleSize, float *data);
00060
00061 float GetVelocityMagnitudeRNC(float x, float y) const;
00062 float GetVelocityMagnitudeNC(float x, float y) const;
00063 float GetVelocityMagnitude(float x, float y) const;
00064 float GetVelocityMagnitudeRR(float x, float y) const;
00065
00066 cml::vector2f GetVelocityVector(float x, float y) const;
00067 cml::vector2f GetVelocityVectorRNC(float x, float y) const;
00068 cml::vector2f GetVelocityVectorNC(float x, float y) const;
00069 cml::vector2f GetVelocityVectorRR(float x, float y) const;
00070
00071 cml::vector2f GetRRFromNC(cml::vector2f ncCoords) const;
00072 cml::vector2f GetNCFromRR(cml::vector2f rrCoords) const;
00073
00074 float GetX(float x, float y) const;
00075 float GetY(float x, float y) const;
00076
00077 float GetXNC(float x, float y) const;
00078 float GetYNC(float x, float y) const;
00079
00080 float GetXRNC(float x, float y) const;
00081 float GetYRNC(float x, float y) const;
00082
00083 bool IsValidRR(cml::vector2f rrCoords) { return (rrCoords[0] >= 0 && rrCoords[1] >=0 && rrCoords[0] < GetWidthRR() && rrCoords[1] < GetHeightRR()); }
00084
00085
00086 int GetWidth() const;
00087 int GetHeight() const;
00088
00089
00090 float GetWidthRNC() const;
00091 float GetHeightRNC() const;
00092
00093
00094 float GetWidthNC() const;
00095 float GetHeightNC() const;
00096
00097
00098 float GetWidthRR() const { return m_widthRR; }
00099 float GetHeightRR() const { return m_heightRR; }
00100 };
00101
00102 #endif