/* LICENSE:
  =========================================================================
    CMPack'04 Source Code Release for OPEN-R SDK 1.1.5-r2 for ERS7
    Copyright (C) 2004 Multirobot Lab [Project Head: Manuela Veloso]
    School of Computer Science, Carnegie Mellon University
    All rights reserved.
  ========================================================================= */

#ifndef INCLUDED_Sample_h
#define INCLUDED_Sample_h

#include "../../headers/Geometry.h"

class Sample {
public:
  // must use double for now
  typedef double Element;
  typedef GVector::vector2d<Element> vector2e;

  Element weight;
  vector2e loc;
  Element angle;

  // data for use by Sampler
  vector2e orig_loc;
  Element orig_angle;
  // end data for use by Sampler

  static const double AngleScale = 1000.0;

  //int line_idx; // for debug only

  void init() {loc.set(0.0,0.0); angle=0.0;}
  void normalize_for_mcmc() {angle *= AngleScale;}
  void normalize() {angle /= AngleScale;}

  // add a derivative to this sample
  void add_der_to_sample(const Sample *der);

  // these functions are related to using the Sample to store derivatives
  //   with respect to the sample variables

  void copy_der(const Sample *other_der); // make this derivative match another derivative
  void set_der_zero(); // set the derivative to zero
  void add_der(const Sample *other_der); // add another derivative to this one
  void scale_der(double val); // multiply the derivative by a scalar

  // these functions are related to momentums

  void random_momentum(Random &random); // initialize as a random momentum
  double sqlength(); // sum of squares of values
};

#endif
