View Javadoc

1   package cz.cuni.amis.pogamut.usar2004.communication.messages.datatypes;
2   
3   import cz.cuni.amis.pogamut.base3d.worldview.object.Location;
4   import cz.cuni.amis.pogamut.base3d.worldview.object.Rotation;
5   
6   /**
7    * OBSOLETE - GETSTARTPOSES is now obsolete, use STARTPOSES instead Double six
8    * dimension Point originaly used for storing StartPoses obtained from server
9    * when GETSTARTPOSES command was sent.
10   *
11   * @author vejmanm
12   */
13  public class Point6d
14  {
15      double first = 0, second = 0, third = 0, fourth = 0, fifth = 0, sixth = 0;
16  
17      public Point6d(double f1, double f2, double f3, double f4, double f5, double f6)
18      {
19          this.first = f1;
20          this.second = f2;
21          this.third = f3;
22          this.fourth = f4;
23          this.fifth = f5;
24          this.sixth = f6;
25      }
26  
27      /**
28       *
29       * @param f Array size of 6
30       *
31       * @throws RuntimeException Too little array
32       */
33      public Point6d(double[] f)
34      {
35          if(f.length >= 6)
36          {
37              this.first = f[0];
38              this.second = f[1];
39              this.third = f[2];
40              this.fourth = f[3];
41              this.fifth = f[4];
42              this.sixth = f[5];
43          }
44          else
45          {
46              throw new RuntimeException("Too little array!");
47          }
48      }
49  
50      public Point6d(Point6d f)
51      {
52          this.first = f.first;
53          this.second = f.second;
54          this.third = f.third;
55          this.fourth = f.fourth;
56          this.fifth = f.fifth;
57          this.sixth = f.sixth;
58  
59      }
60  
61      @Override
62      public String toString()
63      {
64          return "(" + this.first + ", " + this.second + ", " + this.third + ", " + this.fourth + ", " + this.fifth + ", " + this.sixth + ")";
65      }
66  
67      public double getFirst()
68      {
69          return first;
70      }
71  
72      public double getSecond()
73      {
74          return second;
75      }
76  
77      public double getThird()
78      {
79          return third;
80      }
81  
82      public double getFourth()
83      {
84          return fourth;
85      }
86  
87      public double getFifth()
88      {
89          return fifth;
90      }
91  
92      public double getSixth()
93      {
94          return sixth;
95      }
96  
97      public Location getLocation()
98      {
99          return new Location(this.first, this.second, this.third);
100     }
101 
102     public Rotation getRotation()
103     {
104         return new Rotation(this.fourth, this.fifth, this.sixth);
105     }
106 
107     public final void set(double f1, double f2, double f3, double f4, double f5, double f6)
108     {
109         this.first = f1;
110         this.second = f2;
111         this.third = f3;
112         this.fourth = f4;
113         this.fifth = f5;
114         this.sixth = f6;
115     }
116 
117     /**
118      *
119      * @param f Array size of 6
120      *
121      * @throws RuntimeException Too little array
122      */
123     public final void set(double[] f)
124     {
125         if(f.length >= 6)
126         {
127             this.first = f[0];
128             this.second = f[1];
129             this.third = f[2];
130             this.fourth = f[3];
131             this.fifth = f[4];
132             this.sixth = f[5];
133         }
134         else
135         {
136             throw new RuntimeException("Too little array!");
137         }
138     }
139 
140     public final double[] toArray()
141     {
142         return new double[]
143                 {
144                     first, second, third, fourth, fifth, sixth
145                 };
146     }
147 }