ALBA
albaGeometryUtils.h
Go to the documentation of this file.
1/*=========================================================================
2Program: ALBA (Agile Library for Biomedical Applications)
3Module: albaGeometryUtils.h
4Language: C++
5Date: $Date: 2022-01-01 12:00:00 $
6Version: $Revision: 1.0.0.0 $
7Authors: Nicola Vanella
8==========================================================================
9Copyright (c) BIC-IOR 2021 (https://github.com/IOR-BIC)
10
11This software is distributed WITHOUT ANY WARRANTY; without even
12the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13PURPOSE. See the above copyright notice for more information.
14=========================================================================*/
15
16#ifndef __albaGeometryUtils_h
17#define __albaGeometryUtils_h
18
19//----------------------------------------------------------------------------
20// includes :
21
22//----------------------------------------------------------------------------
23// forward declarations
24class vtkPlane;
25class vtkLinearTransform;
26
31{
32protected:
33 enum { X, Y, Z, };
34 enum { XY, YZ, XZ, };
35
36public:
37
38 static double Dot(double *point1, double *point2);
39 static double Mag(double *point1);
40
41 static float Norm2(double *point1);
42 static double Norm(double *point1);
43
44 static void Cross(double *point1, double *point2, double* cross);
45
46
47 static bool Equal(double *point1, double *point2);
48
49 static double DistanceBetweenPoints(double *point1, double *point2);
50
51 static void GetMidPoint(double(&midPoint)[3], double *point1, double *point2);
52
53 /*plane default 0=XY, 1=YZ, 2=XZ*/
54 static double DistancePointToLine(double * point, double * lineP1, double * lineP2, int plane = XY);
55
56 /*plane default 0=XY, 1=YZ, 2=XZ*/
57 static double GetAngle(double* point1, double* point2, double* origin, int plane = XY);
58 static double GetAngle(double point1[3], double point2[3]);
59
60 /*plane default 0=XY, 1=YZ, 2=XZ*/
61 static void RotatePoint(double *point, double *origin, double angle, int plane = XY);
62
64
65 static bool GetLineLineIntersection(double(&point)[3], double *line1Point1, double *line1Point2, double *line2Point1, double *line2Point2, int plane = XY);
66
67 static int IntersectLineLine(double *l1p1, double *l1p2, double *l2p1, double *l2p2, double &perc);
68
69 /*plane default 0=XY, 1=YZ, 2=XZ*/
70 static void GetParallelLine(double(&point1)[3], double(&point2)[3], double *linePoint1, double *linePoint2, double distance, int plane = XY);
71
72 static bool FindPointOnLine(double(&point)[3], double *linePoint1, double *linePoint2, double distance, int plane = XY);
73
74 /*Returns 1 if the point is up, -1 if is down and 0 if the point is in the line(plane default 0 = XY, 1 = YZ, 2 = XZ) */
75 static int PointUpDownLine(double *point, double *lp1, double *lp2, int plane = XY);
76
77 /* Takes a plane and a transform and outputs the plane transformed into the input space */
78 static void PlaneToInputSpace(vtkPlane *inputPlane, vtkLinearTransform *inputTransform, vtkPlane *outputPlane);
79};
80#endif
Class Name: albaGeometryUtils.
static bool FindPointOnLine(double(&point)[3], double *linePoint1, double *linePoint2, double distance, int plane=XY)
static bool GetLineLineIntersection(double(&point)[3], double *line1Point1, double *line1Point2, double *line2Point1, double *line2Point2, int plane=XY)
Lines.
static void Cross(double *point1, double *point2, double *cross)
static void GetParallelLine(double(&point1)[3], double(&point2)[3], double *linePoint1, double *linePoint2, double distance, int plane=XY)
static void RotatePoint(double *point, double *origin, double angle, int plane=XY)
static float Norm2(double *point1)
static void GetMidPoint(double(&midPoint)[3], double *point1, double *point2)
static double Mag(double *point1)
static bool Equal(double *point1, double *point2)
static double Dot(double *point1, double *point2)
static double GetAngle(double *point1, double *point2, double *origin, int plane=XY)
static int IntersectLineLine(double *l1p1, double *l1p2, double *l2p1, double *l2p2, double &perc)
static void PlaneToInputSpace(vtkPlane *inputPlane, vtkLinearTransform *inputTransform, vtkPlane *outputPlane)
static double DistancePointToLine(double *point, double *lineP1, double *lineP2, int plane=XY)
static double DistanceBetweenPoints(double *point1, double *point2)
static int PointUpDownLine(double *point, double *lp1, double *lp2, int plane=XY)
static double Norm(double *point1)
static double GetAngle(double point1[3], double point2[3])