Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Richard Torenvliet
eos
Commits
238afe3c
Commit
238afe3c
authored
9 years ago
by
Patrik Huber
Browse files
Options
Downloads
Patches
Plain Diff
Added a function that calculates the per-vertex normal
parent
681f89e9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/eos/render/utils.hpp
+18
-0
18 additions, 0 deletions
include/eos/render/utils.hpp
with
18 additions
and
0 deletions
include/eos/render/utils.hpp
+
18
−
0
View file @
238afe3c
...
...
@@ -79,6 +79,24 @@ inline cv::Vec2f screen_to_clip_space(const cv::Vec2f& screen_coordinates, int s
return
cv
::
Vec2f
(
x_cs
,
y_cs
);
};
/**
* Calculates the normal of a face (or triangle), i.e. the
* per-face normal. Return normal will be normalised.
* Assumes the triangle is given in CCW order, i.e. vertices
* in counterclockwise order on the screen are front-facing.
*
* @param[in] v0 First vertex.
* @param[in] v1 Second vertex.
* @param[in] v2 Third vertex.
* @return The unit-length normal of the given triangle.
*/
cv
::
Vec3f
calculate_face_normal
(
const
cv
::
Vec3f
&
v0
,
const
cv
::
Vec3f
&
v1
,
const
cv
::
Vec3f
&
v2
)
{
cv
::
Vec3f
n
=
(
v1
-
v0
).
cross
(
v2
-
v0
);
// v0-to-v1 x v0-to-v2
n
/=
cv
::
norm
(
n
);
return
n
;
};
/**
* Draws the texture coordinates (uv-coords) of the given mesh
* into an image by looping over the triangles and drawing each
...
...
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