20 lines
401 B
C++
20 lines
401 B
C++
#include <psemek/vecr/circle.hpp>
|
|
|
|
namespace psemek::vecr
|
|
{
|
|
|
|
sdf_sample sdf(circle const & s, geom::point<float, 2> const & p)
|
|
{
|
|
auto r = p - s.center;
|
|
auto l = geom::length(r);
|
|
if (l > 0.f)
|
|
return {l - s.radius, r / l};
|
|
return {l - s.radius, {0.f, 0.f}};
|
|
}
|
|
|
|
geom::box<float, 2> bbox(circle const & s)
|
|
{
|
|
return geom::expand(geom::box<float, 2>::singleton(s.center), s.radius);
|
|
}
|
|
|
|
}
|