Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor 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
schwede
openstructure
Commits
939a3710
Commit
939a3710
authored
13 years ago
by
Niklaus Johner
Browse files
Options
Downloads
Patches
Plain Diff
Added function to wrap Vec3 and Vec3List in a periodic box
parent
02b50500
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/geom/pymod/export_vecmat3_op.cc
+3
-1
3 additions, 1 deletion
modules/geom/pymod/export_vecmat3_op.cc
modules/geom/src/vecmat3_op.cc
+21
-0
21 additions, 0 deletions
modules/geom/src/vecmat3_op.cc
modules/geom/src/vecmat3_op.hh
+7
-0
7 additions, 0 deletions
modules/geom/src/vecmat3_op.hh
with
31 additions
and
1 deletion
modules/geom/pymod/export_vecmat3_op.cc
+
3
−
1
View file @
939a3710
...
...
@@ -39,7 +39,7 @@ Real (*Mat3Minor)(const Mat3& m, unsigned int i, unsigned int j) = &Minor;
Vec3
(
*
Vec3Min
)(
const
Vec3
&
,
const
Vec3
&
)
=
&
Min
;
Vec3
(
*
Vec3Max
)(
const
Vec3
&
,
const
Vec3
&
)
=
&
Max
;
Real
(
*
Vec3Distance2WithPBC
)(
const
Vec3
&
,
const
Vec3
&
,
const
Vec3
&
)
=
&
Distance2WithPBC
;
Real
(
*
Vec3DistanceWithPBC
)(
const
Vec3
&
,
const
Vec3
&
,
const
Vec3
&
)
=
&
DistanceWithPBC
;
Real
(
*
Vec3DistanceWithPBC
)(
const
Vec3
&
,
const
Vec3
&
,
const
Vec3
&
)
=
&
DistanceWithPBC
;
void
export_VecMat3_op
()
{
...
...
@@ -69,4 +69,6 @@ void export_VecMat3_op()
def
(
"DistanceWithPBC"
,
Vec3DistanceWithPBC
);
def
(
"MinDistance"
,
MinDistance
);
def
(
"MinDistanceWithPBC"
,
MinDistanceWithPBC
);
def
(
"WrapVec3"
,
WrapVec3
);
def
(
"WrapVec3List"
,
WrapVec3List
);
}
This diff is collapsed.
Click to expand it.
modules/geom/src/vecmat3_op.cc
+
21
−
0
View file @
939a3710
...
...
@@ -227,5 +227,26 @@ Real MinDistanceWithPBC(const Vec3List& l1, const Vec3List& l2, Vec3& basis_vec)
}
return
std
::
sqrt
(
min
);
}
Vec3
WrapVec3
(
const
Vec3
&
v1
,
const
Vec3
&
box_center
,
const
Vec3
&
basis_vec
){
Vec3
v
;
Real
r
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
r
=
(
v1
[
i
]
-
box_center
[
i
])
/
basis_vec
[
i
];
r
=
(
r
>
0.0
)
?
std
::
floor
(
r
+
0.5
)
:
std
::
ceil
(
r
-
0.5
);
v
[
i
]
=
v1
[
i
]
-
basis_vec
[
i
]
*
r
;
}
return
v
;
}
Vec3List
WrapVec3List
(
const
Vec3List
&
vl
,
const
Vec3
&
box_center
,
const
Vec3
&
basis_vec
){
Vec3List
vl_out
;
vl_out
.
reserve
(
vl_out
.
size
());
for
(
Vec3List
::
const_iterator
v1
=
vl
.
begin
(),
e
=
vl
.
end
();
v1
!=
e
;
v1
++
)
{
vl_out
.
push_back
(
WrapVec3
(
*
v1
,
box_center
,
basis_vec
));
}
return
vl_out
;
}
}
// ns
This diff is collapsed.
Click to expand it.
modules/geom/src/vecmat3_op.hh
+
7
−
0
View file @
939a3710
...
...
@@ -215,6 +215,13 @@ Real MinDistance(const Vec3List& l1, const Vec3List& l2);
//! returns the minimal distance between the points in two Vec3List
// with periodic boundaries in x,y,z given in basis_vec
Real
MinDistanceWithPBC
(
const
Vec3List
&
l1
,
const
Vec3List
&
l2
,
Vec3
&
basis_vec
);
//!wraps a vector in a box with periodic boundaries
Vec3
WrapVec3
(
const
Vec3
&
v1
,
const
Vec3
&
box_center
,
const
Vec3
&
basis_vec
);
//!wraps all the verctors in a Vec3List in a box with periodic boundaries
Vec3List
WrapVec3List
(
const
Vec3List
&
vl
,
const
Vec3
&
box_center
,
const
Vec3
&
basis_vec
);
}
// ns
#endif
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