VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
GbPoint3D.cpp
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
33//=======================================================================================
34#include <GbPoint3D.h>
35using namespace std;
36
37/*=======================================================*/
39{
40 this->x1 = 0.0;
41 this->x2 = 0.0;
42 this->x3 = 0.0;
43}
44/*=======================================================*/
45GbPoint3D::GbPoint3D(const double &x1, const double &x2, const double &x3)
46{
47 this->x1 = x1;
48 this->x2 = x2;
49 this->x3 = x3;
50}
51/*=======================================================*/
53{
54 this->x1 = point->x1;
55 this->x2 = point->x2;
56 this->x3 = point->x3;
57}
58/*=======================================================*/
60{
61 double dx1 = this->x1 - p->x1;
62 double dx2 = this->x2 - p->x2;
63 double dx3 = this->x3 - p->x3;
64 return std::sqrt(dx1 * dx1 + dx2 * dx2 + dx3 * dx3);
65}
66/*=======================================================*/
68{
69 if (fabs(this->x1 - point->x1) > 1.E-10)
70 return false;
71 if (fabs(this->x2 - point->x2) > 1.E-10)
72 return false;
73 if (fabs(this->x3 - point->x3) > 1.E-10)
74 return false;
75
76 return true;
77}
78/*=======================================================*/
79void GbPoint3D::transform(const double matrix[4][4])
80{
81 double tempX1 = x1;
82 double tempX2 = x2;
83 double tempX3 = x3;
84 x1 = matrix[0][0] * tempX1 + matrix[0][1] * tempX2 + matrix[0][2] * tempX3 + matrix[0][3] * 1.;
85 x2 = matrix[1][0] * tempX1 + matrix[1][1] * tempX2 + matrix[1][2] * tempX3 + matrix[1][3] * 1.;
86 x3 = matrix[2][0] * tempX1 + matrix[2][1] * tempX2 + matrix[2][2] * tempX3 + matrix[2][3] * 1.;
87}
88/*=======================================================*/
89bool GbPoint3D::isPointInGbObject3D(const double &x1, const double &x2, const double &x3)
90{
91 return (fabs(x1) < 1.E-13 && fabs(x2) < 1.E-13 && fabs(x3) < 1.E-13);
92}
93/*=======================================================*/
94bool GbPoint3D::isPointInGbObject3D(const double &x1, const double &x2, const double &x3, bool &pointIsOnBoundary)
95{
96 pointIsOnBoundary = (fabs(x1) < 1.E-13 && fabs(x2) < 1.E-13 && fabs(x3) < 1.E-13);
97 return pointIsOnBoundary;
98}
99/*=======================================================*/
101{
102 cout << "GbPoint3D::getSurfaceTriangleSet() - test ... if no exception occurs, everything is fine\n";
103 vector<GbTriangle3D *> triangles;
104 return triangles; //<-empty vector! is okay!
105
106 // old:
107 // to avoid unnecessary exceptions a point will generate a triangle with
108 // c3 point with same coordinates
109 // vector<GbTriangle3D*> triangles;
110 // GbPoint3D p1(getX1Coordinate(),getX2Coordinate(),getX3Coordinate());
111 // triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p1),new GbPoint3D(p1)));
112}
113/*=======================================================*/
115{
116 throw UbException(UB_EXARGS, "not implemented");
117}
118/*=======================================================*/
120{
122 ss << "GbPoint3D[" << this->x1 << "," << this->x2 << "," << this->x3 << "]";
123 return ((ss.str()).c_str());
124}
125/*=======================================================*/
126void GbPoint3D::translate(const double &dx1, const double &dx2, const double &dx3)
127{
128 this->x1 += dx1;
129 this->x2 += dx2;
130 this->x3 += dx3;
132}
133/*=======================================================*/
134void GbPoint3D::rotate(const double &rx1, const double &rx2, const double &rx3)
135{
136 double newX1 = cos(rx3) * cos(rx2) * x1 - x2 * sin(rx3) * cos(rx1) + x2 * cos(rx3) * sin(rx2) * sin(rx1) +
137 x3 * sin(rx3) * sin(rx1) + x3 * cos(rx3) * sin(rx2) * cos(rx1);
138 double newX2 = sin(rx3) * cos(rx2) * x1 + x2 * cos(rx3) * cos(rx1) + x2 * sin(rx3) * sin(rx2) * sin(rx1) -
139 x3 * cos(rx3) * sin(rx1) + x3 * sin(rx3) * sin(rx2) * cos(rx1);
140 double newX3 = -sin(rx2) * x1 + cos(rx2) * sin(rx1) * x2 + cos(rx2) * cos(rx1) * x3;
141
142 this->x1 = newX1;
143 this->x2 = newX2;
144 this->x3 = newX3;
146}
147/*=======================================================*/
148void GbPoint3D::scale(const double &sx1, const double &sx2, const double &sx3)
149{
150 this->x1 *= sx1;
151 this->x2 *= sx2;
152 this->x3 *= sx3;
154}
155/*=======================================================*/
156
This Class provides basic 3D line objects.
Definition GbLine3D.h:59
This Class provides basic 3D point objects.
Definition GbPoint3D.h:49
double x1
Definition GbPoint3D.h:121
double x3
Definition GbPoint3D.h:123
double x2
Definition GbPoint3D.h:122
virtual void notifyObserversObjectChanged()
std::shared_ptr< T > SPtr
bool isPointInGbObject3D(const double &x1, const double &x2, const double &x3, bool &pointIsOnBoundary) override
Definition GbPoint3D.cpp:94
void scale(const double &sx1, const double &sx2, const double &sx3) override
void translate(const double &x1, const double &x2, const double &x3) override
double getDistance(GbPoint3D *p)
Definition GbPoint3D.cpp:59
void transform(const double matrix[4][4])
Definition GbPoint3D.cpp:79
bool equals(const GbPoint3D *point) const
Definition GbPoint3D.cpp:67
GbLine3D * createClippedLine3D(GbPoint3D &point1, GbPoint3D &point2) override
void rotate(const double &rx1, const double &rx2, const double &rx3) override
std::vector< GbTriangle3D * > getSurfaceTriangleSet() override
std::string toString() override
#define UB_EXARGS
Definition UbException.h:73