1
/////////////////////////////////////////////////////////////
3
// Copyright (c) 2007-2011 by The University of Queensland //
4
// Earth Systems Science Computational Centre (ESSCC) //
5
// http://www.uq.edu.au/esscc //
7
// Primary Business: Brisbane, Queensland, Australia //
8
// Licensed under the Open Software License version 3.0 //
9
// http://www.opensource.org/licenses/osl-3.0.php //
11
/////////////////////////////////////////////////////////////
24
this->randomOrientation = 0;
32
* Tell the shape to be randomly orientated. This will make every object
33
* have a random orientation
34
* \param i 1 for using random orientation, 0 to disable
36
void Shape::makeOrientationRandom(int i) {
37
this->randomOrientation = i;
41
* Returns 1 if the shape is to be randomly orientated
42
* \returns 1 if shape is to be randomly orientated
44
int Shape::useRandomOrientation() {
45
return this->randomOrientation;
50
* Sets a random orientation. Note that this will be run before every
51
* insert if the appropriate function is called.
53
void Shape::setRandomOrientation() {
60
* Set a random pitch to the object
62
void Shape::setRandomPitch() {
63
this->pitch = (rand() % 180) - 90;
67
* Set a random yaw to the object
69
void Shape::setRandomYaw() {
70
this->yaw = (rand() % 360) - 180;
74
* Set a random roll to the object
76
void Shape::setRandomRoll() {
77
this->roll = (rand() % 360) - 180;
81
* Rotate a point around the x, y and z axies. Rotation values are given
82
* using setRoll functions etc.
83
* \param point the point to rotate
84
* \returns the rotated point
86
Vector3 Shape::rotatePoint(Vector3 point) {
87
double roll = this->roll *M_PI/180;
88
double yaw = this->yaw *M_PI/180;
89
double pitch = this->pitch *M_PI/180;
91
double x = (cos(yaw)*cos(roll)+sin(yaw)*sin(pitch)*sin(roll))* point.x()
92
+ (-sin(yaw)*cos(pitch)) * point.y()
93
+ (sin(yaw)*sin(pitch)*cos(roll)-cos(yaw)*sin(roll))* point.z();
94
double y = (sin(yaw)*cos(roll)-cos(yaw)*sin(pitch)*sin(roll))* point.x()
95
+ (cos(yaw)*cos(pitch)) * point.y()
96
+ (-cos(yaw)*sin(pitch)*cos(roll)-sin(yaw)*sin(roll))*point.z();
97
double z = (cos(pitch)*sin(roll))*point.x()
98
+ (sin(pitch)*point.y())
99
+ (cos(pitch)*cos(roll))*point.y();
100
Vector3 newpoint(x,y,z);
102
Vector3 newpoint = point.rotate(Vector3(roll,yaw,pitch),Vector3(0,0,0));
106
int Shape::bias() { return this->bias_factor; }
108
void Shape::setBias(int i) {
109
this->bias_factor = i;
112
void Shape::setPitch(double pitch) { this->pitch = pitch; }
113
double Shape::getPitch() { return this->pitch; }
114
void Shape::setYaw(double yaw) { this->yaw = yaw; }
115
double Shape::getYaw() { return this->yaw; }
116
void Shape::setRoll(double roll) { this->roll = roll; }
117
double Shape::getRoll() { return this->roll; }
120
void Shape::setBondTag(int tag) { bondTag = tag; }
121
int Shape::getBondTag() { return bondTag; }
122
void Shape::setParticleTag(int tag) { particleTag = tag; }
123
int Shape::getParticleTag() { return particleTag; }