Пример #1
0
template<> decimal manhattan_distance(const variant& p1, const variant& p2) {
	const std::vector<decimal>& v1 = p1.as_list_decimal();
	const std::vector<decimal>& v2 = p2.as_list_decimal();
	decimal x1 = v1[0] - v2[0];
	decimal x2 = v1[1] - v2[1];
	return (x1 < 0 ? -x1 : x1) + (x2 < 0 ? -x2 : x2);
}
Пример #2
0
rectf::rectf(const variant& value)
{
	std::vector<decimal> v = value.as_list_decimal();
	switch(v.size()) {
	case 2:
		*this = rectf::from_area(GLfloat(v[0].as_float()), GLfloat(v[1].as_float()), 0, 0);
		break;
	case 3:
		*this = rectf::from_area(GLfloat(v[0].as_float()), GLfloat(v[1].as_float()), GLfloat(v[2].as_float()), 0);
		break;
	case 4:
		*this = rectf::from_area(GLfloat(v[0].as_float()), GLfloat(v[1].as_float()), GLfloat(v[2].as_float()), GLfloat(v[3].as_float()));
		break;
	default:
		*this = rectf();
		break;
	}
}