-
Notifications
You must be signed in to change notification settings - Fork 15
/
PlanarSurface.hpp
66 lines (55 loc) · 2.14 KB
/
PlanarSurface.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef PLANAR_SURFACE_HPP
#define PLANAR_SURFACE_HPP
#include <boost/bind.hpp>
#include "Surface.hpp"
#include "Plane.hpp"
template<typename Ttraits_>
class PlanarSurface
: public BasicSurfaceImpl<Ttraits_, Plane<typename Ttraits_::world_type::traits_type::length_type> >
{
public:
typedef BasicSurfaceImpl<Ttraits_, Plane<typename Ttraits_::world_type::traits_type::length_type> > base_type;
typedef typename base_type::traits_type traits_type;
typedef typename base_type::identifier_type identifier_type;
typedef typename base_type::shape_type shape_type;
typedef typename base_type::rng_type rng_type;
typedef typename base_type::position_type position_type;
typedef typename base_type::length_type length_type;
virtual position_type random_position(rng_type& rng) const
{
return ::random_position(base_type::shape(), boost::bind(&rng_type::uniform, rng, -1., 1.));
}
virtual position_type random_vector(length_type const& r, rng_type& rng) const
{
return multiply(
normalize(
add(
multiply(
base_type::shape().units()[0], rng.uniform(-1., 1.)),
multiply(
base_type::shape().units()[1], rng.uniform(-1., 1.)))), r);
}
virtual position_type bd_displacement(length_type const& r, rng_type& rng) const
{
length_type const x(rng.normal(0., r)), y(rng.normal(0., r));
return add(
multiply(base_type::shape().unit_x(), x),
multiply(base_type::shape().unit_y(), y));
}
virtual length_type minimal_distance(length_type const& radius) const
{
// PlanarSurface has thickness of 0.
return radius * traits_type::MINIMAL_SEPARATION_FACTOR;
}
virtual void accept(ImmutativeStructureVisitor<traits_type> const& visitor) const
{
visitor(*this);
}
virtual void accept(MutativeStructureVisitor<traits_type> const& visitor)
{
visitor(*this);
}
PlanarSurface(identifier_type const& id, shape_type const& shape)
: base_type(id, shape) {}
};
#endif /* PLANAR_SURFACE_HPP */