Start first task
This commit is contained in:
parent
4aebb5f172
commit
3ac15a7649
2 changed files with 28 additions and 3 deletions
|
@ -392,6 +392,16 @@ class AABBTree
|
||||||
assert(IsCompleted());
|
assert(IsCompleted());
|
||||||
if (root == nullptr)
|
if (root == nullptr)
|
||||||
return ResultEntry();
|
return ResultEntry();
|
||||||
|
|
||||||
|
AABBNode* node = root;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
// TODO: dynamic cast to check for leaf- or split-node
|
||||||
|
// if split node: check BB of childs
|
||||||
|
// -> node = child with shorter distance
|
||||||
|
// if leaf node: iterate through primitives
|
||||||
|
}
|
||||||
|
|
||||||
/* Task 3.2.1 */
|
/* Task 3.2.1 */
|
||||||
return ClosestPrimitiveLinearSearch(q);
|
return ClosestPrimitiveLinearSearch(q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,9 +91,24 @@ bool LineSegment::Overlaps(const Box &b) const
|
||||||
//returns the point with smallest distance topoint p which lies on the line segment
|
//returns the point with smallest distance topoint p which lies on the line segment
|
||||||
Eigen::Vector3f LineSegment::ClosestPoint(const Eigen::Vector3f &p) const
|
Eigen::Vector3f LineSegment::ClosestPoint(const Eigen::Vector3f &p) const
|
||||||
{
|
{
|
||||||
//the two endpoints of the line segment are v0,v1
|
Eigen::Vector3f v = v1 - v0;
|
||||||
/* Task 3.2.1 */
|
Eigen::Vector3f w = p - v0;
|
||||||
return Eigen::Vector3f(0, 0, 0);
|
|
||||||
|
float c1 = w.dot(v);
|
||||||
|
float c2 = v.dot(v);
|
||||||
|
|
||||||
|
if (c1 <= 0.0) {
|
||||||
|
return v0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c2 <= c1) {
|
||||||
|
return v1;
|
||||||
|
}
|
||||||
|
|
||||||
|
float b = c1 / c2;
|
||||||
|
|
||||||
|
Eigen::Vector3f Pb = v0 + b * v;
|
||||||
|
return Pb;
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns the squared distance between point p and the line segment
|
//returns the squared distance between point p and the line segment
|
||||||
|
|
Loading…
Reference in a new issue