23 #ifndef PT_SCENE_ADAPTER_H
24 #define PT_SCENE_ADAPTER_H
50 if(!infer_head) { assert(d <= 1); }
53 case 0:
return target.
trajectory()[frame - 1]->value.position[0];
54 case 1:
return target.
trajectory()[frame - 1]->value.position[2];
55 case 2:
return target.
trajectory()[frame - 1]->value.body_dir;
56 case 3:
return target.
trajectory()[frame - 1]->value.face_dir[0];
57 case 4:
return target.
trajectory()[frame - 1]->value.face_dir[1];
61 "Cannot get variable: bad index");
84 double px = target.
trajectory()[frame - 1]->value.position[0];
85 double pz = target.
trajectory()[frame - 1]->value.position[2];
90 double fd1 = target.
trajectory()[frame - 1]->value.face_dir[0];
91 double fd2 = target.
trajectory()[frame - 1]->value.face_dir[1];
102 scene, target, frame,
Vector3(x, 0.0, pz), vo, infer_head);
106 scene, target, frame,
Vector3(px, 0.0, x), vo, infer_head);
113 scene, target, frame,
Vector2(x, fd2), vo);
117 scene, target, frame,
Vector2(fd1, x), vo);
122 "Cannot set variable: bad index");
151 scene, target, frame,
Vector3(dx, 0.0, 0.0), vo, infer_head);
155 scene, target, frame,
Vector3(0.0, 0.0, dx), vo, infer_head);
162 scene, target, frame,
Vector2(dx, 0.0), vo);
166 scene, target, frame,
Vector2(0.0, dx), vo);
171 "Cannot move variable: bad index");
189 m_infer_head(infer_head)
193 double get(
const Scene* s,
size_t i)
const
198 *s, *tgt_ps_[
i], frames_[i], dims_[i], m_infer_head);
207 *s, *tgt_ps_[i], frames_[i], dims_[i], x, m_vis_off, m_infer_head);
211 void set(
Scene* s,
size_t i,
size_t j,
double x,
double y)
const
215 std::cerr <<
"Scene_adapter::set received same index" << std::endl;
236 return tgt_ps_.size();
240 void reset()
const { scene_p_ = 0; }
243 std::pair<const Target*, size_t>
246 if(i >=
size(s))
return std::make_pair((
const Target*)0, 0);
248 return std::make_pair(tgt_ps_[i], frames_[i]);
256 void compute_vars(
const Scene* s)
const;
259 mutable const Scene* scene_p_;
260 mutable std::vector<const Target*> tgt_ps_;
261 mutable std::vector<size_t> frames_;
262 mutable std::vector<size_t> dims_;
void set(Scene *s, size_t i, size_t j, double x, double y) const
Set the ith element of a scene to x.
Definition: pt_scene_adapter.h:211
void set_trajectory_face_dir_at_frame(const Scene &scene, const Target &target, size_t frame, const Vector2 &dir, bool vis_off)
Function that changes a single face direction at a single frame, and performs all the necessary updat...
Definition: pt_scene.cpp:373
std::pair< const Target *, size_t > target_frame(const Scene *s, size_t i) const
Get target and frame corresponding to variable i.
Definition: pt_scene_adapter.h:244
Adapts a Scene into a VectorModel for HMC sampling.
Definition: pt_scene_adapter.h:183
Vector_d< 3 > Vector3
Definition: g_quaternion.h:37
void set_variable_at_frame(const Scene &scene, const Target &target, size_t frame, size_t d, double x, bool vo, bool infer_head)
Sets the scene at the given variable. Here, d = 1 ... 5 represents the different parts of the traject...
Definition: pt_scene_adapter.h:73
Trajectory & trajectory() const
Get this target's current 3D positions.
Definition: pt_target.h:85
Scene_adapter(bool vis_off=false, bool infer_head=true)
Definition: pt_scene_adapter.h:186
Class that represents a full scene in the PT universe.
Definition: pt_scene.h:40
void swap(Scene &s1, Scene &s2)
Swap two scenes.
Definition: pt_scene.h:69
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
void move_variable_at_frame(const Scene &scene, const Target &target, size_t frame, size_t d, double dx, bool vo, bool infer_head)
Moves the scene at the given variable. Here, d = 1 ... 5 represents the different parts of the trajec...
Definition: pt_scene_adapter.h:134
#define IFT(a, ex, msg)
Definition: l_exception.h:101
void move_trajectory_at_frame(const Scene &scene, const Target &target, size_t frame, const Vector3 &dv, bool vis_off, bool infer_head=true)
Function that moves a single trajectory at a single frame, and performs all the necessary updates...
Definition: pt_scene.h:307
double get_variable_at_frame(const Scene &scene, const Target &target, size_t frame, size_t d, size_t infer_head)
Gets the scene at the given variable. Here, d = 1 ... 5 represents the different parts of the traject...
Definition: pt_scene_adapter.h:42
void reset() const
Restart state.
Definition: pt_scene_adapter.h:240
x
Definition: APPgetLargeConnectedEdges.m:100
void set_trajectory_at_frame(const Scene &scene, const Target &target, size_t frame, const Vector3 &v, bool vis_off, bool infer_head=true)
Function that changes a single trajectory at a single frame, and performs all the necessary updates...
Definition: pt_scene.cpp:210
Class that represents a target moving through space.
Definition: pt_target.h:50
#define KJB_THROW_2(ex, msg)
Definition: l_exception.h:48
void move_trajectory_face_dir_at_frame(const Scene &scene, const Target &target, size_t frame, const Vector2 &dd, bool vis_off)
Function that moves a single face direction at a single frame, and performs all the necessary updates...
Definition: pt_scene.h:458
void swap(kjb::Gsl_Multimin_fdf &m1, kjb::Gsl_Multimin_fdf &m2)
Swap two wrapped multimin objects.
Definition: gsl_multimin.h:693
bool infer_head() const
Returns whether inferring head or not.
Definition: pt_scene_adapter.h:252
void set(Scene *s, size_t i, double x) const
Set the ith element of a scene to x.
Definition: pt_scene_adapter.h:202
void set_trajectory_dir_at_frame(const Scene &scene, const Target &target, size_t frame, double dir, bool vis_off)
Function that changes a single direction at a single frame, and performs all the necessary updates...
Definition: pt_scene.cpp:295
Object thrown when an argument to a function is not acceptable.
Definition: l_exception.h:377
size_t size(const Scene *s) const
Get the number of elements in this scene.
Definition: pt_scene_adapter.h:233
get the indices of edges in each direction for i
Definition: APPgetLargeConnectedEdges.m:48
Vector_d< 2 > Vector2
Definition: gr_opengl.h:35
Object thrown when computation fails somehow during execution.
Definition: l_exception.h:321
void move_trajectory_dir_at_frame(const Scene &scene, const Target &target, size_t frame, double dd, bool vis_off)
Function that moves a single direction at a single frame, and performs all the necessary updates...
Definition: pt_scene.h:384