CiftiLib
A C++ library for CIFTI-2 and CIFTI-1 files
src
Common
Vector3D.h
1
#ifndef __VECTOR_3D_H__
2
#define __VECTOR_3D_H__
3
4
/*LICENSE_START*/
5
/*
6
* Copyright (c) 2014, Washington University School of Medicine
7
* All rights reserved.
8
*
9
* Redistribution and use in source and binary forms, with or without modification,
10
* are permitted provided that the following conditions are met:
11
*
12
* 1. Redistributions of source code must retain the above copyright notice,
13
* this list of conditions and the following disclaimer.
14
*
15
* 2. Redistributions in binary form must reproduce the above copyright notice,
16
* this list of conditions and the following disclaimer in the documentation
17
* and/or other materials provided with the distribution.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
#include <cstddef>
32
#include "stdint.h"
33
34
namespace
cifti
{
35
36
class
Vector3D
37
{
38
float
m_vec[3];
39
public
:
40
//vector functions
41
float
dot(
const
Vector3D
& right)
const
;
42
Vector3D
cross(
const
Vector3D
& right)
const
;
43
Vector3D
normal(
float
* origLength = NULL)
const
;
44
float
length()
const
;
45
float
lengthsquared()
const
;
46
//constructors
47
Vector3D
();
48
Vector3D
(
const
float
& x,
const
float
& y,
const
float
& z);
49
Vector3D
(
const
float
* right);
50
//compatibility operators
51
float
& operator[](
const
int64_t& index);
52
const
float
& operator[](
const
int64_t& index)
const
;
53
float
& operator[](
const
int32_t& index);
54
const
float
& operator[](
const
int32_t& index)
const
;
55
Vector3D
& operator=(
const
float
* right);
56
//numerical operators
57
Vector3D
& operator+=(
const
Vector3D
& right);
58
Vector3D
& operator-=(
const
Vector3D
& right);
59
Vector3D
& operator*=(
const
float
& right);
60
Vector3D
& operator/=(
const
float
& right);
61
Vector3D
operator+(
const
Vector3D
& right)
const
;
62
Vector3D
operator-(
const
Vector3D
& right)
const
;
63
Vector3D
operator-()
const
;
64
Vector3D
operator*(
const
float
& right)
const
;
65
Vector3D
operator/(
const
float
& right)
const
;
//NOTE: doesn't really make sense to have the other division, unlike multiplication
66
inline
operator
float
*() {
return
m_vec; }
67
};
68
69
Vector3D
operator*(
const
float
& left,
const
Vector3D
& right);
70
71
}
72
#endif //__VECTOR_3D_H__
cifti
namespace for all CiftiLib functionality
Definition:
CiftiBrainModelsMap.h:41
cifti::Vector3D
Definition:
Vector3D.h:36
Generated by
1.8.12