⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vec2d.h

📁 傅立叶变换和小波变换是图像压缩的重要工具。该代大戏是利用小波变换进行图像压缩。
💻 H
字号:
#ifndef DRAWDRIVER_VEC2D_H
#define DRAWDRIVER_VEC2D_H

#include <crblib/inc.h>

//--------------------------------------------------------------------------------

typedef struct
{
	float x;
	float y;
} Vec2d;

float	REGCALL Vec2d_Length(const Vec2d *v);
float	REGCALL Vec2d_LenSquared(const Vec2d *v);
float	REGCALL Vec2d_Normalize(Vec2d *v);
void	REGCALL Vec2d_Perp(const Vec2d *fm,Vec2d *to);
float	REGCALL Vec2d_DotProduct(const Vec2d *a,const Vec2d *b);
float	REGCALL Vec2d_CrossProduct(const Vec2d *a,const Vec2d *b);
float	REGCALL Vec2d_InDirection(const Vec2d *vec,const Vec2d * normal,Vec2d *dir);

void	REGCALL Vec2d_PerpNormal(const Vec2d *p1,const Vec2d *p2,Vec2d *normal);

#define Vec2d_PerpDot	Vec2d_CrossProduct

void	REGCALL Vec2d_Set( Vec2d * V, float X, float Y ) ;

void	REGCALL Vec2d_Add( const Vec2d * pV1, const Vec2d * pV2, Vec2d * pV1PlusV2 ) ;
void	REGCALL Vec2d_Copy( const Vec2d *VSrc, Vec2d *VDst ) ;
void	REGCALL Vec2d_Clear( Vec2d *V ) ;
float	REGCALL Vec2d_DistanceBetween( const Vec2d *V1, const Vec2d *V2 ) ;
float	REGCALL Vec2d_DistBetweenSquared( const Vec2d *V1, const Vec2d *V2 );
void	REGCALL Vec2d_Scale( const Vec2d *VSrc, float fScale, Vec2d *VDst) ;
void	REGCALL Vec2d_Subtract( const Vec2d *V1, const Vec2d *V2, Vec2d *V1MinusV2 ) ;

			//(assuming positive X is along 3 o'clock and Y is along '12')
void	REGCALL Vec2d_Perp_Clockwise( const Vec2d *Src, Vec2d *Dst);
void	REGCALL Vec2d_Perp_CClockwise( const Vec2d *Src, Vec2d *Dst);
			// makes a perpendicular vector (as close to cross product as you get in 2d)
void	REGCALL Vec2d_Rotate( const Vec2d *pVec, float Radians, Vec2d *pDest);
			// rotates clockwise (!?)

int		REGCALL Vec2d_SideX(const Vec2d *pSeg1,const Vec2d *pSeg2,const Vec2d *pPoint);
			// -1 if point is to the left, +1 to the right, 0 is not in Y range
			// this is not oriented, its absolte X-lower is left

void REGCALL Vec2d_AddScaled(const Vec2d * v1,const Vec2d *v2,float v2scale,Vec2d *out);

extern const Vec2d ZeroVec2d ;
extern const Vec2d UnitXVec2d;
extern const Vec2d UnitYVec2d;

//--------------------------------------------------------------------------------

typedef struct
{
	Vec2d min,max;
} Box2d;

void	REGCALL Box2d_SetToPoint(Box2d *b,const Vec2d *v);
void	REGCALL Box2d_ExtendToEnclose(Box2d *b,const Vec2d *v);
bool	REGCALL Box2d_Intersects(const Box2d *b1,const Box2d *b2);

//--------------------------------------------------------------------------------

typedef struct
{
	Vec2d normal;
	float dist;
} Plane2d;

void	REGCALL Plane2d_Set(Plane2d * p,const Vec2d *point,const Vec2d *normal);
void	REGCALL Plane2d_SetFromCClockwise(Plane2d * p,const Vec2d *p1,const Vec2d *p2);
float	REGCALL Plane2d_Distance(const Plane2d * p,const Vec2d *v);
void	REGCALL Plane2d_GetPointOnPlane(const Plane2d * p,Vec2d *v);

bool Plane2d_SegmentIntersection(const Plane2d *p,const Vec2d * fm,const Vec2d *to,Vec2d *hit,float *pfrac);
bool Plane2d_ClipSeg(const Plane2d *p,Vec2d *p0,Vec2d *p1);

//--------------------------------------------------------------------------------

#endif // DRAWDRIVER_VEC2D_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -