Beispiel #1
0
		std::list<location_component*> environment::nearest(point2 postion, unsigned int radius)
		{
			std::list<location_component*> list;
			m_space->find(postion.x(), postion.y(), radius, [&](int, int, location_component* component)
			{
				list.push_back(component);
			});
			return list;
		}
Beispiel #2
0
double line2::distance_from_segment_to_point(point2 const& point) const
{
	delta2 v = p2 - p1;
	delta2 w = point - p1;
	
	double c1 = w.dot(v);
	if(c1 <= 0)
		return point.distance(p1);
	
	double c2 = v.dot(v);
	if(c2 <= c1)
		return point.distance(p2);
	
	double b = c1 / c2;
	point2 Pb = p1 + v * b;
	return point.distance(Pb);
}
Beispiel #3
0
double line2::distance_from_line_to_point(point2 const& point) const
{
	delta2 v = p2 - p1;
	delta2 w = point - p1;
	
	double c1 = w.dot(v);
	double c2 = v.dot(v);
	double b = c1 / c2;
	
	point2 Pb = p1 + v * b;
	return point.distance(Pb);
}
void AABB2D::AddPoint( const point2& p )
{
	if ( p.x() > m_Max.x )
	{
		m_Max.x = p.x();
	}
	else if ( p.x() < m_Min.x )
	{
		m_Min.x = p.x();
	}

	if ( p.y() > m_Max.y )
	{
		m_Max.y = p.y();
	}
	else if ( p.y() < m_Min.y )
	{
		m_Min.y = p.y();
	}

	m_Len.x = std::abs(m_Max.x - m_Min.x);
	m_Len.y = std::abs(m_Max.y - m_Min.y);;
}
Beispiel #5
0
		int environment::distance(point2 const& a, point2 const& b) const
		{
			return a.king_distance(b);
		}
Vec2 Point2toVec2( const point2& p )
{
	return Vec2( p.x(), p.y() );
}
Beispiel #7
0
	constexpr point2<T> inverted_scale(point2<T> a, vec2<T> b)
	{
		a.inverted_scale(b);
		return a;
	}
Beispiel #8
0
	constexpr point2<T> scale(point2<T> a, vec2<T> b)
	{
		a.scale(b);
		return a;
	}
void VectorGraphics::arc_negative(point2 p, length r, plane_angle a1, plane_angle a2) {
    cairo_arc_negative(cr(), p.x()/meters, p.y()/meters, r/meters, a1/radians, a2/radians);
}
void VectorGraphics::rectangle(point2 p1, point2 p2) {
    cairo_rectangle(cr(), p1.x()/meters, p1.y()/meters, (p2.x()-p1.x())/meters, (p2.y()-p1.y())/meters);
}
void VectorGraphics::line_to(point2 p) {
    cairo_line_to(cr(), p.x()/meters, p.y()/meters);
}