source: git/src/vector3.h @ c822014

RELEASE/1.1RELEASE/1.2debug-cidebug-ci-sanitisersfaster-cavernloglog-selectstereostereo-2025walls-datawalls-data-hanging-as-warningwarn-only-for-hanging-survey
Last change on this file since c822014 was f8e4c56, checked in by Mark Shinwell <mark>, 23 years ago

branch moving things

git-svn-id: file:///home/survex-svn/survex/branches/survex-1_1@2068 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100644
File size: 2.1 KB
Line 
1//
2//  vector3.h
3//
4//  C++ class for 3-element vectors
5//
6//  Copyright (C) 2000-2002, Mark R. Shinwell.
7//
8//  This program is free software; you can redistribute it and/or modify
9//  it under the terms of the GNU General Public License as published by
10//  the Free Software Foundation; either version 2 of the License, or
11//  (at your option) any later version.
12//
13//  This program is distributed in the hope that it will be useful,
14//  but WITHOUT ANY WARRANTY; without even the implied warranty of
15//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16//  GNU General Public License for more details.
17//
18//  You should have received a copy of the GNU General Public License
19//  along with this program; if not, write to the Free Software
20//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21//
22
23#ifndef Vector3_h
24#define Vector3_h
25
26#include <stdio.h>
27
28class Vector3 {
29    double x; //--FIXME
30    double y;
31    double z;
32
33public:
34    Vector3();
35    Vector3(double, double, double);
36    ~Vector3();
37
38    void Save(FILE* fp) { //--Pres: FIXME
39        fwrite(&x, sizeof(double), 1, fp);
40        fwrite(&y, sizeof(double), 1, fp);
41        fwrite(&z, sizeof(double), 1, fp);
42    }
43
44    void Load(FILE* fp) { //--Pres: FIXME
45        fread(&x, sizeof(double), 1, fp);
46        fread(&y, sizeof(double), 1, fp);
47        fread(&z, sizeof(double), 1, fp);
48    }
49
50    double getX() { return x; }
51    double getY() { return y; }
52    double getZ() { return z; }
53
54    double magnitude();
55    void normalise();
56
57    void set(double, double, double);
58
59    friend Vector3 operator-(const Vector3& v) {
60        Vector3 o;
61        o.x = -v.x;
62        o.y = -v.y;
63        o.z = -v.z;
64        return o;
65    }
66    Vector3& operator*=(const double);
67    Vector3& operator/=(const double);
68    Vector3& operator=(const Vector3&);
69
70    friend Vector3 operator*(const Vector3&, const double);
71    friend Vector3 operator*(const double, const Vector3&);
72    friend Vector3 operator*(const Vector3&, const Vector3&); // cross product
73    friend Vector3 operator+(const Vector3&, const Vector3&);
74    friend Vector3 operator-(const Vector3&, const Vector3&);
75    friend double dot(const Vector3&, const Vector3&);
76};
77
78#endif
Note: See TracBrowser for help on using the repository browser.