//-------------------------------------------------------------------------
//                  Sampling methods for SO(3)
//-------------------------------------------------------------------------
//
// Copyright (c) 2003 University of Illinois and Steven M. LaValle
// All rights reserved.
//
// Developed by:                Motion Strategy Laboratory
//                              University of Illinois
//                              http://msl.cs.uiuc.edu/msl/
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal with the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
//     * Redistributions of source code must retain the above copyright 
//       notice, this list of conditions and the following disclaimers.
//     * Redistributions in binary form must reproduce the above copyright 
//       notice, this list of conditions and the following disclaimers in 
//       the documentation and/or other materials provided with the 
//       distribution.
//     * Neither the names of the Motion Strategy Laboratory, University
//       of Illinois, nor the names of its contributors may be used to 
//       endorse or promote products derived from this Software without 
//       specific prior written permission.
//
// The software is provided "as is", without warranty of any kind,
// express or implied, including but not limited to the warranties of
// merchantability, fitness for a particular purpose and
// noninfringement.  In no event shall the contributors or copyright
// holders be liable for any claim, damages or other liability, whether
// in an action of contract, tort or otherwise, arising from, out of or
// in connection with the software or the use of other dealings with the
// software.
//
//-------------------------------------------------------------------------

#ifndef PRMNEW_H 
#define PRMNEW_H 

#include <queue>

#include "random.h"
#include "vector.h"

#ifndef PI
#define PI 3.1415926535897932385
#endif 


class Sample{
 protected:
  MSLRandomSource R;

  vector<int *> order;

  int numCubes;
  int numVert;
  MSLVector **v;				// vertices of the hyper cube

  MSLVector RandomState(int dim);		// random quaternion sequence
  MSLVector QuatState(int i);			// deterministic grid sequences

  MSLVector DiscGridSample(int i, int dim);	// Sukharev grid sequence
  MSLVector Choose3dState(int i, int dim);	// layered Sukharev grid sequence

  MSLVector LinearInterpolate(MSLVector x1, MSLVector x2, double a);	// spherical linear interpolation
  void transform(MSLVector a, int faceIndex, MSLVector &qrsample);	// spherical sample using baricentric coordinates of the cube vertices

  void readOrder();				// reads order on faces from a file
  void readV();					// produces the orderings sequence on the vertices of the inscribed cube

  static const int RandomQuaternions = 1;
  static const int SukGriSequence = 2;
  static const int LaySukGriSequence = 3;

  int SampleMethod;
 public:

  //! A constructor that initializes data members.
  Sample(int smethod);

  //! Empty destructor
  virtual ~Sample() {};

  //! Generation of a sequence element with index i
  virtual MSLVector ChooseState(int i);
};


#endif

