You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
3.7 KiB
C++
129 lines
3.7 KiB
C++
#pragma once
|
|
#include "MLMicroStructureExport.h"
|
|
class MLBox;
|
|
class MLLine;
|
|
class MLMICROSTRUCTURE_EXPORT MLVector
|
|
{
|
|
public:
|
|
MLVector(void);
|
|
MLVector(double vx, double vy, double vz = 0.0, bool valid_in = true);
|
|
~MLVector(void);
|
|
|
|
static const MLVector invalid;
|
|
static const MLVector nullVector;
|
|
|
|
// ÔŞËŘĘý
|
|
__declspec(property(get=getX, put = setX)) double x;
|
|
__declspec(property(get=getY, put = setY)) double y;
|
|
__declspec(property(get=getZ, put = setZ)) double z;
|
|
__declspec(property(get=getValid, put = setValid)) bool valid;
|
|
|
|
public:
|
|
// Sets new values for the vector and makes the vector valid.
|
|
inline void set(double vx, double vy, double vz = 0.0) ;
|
|
|
|
void setPolar(double radius, double angle);
|
|
|
|
bool isValid() const;
|
|
|
|
bool isInside(const MLBox& b) const;
|
|
|
|
//bool equalsFuzzy(const MLVector& v, double tol = MLCore::PointTolerance) const;
|
|
|
|
double getDistanceTo(const MLVector& v) const;
|
|
|
|
double getDistanceTo2d(const MLVector& v) const;
|
|
|
|
void setAngle(double a);
|
|
|
|
double getAngle() const;
|
|
|
|
double getAngleToPlaneXY() const;
|
|
|
|
double getAngleTo(const MLVector& v) const;
|
|
|
|
void setMagnitude2d(double m);
|
|
|
|
double getMagnitude() const;
|
|
|
|
double getSquaredMagnitude() const;
|
|
|
|
double getMagnitude2d() const;
|
|
|
|
MLVector getLerp(const MLVector& v, double t) const;
|
|
|
|
MLVector getUnitVector() const;
|
|
|
|
void setX(double x);
|
|
double getX() const;
|
|
double& getX();
|
|
|
|
void setY(double y);
|
|
double getY() const;
|
|
double& getY();
|
|
|
|
void setZ(double z);
|
|
double getZ() const;
|
|
double& getZ();
|
|
|
|
void setValid(bool valid);
|
|
bool getValid() const;
|
|
|
|
bool isInWindow(const MLVector& firstCorner, const MLVector& secondCorner);
|
|
|
|
MLVector operator + (const MLVector& v) const;
|
|
MLVector operator - (const MLVector& v) const;
|
|
MLVector operator * (double s) const;
|
|
MLVector operator / (double s) const;
|
|
MLVector operator - () const;
|
|
|
|
void operator += (const MLVector& v);
|
|
void operator -= (const MLVector& v);
|
|
void operator *= (double s);
|
|
void operator /= (double s);
|
|
|
|
bool operator ==(const MLVector& v) const;
|
|
bool operator !=(const MLVector& v) const;
|
|
|
|
MLVector getNegated() const;
|
|
MLVector normalize();
|
|
MLVector getNormalized() const;
|
|
MLVector getFloor() const;
|
|
MLVector getCeil() const;
|
|
MLVector move(const MLVector& offset);
|
|
|
|
static MLVector getCrossProduct(const MLVector& v1, const MLVector& v2);
|
|
static double getDotProduct(const MLVector& v1, const MLVector& v2);
|
|
static MLVector createPolar(double radius, double angle);
|
|
static MLVector getMinimum(const MLVector& v1, const MLVector& v2);
|
|
static MLVector getMaximum(const MLVector& v1, const MLVector& v2);
|
|
static MLVector getAverage(const MLVector& v1, const MLVector& v2);
|
|
|
|
MLVector rotate(double rotation);
|
|
MLVector rotate(double rotation, const MLVector& center);
|
|
MLVector rotate3d(const MLLine& axis, double rotation);
|
|
//MLVector rotate3d(const QQuaternion& quaternion);
|
|
|
|
MLVector scale(double factor, const MLVector& center=nullVector);
|
|
MLVector scale(const MLVector& factors, const MLVector& center=nullVector);
|
|
|
|
MLVector mirror(const MLLine& axis);
|
|
MLVector mirror(const MLVector& axis1, const MLVector& axis2);
|
|
MLVector flipHorizontal();
|
|
MLVector flipVertical();
|
|
//MLVector stretch(const MLPolyline& area, const MLVector& offset);
|
|
/*
|
|
static void moveList(std::vector<MLVector>& list, const MLVector& offset);
|
|
static void rotateList(std::vector<MLVector>& list, double rotation);
|
|
static void rotateList(std::vector<MLVector>& list, double rotation, const MLVector& center);
|
|
static void scaleList(std::vector<MLVector>& list, double factor, const MLVector& center=nullVector);
|
|
static void scaleList(std::vector<MLVector>& list, const MLVector& factors, const MLVector& center=nullVector);
|
|
*/
|
|
protected:
|
|
double m_x;
|
|
double m_y;
|
|
double m_z;
|
|
bool m_valid;
|
|
};
|
|
|