MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / getLinearAlpha

Function getLinearAlpha

src/utilities/geometry/Intersection.cpp:1122–1157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1120}
1121
1122boost::optional<double> getLinearAlpha(const Point3d& point0, const Point3d& point1, const Point3d& test) {
1123 // test = point0 + a*(point1 - point0)
1124 Vector3d diff1 = point1 - point0;
1125 const Vector3d diffTest = test - point0;
1126
1127 const double length = diff1.length();
1128 if (length < 0.001) {
1129 return boost::none;
1130 }
1131
1132 double a = 0.0;
1133 if (std::abs(diff1.x()) > std::abs(diff1.y())) {
1134 if (std::abs(diff1.x()) > std::abs(diff1.z())) {
1135 a = diffTest.x() / diff1.x();
1136 } else {
1137 a = diffTest.z() / diff1.z();
1138 }
1139 } else {
1140 if (std::abs(diff1.y()) > std::abs(diff1.z())) {
1141 a = diffTest.y() / diff1.y();
1142 } else {
1143 a = diffTest.z() / diff1.z();
1144 }
1145 }
1146
1147 diff1.setLength(a * length);
1148 const Point3d test2 = point0 + diff1;
1149 const double d = getDistance(test, test2);
1150 if (d < 0.001) {
1151 if (a > 0 && a < 1) {
1152 return a;
1153 }
1154 }
1155
1156 return boost::none;
1157}
1158
1159std::vector<Point3d> simplify(const std::vector<Point3d>& vertices, bool removeCollinear, double tol) {
1160 std::vector<Point3d> allPoints;

Callers 1

simplifyFunction · 0.85

Calls 7

absFunction · 0.85
getDistanceFunction · 0.85
lengthMethod · 0.45
xMethod · 0.45
yMethod · 0.45
zMethod · 0.45
setLengthMethod · 0.45

Tested by

no test coverage detected