You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
5.0 KiB

#ifndef ARITH_UTILS_H
#define ARITH_UTILS_H
#pragma once
#include "Arith_SysStruct.h"
// 使用哈希表来记录每个非零数字的出现次数
typedef struct tagHashEntry
{
int key;
int count;
} HashEntry;
typedef struct tagHashMap
{
HashEntry* entries;
int capacity;
int size;
} HashMap;
// 矩阵加法
void AddMat(double* A, double* B, int mn, double* AaddB);
// 矩阵乘法
void MultiMat(double* A, double* B, double* AB, int m, int n, int p);
// M1(3*3) * M2(3*3)
void MultiMat33(double* A, double* B, double* AB);
// M1(3*3) * M2(3*3) * M3(3*3)
void MultiMat333(double* A, double* B, double* C, double* ABC);
// 标量乘以矩阵
void MultiMatScalar(double scalar, double* A, double* sA, int mn);
// 矩阵转置
void TransposeMat(double* A, int m, int n, double* AT);
// 3阶矩阵逆不判断逆是否存在
void invMat3(double* A, double* invA);
// 获得三阶单位阵
void eye3(double* M);
// 绕X轴旋转矩阵
void Rx(double omega, double* Opp);
// 绕Y轴旋转矩阵
void Ry(double omega, double* Opp);
// 绕Z轴旋转矩阵
void Rz(double omega, double* Opp);
// 镜面反射矩阵
void RMirror(PointXYZ normalVec, double* Opp);
// 坐标(矢量)旋转: M1(3*3) * M2(3,1)
PointXYZ RtPoint(double* M, PointXYZ Point);
// 坐标(矢量)归一化
PointXYZ NormPoint(PointXYZ Point);
// 罗得里格公式
void rotationVectorToMatrix(PointXYZ rotaVec_One, float rotaAgl, double* Mat);
/*************************************
* Method: findMostFrequentNonZero()
* Function Description:
* CreateData: 2025/1/8
* Input Param: int arr[]:
* Input Param: int size:
* Input Param: int clsMaxNum:
* Input Param: float * MostFrequentratio:
* Output Param:
* Return: int:
* Call Relation:
* Other Description:
*************************************/
int findMostFrequentNonZero(int arr[], int size, int *clsMaxNum, float* MostFrequentratio);
/*************************************
* Method: count2To0Transitions()
* Function Description: 21
* CreateData: 2025/1/8
* Input Param: int arr[]
* Input Param: int size
* Output Param:
* Return: int
* Call Relation:
* Other Description:
*************************************/
int count2To0Transitions(int arr[], int size);
/*************************************
* Method: checkCondition()
* Function Description: 211frmThresh
* CreateData: 2025/1/8
* Input Param: int arr[]
* Input Param: int size
* Input Param: int frmThresh
* Output Param:
* Return: bool
* Call Relation:
* Other Description:
*************************************/
bool checkXToYCondition(int arr[], int size, int x, int y, int frmThresh);
/*************************************
* Method: countNumberFreq()
* Function Description: number
* CreateData: 2025/1/8
* Input Param: int arr[]
* Input Param: int size
* Input Param: int number
* Output Param:
* Return: int
* Call Relation:
* Other Description:
*************************************/
int countNumberFreq(int arr[], int size, int number);
/*************************************
* Method: Cosine_Similarity()
* Function Description: size
* CreateData: 2025/2/7
* Input Param: float * A
* Input Param: float * B
* Input Param: int size
* Output Param:
* Return: float
* Call Relation:
* Other Description:
*************************************/
float Cosine_Similarity(float* A, float* B, int size);
// 获取动态库所在路径
std::string GetDynamicLibraryPath();
/*************************************
* Method: Save_RunImg()
* Function Description:
* CreateData: 2025/3/11
* Input Param: GD_VIDEO_FRAME_S img:
* Input Param: SINT32 nControlerFrmNum:
* Output Param:
* Return: void
* Call Relation:
* Other Description:
*************************************/
void Save_RunImg(GD_VIDEO_FRAME_S img, SINT32 nControlerFrmNum);
/**********************************************************
* SERVO_CorrectAngleScale()
* 0°360°
* FLOAT32 fAngle --
*
* FLOAT32 fAngleCorrect --
*
* -180°0°180°(= -180°)0°180°
**********************************************************/
FLOAT32 SERVO_CorrectAngleScale(FLOAT32 fAngle);
#endif