My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
package com.badlogic.gamedev.spaceinvaders.simulation;

import java.io.Serializable;

import android.util.FloatMath;

public class Vector implements Serializable
{
public float x, y, z;

public Vector( float x, float y, float z )
{
this.x = x;
this.y = y;
this.z = z;
}

public Vector( )
{
x = y = z = 0;
}

public Vector( Vector v )
{
set( v );
}

public void set( Vector v )
{
this.x = v.x;
this.y = v.y;
this.z = v.z;
}

public Vector add( Vector v )
{
this.x += v.x;
this.y += v.y;
this.z += v.z;
return this;
}

public Vector sub( Vector v )
{
this.x -= v.x;
this.y -= v.y;
this.z -= v.z;
return this;
}

public void set(float x, float y, float z)
{
this.x = x;
this.y = y;
this.z = z;
}

public float distance(Vector v)
{
float a = v.x - x;
float b = v.y - y;
float c = v.z - z;
return FloatMath.sqrt( a * a + b * b + c * c );
}
}

Change log

r54 by quantumgame on Jan 14, 2010   Diff
[No log message]
Go to: 
Project members, sign in to write a code review

Older revisions

r43 by quantumgame on Jan 11, 2010   Diff
[No log message]
r35 by quantumgame on Jan 10, 2010   Diff
[No log message]
r34 by quantumgame on Jan 10, 2010   Diff
[No log message]
All revisions of this file

File info

Size: 919 bytes, 65 lines
Powered by Google Project Hosting