~ubuntu-branches/ubuntu/saucy/python-demgengeo/saucy

« back to all changes in this revision

Viewing changes to src/SphereObj.cc

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2011-11-18 21:47:18 UTC
  • Revision ID: package-import@ubuntu.com-20111118214718-4ysqm3dhpqwdd7gd
Tags: upstream-0.99~bzr106
ImportĀ upstreamĀ versionĀ 0.99~bzr106

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////
 
2
//                                                         //
 
3
// Copyright (c) 2007-2011 by The University of Queensland //
 
4
// Earth Systems Science Computational Centre (ESSCC)      //
 
5
// http://www.uq.edu.au/esscc                              //
 
6
//                                                         //
 
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          //
 
10
//                                                         //
 
11
/////////////////////////////////////////////////////////////
 
12
 
 
13
#include "SphereObj.h"
 
14
 
 
15
    void SphereObj::insert(Vector3 pos, double radius, MNTable3D* table,int tag,int id) {
 
16
      
 
17
      // First list all (only 1 in this case) sphere locations relative to the
 
18
      // middle of the "empty space"
 
19
      Vector3 sphere_origin(0,0,0);
 
20
 
 
21
      // Rotate each one through all axis using the rotate function as below
 
22
      //
 
23
      // The below will do nothing, but is an example of what to do with more
 
24
      // complex shapes with multiple spheres.
 
25
      if ( this->useRandomOrientation() ) {
 
26
        this->setRandomOrientation();
 
27
        sphere_origin = this->rotatePoint(sphere_origin);
 
28
      }
 
29
 
 
30
      // Translate all spheres to the given position
 
31
      sphere_origin = sphere_origin + pos;
 
32
      
 
33
      // Expand radius from unit circle to actual given radius for each circle
 
34
      // For example a circle that has radius 1/4 of unit circle should  get
 
35
      // radius 0.25f*radius.
 
36
      double r = radius*1.0f;
 
37
 
 
38
      // Finally insert all spheres and bonds where relevant.
 
39
      Sphere Sc(sphere_origin, r);
 
40
      if ( table->checkInsertable(Sc,id) ) {
 
41
        Sc.setTag(tag);
 
42
        table->insert(Sc,id);
 
43
      }
 
44
    }
 
45
    void SphereObj::setBias(int factor) {
 
46
      this->bias_factor = factor;
 
47
    }
 
48
    int SphereObj::bias() {
 
49
      return this->bias_factor;
 
50
    }