aboutsummaryrefslogtreecommitdiff
path: root/dep/g3dlite/source/Vector3int16.cpp
blob: 3c9c5dc9295ec43682f20c3e87cfe36115ab8634 (plain)
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
/**
 @file Vector3int16.cpp
 
 @author Morgan McGuire, http://graphics.cs.williams.edu
  
 @created 2003-04-07
 @edited  2006-01-17
 */

#include "G3D/platform.h"
#include "G3D/g3dmath.h"
#include "G3D/Vector3int16.h"
#include "G3D/Vector3.h"
#include "G3D/BinaryInput.h"
#include "G3D/BinaryOutput.h"
#include "G3D/format.h"

namespace G3D {

Vector3int16::Vector3int16(const class Vector3& v) {
    x = (int16)iFloor(v.x + 0.5);
    y = (int16)iFloor(v.y + 0.5);
    z = (int16)iFloor(v.z + 0.5);
}


Vector3int16::Vector3int16(class BinaryInput& bi) {
    deserialize(bi);
}


void Vector3int16::serialize(class BinaryOutput& bo) const {
    bo.writeInt16(x);
    bo.writeInt16(y);
    bo.writeInt16(z);
}


void Vector3int16::deserialize(class BinaryInput& bi) {
    x = bi.readInt16();
    y = bi.readInt16();
    z = bi.readInt16();
}

std::string Vector3int16::toString() const {
    return G3D::format("(%d, %d, %d)", x, y, z);
}

    
Vector3int16 Vector3int16::floor(const Vector3& v) {
    return Vector3int16(iFloor(v.x), iFloor(v.y), iFloor(v.z));
}


Vector3int16 Vector3int16::ceil(const Vector3& v) {
    return Vector3int16(iCeil(v.x), iCeil(v.y), iCeil(v.z));
}

}