📄 utils.h
字号:
/*
Copyright (C) 2001 Tsinghuaeolus
Authors : ChenJiang, YaoJinyi, CaiYunpeng, Lishi
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
If you make any changes or have any comments we would appreciate a
message to yjy01@mails.tsinghua.edu.cn.
*/
#ifndef _utils
#define _utils
extern int enable_my_error;
extern void my_error(char*,...);
#define DoLogData logdata.LogAction
#define _LOG
#ifdef _LOG
#define DoLog rec.LogAction
//#define DoRecord(x) NULL
#define DoRecord recmsg.LogAction
#else
#define DoLog(x) NULL
#define DoRecord(x) NULL
#endif
/********** String *****************************/
extern double get_double(char **str_ptr);
extern double get_double(char *str);
extern float get_float (char **str_ptr);
extern float get_float (char *str);
extern int get_int (char **str_ptr);
extern int get_int (char *str);
extern void get_word (char **str_ptr);
extern void get_next_word (char **str_ptr);
extern void get_token (char **str_ptr);
extern void advance_to(char c, char **str_ptr);
extern void advance_past_space(char **str_ptr);
extern void get_to_left_blanket(char **str_ptr);
extern void get_to_right_blanket(char **str_ptr);
/******** Mathematics *********************************/
extern inline float NormalizeAngle(float ang, float min = -180.0f);
extern inline float Rad2Deg(float x);
extern inline float Deg2Rad(float x);
extern inline float Cos(float deg);
extern inline float Sin(float deg);
extern inline float Tan(float deg);
extern inline float ATan(float x);
extern inline float ATan2(float x, float y);
extern inline float ASin(float x);
extern inline float ACos(float x);
extern inline float random0_1();
extern inline int random(int max);
extern inline bool chance(float luck);
extern inline bool halfchance();
extern int QuadraticFormula(float a, float b, float c, float& psol1, float& psol2);
extern inline float Exp(float x, float t);
template<class T> inline const T Min(const T& x, const T& y){
return x < y ? x : y;
}
template<class T> inline const T Max(const T& x, const T& y){
return x > y ? x : y;
}
template<class T> inline void Swap(T& x, T& y){
T tmp =x; x = y; y = tmp;
}
extern void pose_limitation(float& x, float min, float max);
extern float Angle_distance(float a1, float a2);
extern int Angle_between( float ang, float low, float up );
extern int IsNegativeInf(float x);
extern float priority_sum(float priority1, float priority2);
extern float priority_sub(float priority1, float priority2);
extern float LowPassFilter(float passfreq,float cutfreq,float currentfreq);
extern float HighPassFilter(float cutfreq,float passfreq,float currentfreq);
extern float MidAngle2(float angle,float angle_inf);
extern float MidAngle(float angle,float angle_inf);
extern float AngleDif(float angle1,float angle2);
#define round(x) ((x)>0?int((x)+0.5f):int((x)-0.5f))
#define Quantize(v,q) ((round((v)/(q)))*(q))
#define Constrain(x,min,max) Min(max,Max(min,(x)))
#define Sqr(x) ((x)*(x))
#define Idx(No) ((No) - 1)
extern void GetOptions(int,char**);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -