-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathV_EdgeMetric.cpp
56 lines (45 loc) · 1.54 KB
/
V_EdgeMetric.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*=========================================================================
Module: V_EdgeMetric.cpp
Copyright 2003,2006,2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
Under the terms of Contract DE-NA0003525 with NTESS,
the U.S. Government retains certain rights in this software.
See LICENSE for details.
=========================================================================*/
/*
*
* V_EdgeMetric.cpp contains quality calculations for edges
*
* This file is part of VERDICT
*
*/
#include "verdict.h"
#include <math.h>
namespace VERDICT_NAMESPACE
{
/*!\brief Length of and edge.
* Length is calculated by taking the distance between the end nodes.
*/
VERDICT_HOST_DEVICE double edge_length(int num_nodes, const double coordinates[][3])
{
double edge_length = 0.0;
if (2 == num_nodes)
{
double x = coordinates[1][0] - coordinates[0][0];
double y = coordinates[1][1] - coordinates[0][1];
double z = coordinates[1][2] - coordinates[0][2];
edge_length = (double)(sqrt(x * x + y * y + z * z));
}
if (3 == num_nodes)
{
double x = coordinates[2][0] - coordinates[0][0];
double y = coordinates[2][1] - coordinates[0][1];
double z = coordinates[2][2] - coordinates[0][2];
edge_length += (double)(sqrt(x * x + y * y + z * z));
x = coordinates[2][0] - coordinates[1][0];
y = coordinates[2][1] - coordinates[1][1];
z = coordinates[2][2] - coordinates[1][2];
edge_length += (double)(sqrt(x * x + y * y + z * z));
}
return edge_length;
}
} // namespace verdict