1 /* FILE: Location.java
2 * DATE OF CREATION: Fri Jan 31 14:13:31 2003
3 * AUTHOR : Emmanuel Pietriga (emmanuel@w3.org)
4 * MODIF: Mon Feb 03 10:50:18 2003 by Emmanuel Pietriga
5 * Copyright (c) Emmanuel Pietriga, 2002. All Rights Reserved
6 * Licensed under the GNU LGPL. For full terms see the file COPYING.
7 */
8
9 package net.claribole.zvtm.engine;
10
11 import java.util.Vector;
12
13 import com.xerox.VTM.engine.LongPoint;
14
15 /**Mean to store a camera location - provides 2 long fields for X,Y and a float field for altitude*/
16
17 public class Location {
18
19
20 /**
21 * returns the difference betzeen two locations (l2-l1, how much to go from l1 to l2) as a vector whose first element is the altitude difference and second element is a LongPoint for X,Y difference
22 */
23 public static Vector getDifference(Location l1,Location l2){
24 Vector res=new Vector();
25 Float f=new Float(l2.getAltitude()-l1.getAltitude());
26 res.add(f);
27 LongPoint p=new LongPoint(l2.getX()-l1.getX(),l2.getY()-l1.getY());
28 res.add(p);
29 return res;
30 }
31
32 public static boolean equals(Location l1,Location l2){
33 if (l1.getX()==l2.getX() && l1.getY()==l2.getY() && l1.getAltitude()==l2.getAltitude()){return true;}
34 else return false;
35 }
36
37 public Location(long x,long y,float a){
38 vx=x;
39 vy=y;
40 alt=a;
41 }
42
43 /**a zvtm X coordinate*/
44 public long vx;
45
46 /**a zvtm Y coordinate*/
47 public long vy;
48
49 /**a zvtm altitude*/
50 public float alt;
51
52 public void setPosition(LongPoint p){
53 vx=p.x;
54 vy=p.y;
55 }
56
57 public void setPositionX(long x){
58 vx=x;
59 }
60
61 public void setPositionY(long y){
62 vy=y;
63 }
64
65 public void setAltitude(float a){
66 alt=a;
67 }
68
69 public LongPoint setPosition(){
70 return new LongPoint(vx,vy);
71 }
72
73 public long getX(){
74 return vx;
75 }
76
77 public long getY(){
78 return vy;
79 }
80
81 public float getAltitude(){
82 return alt;
83 }
84
85 public String toString(){
86 return "x="+vx+", y="+vy+", alt="+alt;
87 }
88
89 }