STIR 6.4.0
Shape3D.inl
Go to the documentation of this file.
1//
2//
3/*
4 Copyright (C) 2000- 2009, Hammersmith Imanet Ltd
5 This file is part of STIR.
6
7 SPDX-License-Identifier: Apache-2.0
8
9 See STIR/LICENSE.txt for details
10*/
20
21START_NAMESPACE_STIR
22
23Shape3D::Shape3D()
24 : origin(0, 0, 0)
25{}
26
27Shape3D::Shape3D(const CartesianCoordinate3D<float>& origin)
28 : origin(origin)
29{}
30
31bool
32Shape3D::operator==(const Shape3D& s) const
33{
34 return norm(this->origin - s.origin) < .001F;
35}
36
37bool
38Shape3D::operator!=(const Shape3D& s) const
39{
40 return !(*this == s);
41}
42
43void
45{
47 translate(old_origin * (-1));
48 scale(scale3D);
49 translate(old_origin);
50 assert((norm(get_origin()) == 0 && norm(old_origin) == 0) || norm(get_origin() - old_origin) < norm(get_origin()) * 10E-5);
51}
52
55{
56 return origin;
57}
58
59END_NAMESPACE_STIR
a templated class for 3-dimensional coordinates.
Definition CartesianCoordinate3D.h:53
virtual void translate(const CartesianCoordinate3D< float > &direction)
translate the whole shape by shifting its origin
Definition Shape3D.cxx:49
virtual bool operator==(const Shape3D &) const =0
Compare shapes.
Definition Shape3D.inl:32
bool operator!=(const Shape3D &) const
Compare shapes.
Definition Shape3D.inl:38
void scale_around_origin(const CartesianCoordinate3D< float > &scale3D)
scale the whole shape, keeping the centre at the same place
Definition Shape3D.inl:44
virtual void scale(const CartesianCoordinate3D< float > &scale3D)=0
scale the whole shape
CartesianCoordinate3D< float > get_origin() const
get the origin of the shape-coordinate system
Definition Shape3D.inl:54
double norm(const BasicCoordinate< num_dimensions, coordT > &p1)
compute sqrt(inner_product(p1,p1))
Definition BasicCoordinate.inl:426