其他分享
首页 > 其他分享> > VTKMath 常用接口整理

VTKMath 常用接口整理

作者:互联网

VTKMath 常用接口整理

  1. 定义常量π

    static constexpr double [Pi]()() { return 3.141592653589793; }
    
  2. 浮点型四舍五入为整形

    static int Round(float f) { return static_cast<int>(f + (f >= 0.0 ? 0.5 : -0.5)); }
    static int Round(double f) { return static_cast<int>(f + (f >= 0.0 ? 0.5 : -0.5)); }
    
  3. double转为其他类型,且保证转换后的值在类型允许数值范围内

    static void RoundDoubleToIntegralIfNecessary(double val, OutT* ret)
    
  4. 判断两个数之中最大值/最小值

    static T Min(const T& a, const T& b);
    static T Max(const T& a, const T& b);
    
  5. 阶乘

    static vtkTypeInt64 Factorial(int N);
    
  6. T1 赋值 T2

    static void Assign(const VectorT1& a, VectorT2&& b)
    static void Assign(const double a[3], double b[3]) { vtkMath::Assign<>(a, b); }
    
  7. float与double数组的 加减乘

    static void Add(const float a[3], const float b[3], float c[3]);
    static void Add(const double a[3], const double b[3], double c[3]);
    static void Subtract(const float a[3], const float b[3], float c[3]);
    static void Subtract(const double a[3], const double b[3], double c[3])
    static void MultiplyScalar(float a[3], float s);
    static void MultiplyScalar2D(float a[2], float s);
    static void MultiplyScalar(double a[3], double s);
    static void MultiplyScalar2D(double a[2], double s);
    
  8. 点积、叉积与外积

    static float Dot(const float a[3], const float b[3]);
    static double Dot(const double a[3], const double b[3]);
    static float Dot2D(const float x[2], const float y[2]); 
    static double Dot2D(const double x[2], const double y[2]); 
    static void Cross(const float a[3], const float b[3], float c[3]);
    static void Cross(const double a[3], const double b[3], double c[3]);
    static void Outer(const float a[3], const float b[3], float c[3] [3]);
    static void Outer(const double a[3], const double b[3], double c[3][3]);
    static void Outer2D(const float x[2], const float y[2], float A[2] [2])
    static void Outer2D(const double x[2], const double y[2], double A[2][2])
    
  9. 计算向量模

    static float Norm(const float* x, int n);
    static double Norm(const double* x, int n);
    static float Norm(const float v[3]);
    static double Norm(const double v[3]);
    static float Norm2D(const float x[2]);
    static double Norm2D(const double x[2]);
    
  10. 给定一个向量v1,找出两个向量v2和v3,使向量相互垂直

    static void Perpendiculars(const double v1[3], double v2[3], double v3[3], double theta);
    static void Perpendiculars(const float v1[3], float v2[3], float v3[3], double theta);
    
  11. 计算 三维/二维 向量A在向量B上的投影

    static bool ProjectVector(const float a[3], const float b[3], float projection[3]);
    static bool ProjectVector(const double a[3], const double b[3], double projection[3]);
    static bool ProjectVector2D(const float a[2], const float b[2], float projection[2]);
    static bool ProjectVector2D(const double a[2], const double b[2], double projection[2]);
    
  12. 计算两点间距离

    static float Distance2BetweenPoints(const float p1[3], const float p2[3]);
    static double Distance2BetweenPoints(const double p1[3], const double p2[3]);
    
  13. 计算两个向量间的弧度角

    static double AngleBetweenVectors(const double v1[3], const double v2[3]);
    
  14. 计算2x2矩阵

    static float Determinant2x2(const float c1[2], const float c2[2]);
    static double Determinant2x2(double a, double b, double c, double d);
    static double Determinant2x2(const double c1[2], const double c2[2]);
    
  15. 3x3矩阵转为四元数

    static void QuaternionToMatrix3x3(const float quat[4], float A[3][3]);
    static void QuaternionToMatrix3x3(const double quat[4], double A[3][3]);
    
  16. 用WXYZ旋转一个向量

    static void RotateVectorByWXYZ(const float v[3], const float q[4], float r[3]);
    static void RotateVectorByWXYZ(const double v[3], const double q[4], double r[3]);
    
  17. RGB(红、绿、蓝)、HSV(色调、饱和度、明度)互相转换

    static void RGBToHSV(const float rgb[3], float hsv[3])
    static void RGBToHSV(float r, float g, float b, float* h, float* s, float* v);
    static void RGBToHSV(const double rgb[3], double hsv[3])
    static void RGBToHSV(double r, double g, double b, double* h, double* s, double* v);
    static void HSVToRGB(const float hsv[3], float rgb[3])
    static void HSVToRGB(float h, float s, float v, float* r, float* g, float* b);
    static void HSVToRGB(const double hsv[3], double rgb[3])
    static void HSVToRGB(double h, double s, double v, double* r, double* g, double* b);
    
  18. 边界初始化

    static void UninitializeBounds(double bounds[6])
    {
    	bounds[0] = 1.0;
    	bounds[1] = -1.0;
    	bounds[2] = 1.0;
    	bounds[3] = -1.0;
    	bounds[4] = 1.0;
    	bounds[5] = -1.0;
    }
    
  19. 判断边界是否初始化

    static vtkTypeBool AreBoundsInitialized(const double bounds[6])
    {
        if (bounds[1] - bounds[0] < 0.0)
        {	
            return 0;
        }
        return 1;
    }
    
  20. v 小于 min ,则返回 min ;若 v 大于 max ,则返回 max ;否则返回 v

    static T ClampValue(const T& value, const T& min, const T& max);
    static void ClampValue(double* value, const double range[2]);
    static void ClampValue(double value, const double range[2], double* clamped_value);
    static void ClampValues(double* values, int nb_values, const double range[2]);
    static void ClampValues(const double* values, int nb_values, const double range[2], double* clamped_values);
    
  21. 判断范围在范围内,边界在边界内,点在边界内

    static vtkTypeBool ExtentIsWithinOtherExtent(const int extent1[6], const int extent2[6]);
    static vtkTypeBool BoundsIsWithinOtherBounds(
    const double bounds1[6], const double bounds2[6], const double delta[3]);
    static vtkTypeBool PointIsWithinBounds(const double point[3], const double bounds[6], const double delta[3]);
    
  22. 三点计算圆心

    static double Solve3PointCircle(const double p1[3], const double p2[3], const double p3[3], double center[3]);
    

标签:常用,const,double,void,float,bounds,接口,static,VTKMath
来源: https://blog.csdn.net/Kir1hara/article/details/123109641