forked from NonEuclideanDreamer/CutAndProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPolytope.java
More file actions
37 lines (32 loc) · 851 Bytes
/
Polytope.java
File metadata and controls
37 lines (32 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//************************************
// Author: NonEuclideanDreamer
// Convex(!) Polytope described by the Hyperplanes bounding it
//**************************************
public class Polytope
{
public Hyperplane[] face;//The normal vectors should all point inwards!
public Polytope(Hyperplane[] f)
{
face=f;
}
public Polytope shift(Rn v)
{
Hyperplane[] f=new Hyperplane[face.length];
for(int i=0;i<face.length;i++)
{
f[i]=face[i].shift(v);
}
return new Polytope(f);
}
public static Polytope zerocell(Lattice l)
{
int n=l.n, m=l.base.length;
Hyperplane[] faces=new Hyperplane[2*m];
for(int i=0;i<m;i++)
{
faces[i]=Rn.zero(n).middlenormal(new Rn(l.base[i]));
faces[i+m]=Rn.zero(n).middlenormal(new Rn(l.base[i]).times(-1));
}
return new Polytope(faces);
}
}