File size: 4,536 Bytes
68ce2fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-    */
/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */

/*
  Author(s):	Anton Deguet
  Created on:	2005-01-31

  (C) Copyright 2005-2020 Johns Hopkins University (JHU), All Rights Reserved.

--- begin cisst license - do not edit ---

This software is provided "as is" under an open source license, with
no warranty.  The complete license can be found in license.txt and
http://www.cisst.org/cisst/license.txt.

--- end cisst license ---

*/


#include <cisstCommon/cmnConstants.h>

#include <cisstVector/vctRandom.h>

#include <cisstVector/vctMatrixRotation3Base.h>
#include <cisstVector/vctQuaternionRotation3Base.h>
#include <cisstVector/vctAxisAngleRotation3.h>
#include <cisstVector/vctRodriguezRotation3.h>

#include <cisstVector/vctMatrixRotation2Base.h>
#include <cisstVector/vctAngleRotation2.h>


template <class _containerType>
void vctRandom(vctMatrixRotation3Base<_containerType> & matrixRotation) {
    typedef typename _containerType::value_type value_type;
    vctQuaternionRotation3Base<vctFixedSizeVector<value_type, 4> > quaternionRotation;
    vctRandom(quaternionRotation);
    matrixRotation.From(quaternionRotation);
}

template void vctRandom(vctMatrixRotation3Base<vctFixedSizeMatrix<double, 3, 3, VCT_ROW_MAJOR> > &);
template void vctRandom(vctMatrixRotation3Base<vctFixedSizeMatrix<float, 3, 3, VCT_ROW_MAJOR> > &);
template void vctRandom(vctMatrixRotation3Base<vctFixedSizeMatrix<double, 3, 3, VCT_COL_MAJOR> > &);
template void vctRandom(vctMatrixRotation3Base<vctFixedSizeMatrix<float, 3, 3, VCT_COL_MAJOR> > &);
template void vctRandom(vctMatrixRotation3Base<vctFixedSizeMatrixRef<double, 3, 3, 4, 1> > &);
template void vctRandom(vctMatrixRotation3Base<vctFixedSizeMatrixRef<double, 3, 3, 1, 4> > &);
template void vctRandom(vctMatrixRotation3Base<vctFixedSizeMatrixRef<float, 3, 3, 4, 1> > &);
template void vctRandom(vctMatrixRotation3Base<vctFixedSizeMatrixRef<float, 3, 3, 1, 4> > &);


template <class _containerType>
void vctRandom(vctQuaternionRotation3Base<_containerType> & quaternionRotation) {
    typedef typename _containerType::value_type value_type;
    vctRandom(quaternionRotation, (value_type) -1.0, (value_type) 1.0);
    quaternionRotation.NormalizedSelf();
}

template void vctRandom(vctQuaternionRotation3Base<vctFixedSizeVector<double, 4> > &);
template void vctRandom(vctQuaternionRotation3Base<vctFixedSizeVector<float, 4> > &);



template <class _elementType>
void vctRandom(vctAxisAngleRotation3<_elementType> & axisAngleRotation) {
    typedef _elementType value_type;
    vctQuaternionRotation3Base<vctFixedSizeVector<value_type, 4> > quaternionRotation;
    vctRandom(quaternionRotation);
    axisAngleRotation.FromRaw(quaternionRotation);
}

template void vctRandom(vctAxisAngleRotation3<double> &);
template void vctRandom(vctAxisAngleRotation3<float> &);



template <class _containerType>
void vctRandom(vctRodriguezRotation3Base<_containerType> & rodriguezRotation) {
    typedef typename _containerType::value_type value_type;
    vctAxisAngleRotation3<value_type> axisAngleRotation;
    vctRandom(axisAngleRotation);
    rodriguezRotation.FromRaw(axisAngleRotation);
}

template void vctRandom(vctRodriguezRotation3Base<vctFixedSizeVector<double, 3> > &);
template void vctRandom(vctRodriguezRotation3Base<vctFixedSizeVector<float, 3> > &);



template <vctEulerRotation3Order::OrderType _order>
void vctRandom(vctEulerRotation3<_order> & eulerRotation) {
    vctRandom(eulerRotation.GetAngles(), -cmnPI, cmnPI);
}

template void vctRandom(vctEulerRotation3<vctEulerRotation3Order::ZYZ> &);
template void vctRandom(vctEulerRotation3<vctEulerRotation3Order::ZYX> &);
template void vctRandom(vctEulerRotation3<vctEulerRotation3Order::ZXZ> &);
template void vctRandom(vctEulerRotation3<vctEulerRotation3Order::YZX> &);



template <class _containerType>
void vctRandom(vctMatrixRotation2Base<_containerType> & matrixRotation) {
    vctAngleRotation2 angleRotation;
    vctRandom(angleRotation);
    matrixRotation.From(angleRotation);
}

template void vctRandom(vctMatrixRotation2Base<vctFixedSizeMatrix<double, 2, 2> > &);
template void vctRandom(vctMatrixRotation2Base<vctFixedSizeMatrix<float, 2, 2> > &);



void vctRandom(vctAngleRotation2 & angleRotation) {
    cmnRandomSequence & randomSequence = cmnRandomSequence::GetInstance();
    randomSequence.ExtractRandomValue(0.0, 2 * cmnPI,
                                      angleRotation.Angle());
}