Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
typed-geometry
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
Benedikt Conze
typed-geometry
Commits
01f52715
Commit
01f52715
authored
6 years ago
by
Philip Trettner
Browse files
Options
Downloads
Patches
Plain Diff
added rows to matrices
parent
f6b38b8f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tg/detail/functions/data_ptr.hh
+11
-0
11 additions, 0 deletions
src/tg/detail/functions/data_ptr.hh
src/tg/types/mat.hh
+27
-3
27 additions, 3 deletions
src/tg/types/mat.hh
with
38 additions
and
3 deletions
src/tg/detail/functions/data_ptr.hh
+
11
−
0
View file @
01f52715
...
...
@@ -36,4 +36,15 @@ constexpr ScalarT* data_ptr(size<D, ScalarT>& v)
{
return
&
v
.
width
;
}
template
<
int
C
,
int
R
,
class
ScalarT
>
constexpr
ScalarT
const
*
data_ptr
(
mat
<
C
,
R
,
ScalarT
>
const
&
m
)
{
return
&
m
[
0
][
0
];
}
template
<
int
C
,
int
R
,
class
ScalarT
>
constexpr
ScalarT
*
data_ptr
(
mat
<
C
,
R
,
ScalarT
>&
m
)
{
return
&
m
[
0
][
0
];
}
}
// namespace tg
This diff is collapsed.
Click to expand it.
src/tg/types/mat.hh
+
27
−
3
View file @
01f52715
...
...
@@ -90,6 +90,31 @@ using umat4x4 = mat<4, 4, u32>;
// ======== IMPLEMENTATION ========
namespace
detail
{
template
<
int
R
,
class
ScalarT
>
constexpr
vec
<
1
,
ScalarT
>
mat_row
(
mat
<
1
,
R
,
ScalarT
>
const
&
m
,
int
i
)
{
return
{
m
[
0
][
i
]};
}
template
<
int
R
,
class
ScalarT
>
constexpr
vec
<
2
,
ScalarT
>
mat_row
(
mat
<
2
,
R
,
ScalarT
>
const
&
m
,
int
i
)
{
return
{
m
[
0
][
i
],
m
[
1
][
i
]};
}
template
<
int
R
,
class
ScalarT
>
constexpr
vec
<
3
,
ScalarT
>
mat_row
(
mat
<
3
,
R
,
ScalarT
>
const
&
m
,
int
i
)
{
return
{
m
[
0
][
i
],
m
[
1
][
i
],
m
[
2
][
i
]};
}
template
<
int
R
,
class
ScalarT
>
constexpr
vec
<
4
,
ScalarT
>
mat_row
(
mat
<
4
,
R
,
ScalarT
>
const
&
m
,
int
i
)
{
return
{
m
[
0
][
i
],
m
[
1
][
i
],
m
[
2
][
i
],
m
[
3
][
i
]};
}
}
// namespace detail
/*
* Memory layout of a 4x4:
* 0 4 8 12
...
...
@@ -109,15 +134,14 @@ struct mat
{
using
row_t
=
vec
<
C
,
ScalarT
>
;
using
col_t
=
vec
<
R
,
ScalarT
>
;
using
transpose_t
=
mat
<
C
,
R
,
ScalarT
>
;
col_t
m
[
R
];
constexpr
col_t
&
operator
[](
int
i
)
{
return
m
[
i
];
}
constexpr
col_t
const
&
operator
[](
int
i
)
const
{
return
m
[
i
];
}
constexpr
col_t
&
col
(
int
i
)
{
return
m
[
i
];
}
constexpr
col_t
const
&
col
(
int
i
)
const
{
return
m
[
i
]
;
}
constexpr
col_t
col
(
int
i
)
const
{
return
m
[
i
];
}
constexpr
row_t
row
(
int
i
)
const
{
return
detail
::
mat_row
(
*
this
,
i
)
;
}
mat
()
=
default
;
};
...
...
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