Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
unionized-triangles
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
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
Shlomi Steinberg
unionized-triangles
Commits
b496605a
Commit
b496605a
authored
3 months ago
by
Brandon Lai-Cheong
Browse files
Options
Downloads
Patches
Plain Diff
fixed interpolate
parent
61a2e48f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/interpolate_z.h
+2
-1
2 additions, 1 deletion
include/interpolate_z.h
src/utilities/interpolate_z.cpp
+11
-17
11 additions, 17 deletions
src/utilities/interpolate_z.cpp
with
13 additions
and
18 deletions
include/interpolate_z.h
+
2
−
1
View file @
b496605a
#pragma once
#include
<vector>
struct
Point
;
struct
Edge
;
float
interpolateZ
(
const
std
::
vector
<
Point
>
&
shape
,
const
Point
&
p
);
\ No newline at end of file
float
interpolateZ
(
const
Edge
&
e
,
const
Point
&
p
);
This diff is collapsed.
Click to expand it.
src/utilities/interpolate_z.cpp
+
11
−
17
View file @
b496605a
#include
<interpolate_z.h>
#include
<limits>
#include
<point.h>
#include
<edge.h>
#include
<cmath>
float
dist2D
(
const
Point
&
p
)
{
return
sqrt
(
p
.
x
*
p
.
x
+
p
.
y
*
p
.
y
);
}
float
interpolateZ
(
const
std
::
vector
<
Point
>
&
shape
,
const
Point
&
p
)
{
// create direction vectors
const
Point
v1
=
-
(
shape
[
0
]
-
shape
[
1
]);
const
Point
v2
=
-
(
shape
[
0
]
-
shape
[
2
]);
const
Point
&
origin
=
shape
[
0
];
float
t
=
(
p
.
y
*
v1
.
x
-
origin
.
y
*
v1
.
x
-
p
.
x
*
v1
.
y
+
origin
.
x
*
v1
.
y
)
/
(
v1
.
x
*
v2
.
y
-
v1
.
y
*
v2
.
x
);
float
s
=
(
p
.
y
-
origin
.
y
-
t
*
v2
.
y
)
/
v1
.
y
;
if
(
s
==
-
std
::
numeric_limits
<
float
>::
infinity
()
||
std
::
isnan
(
s
))
{
s
=
0
;
}
float
interpolateZ
(
const
Edge
&
e
,
const
Point
&
p
)
{
const
float
p1Dist
=
dist2D
(
e
.
p1
);
const
float
p2Dist
=
dist2D
(
e
.
p2
);
if
(
t
==
-
std
::
numeric_limits
<
float
>::
infinity
()
||
std
::
isnan
(
t
))
{
t
=
0
;
}
const
float
b
=
(
p2Dist
*
e
.
p1
.
z
-
p1Dist
*
e
.
p2
.
z
)
/
(
p2Dist
-
p1Dist
);
const
float
m
=
(
e
.
p2
.
z
-
b
)
/
p2Dist
;
return
origin
.
z
+
v1
.
z
*
s
+
v2
.
z
*
t
;
return
m
*
dist2D
(
p
)
+
b
;
}
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