Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CppRaytracer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yoel
CppRaytracer
Commits
9bd479f1
Commit
9bd479f1
authored
4 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
Implemented the *-operator for transforming a AABB with matrices
parent
5594bbb3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
RayTracer/tools/AxisAlignedBoundingBox.cpp
+29
-0
29 additions, 0 deletions
RayTracer/tools/AxisAlignedBoundingBox.cpp
with
29 additions
and
0 deletions
RayTracer/tools/AxisAlignedBoundingBox.cpp
+
29
−
0
View file @
9bd479f1
...
...
@@ -26,6 +26,35 @@ AxisAlignedBoundingBox AxisAlignedBoundingBox::operator+(
return
AxisAlignedBoundingBox
(
min
,
max
);
}
AxisAlignedBoundingBox
AxisAlignedBoundingBox
::
operator
*
(
const
Mat4
&
rhs
)
const
{
AxisAlignedBoundingBox
result
(
Vec3
(
std
::
numeric_limits
<
float
>::
infinity
()),
Vec3
(
-
std
::
numeric_limits
<
float
>::
infinity
()));
Vec3
v1
=
rhs
.
transformPoint
(
Vec3
(
min
.
x
(),
min
.
y
(),
min
.
z
()));
Vec3
v2
=
rhs
.
transformPoint
(
Vec3
(
min
.
x
(),
min
.
y
(),
max
.
z
()));
Vec3
v3
=
rhs
.
transformPoint
(
Vec3
(
min
.
x
(),
max
.
y
(),
min
.
z
()));
Vec3
v4
=
rhs
.
transformPoint
(
Vec3
(
min
.
x
(),
min
.
y
(),
max
.
z
()));
Vec3
v5
=
rhs
.
transformPoint
(
Vec3
(
max
.
x
(),
min
.
y
(),
min
.
z
()));
Vec3
v6
=
rhs
.
transformPoint
(
Vec3
(
min
.
x
(),
min
.
y
(),
max
.
z
()));
Vec3
v7
=
rhs
.
transformPoint
(
Vec3
(
min
.
x
(),
max
.
y
(),
min
.
z
()));
Vec3
v8
=
rhs
.
transformPoint
(
Vec3
(
min
.
x
(),
max
.
y
(),
max
.
z
()));
float
minX
=
std
::
min
<
float
>
(
{
v1
.
x
(),
v2
.
x
(),
v3
.
x
(),
v4
.
x
(),
v5
.
x
(),
v6
.
x
(),
v7
.
x
(),
v8
.
x
()});
float
minY
=
std
::
min
<
float
>
(
{
v1
.
y
(),
v2
.
y
(),
v3
.
y
(),
v4
.
y
(),
v5
.
y
(),
v6
.
y
(),
v7
.
y
(),
v8
.
y
()});
float
minZ
=
std
::
min
<
float
>
(
{
v1
.
z
(),
v2
.
z
(),
v3
.
z
(),
v4
.
z
(),
v5
.
z
(),
v6
.
z
(),
v7
.
z
(),
v8
.
z
()});
float
maxX
=
std
::
max
<
float
>
(
{
v1
.
x
(),
v2
.
x
(),
v3
.
x
(),
v4
.
x
(),
v5
.
x
(),
v6
.
x
(),
v7
.
x
(),
v8
.
x
()});
float
maxY
=
std
::
max
<
float
>
(
{
v1
.
y
(),
v2
.
y
(),
v3
.
y
(),
v4
.
y
(),
v5
.
y
(),
v6
.
y
(),
v7
.
y
(),
v8
.
y
()});
float
maxZ
=
std
::
max
<
float
>
(
{
v1
.
z
(),
v2
.
z
(),
v3
.
z
(),
v4
.
z
(),
v5
.
z
(),
v6
.
z
(),
v7
.
z
(),
v8
.
z
()});
return
AxisAlignedBoundingBox
(
Vec3
(
minX
,
minY
,
minZ
),
Vec3
(
maxX
,
maxY
,
maxZ
));
}
// Methods
// https://education.siggraph.org/static/HyperGraph/raytrace/rtinter3.htm
bool
AxisAlignedBoundingBox
::
intersects
(
const
cam
::
Ray
&
r
)
const
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment