geometry.h

来自「this a Navier-Stokes equations solver. I」· C头文件 代码 · 共 41 行

H
41
字号
#ifndef _GEOMERTY_H_
#define _GEOMETRY_H_

template<class T>
struct point
{
	point():x(0),y(0){}
	point(T _x,T _y):x(_x),y(_y){}

	T x;
	T y;
};

template<class T>
point<T> inline operator - (const point<T> &a,const point<T> &b)
{
	return point<T>(a.x - b.x, a.y - b.y);
}

template<class T,class P>
point<T> inline operator / (const point<T> &a,const point<P> &b)
{
	return point<T>(a.x / b.x, a.y / b.y)
}

template<class T>
struct rect
{
	point<T> a;
	point<T> b;

	bool inline inside(const point<T> &p){
		return p.x >= a.x && p.x < b.x && p.y >= a.y && p.y < b.y;
	}
	bool inline inclusive_inside(const point<T> &p){
		return p.x >= a.x && p.x <= b.x && p.y >= a.y && p.y <= b.y;
	}
};

#endif

⌨️ 快捷键说明

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