Skip to content

Commit 0228f8d

Browse files
authored
Update README.md
1 parent c5ca169 commit 0228f8d

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,53 @@
5959
**网格曲面**
6060

6161
![网格曲面](pic/网格曲面.jpg "网格曲面")
62+
简单样例代码
63+
```
64+
public class MobiusStripDemo {
65+
public static void main(String[] args) throws Exception {
66+
67+
GridMeshProcessor processer = new GridMeshProcessor();
68+
69+
Matplot3D4JMgr matPlot3DMgr = new Matplot3D4JMgr(processer);
70+
71+
GridMeshMapper f = new GridMeshMapper() {
72+
73+
public Point3D f(double d1, double d2) {
74+
75+
double sita = d1;
76+
double offset = d2;
77+
78+
double baseR = 12;// 半径
79+
80+
double r = 3.6 * Math.cos(sita * 3 / 2) + baseR;
81+
82+
double fai;// 自旋角
83+
84+
fai = sita * 1.75;// 自旋角是方位角的1.75
85+
86+
double x = (r + (offset * Math.cos(fai))) * Math.cos(sita);
87+
double y = (r + (offset * Math.cos(fai))) * Math.sin(sita);
88+
double z = offset * Math.sin(fai) + 3.6 * Math.sin(sita * 3 / 2);
89+
90+
return new Point3D(x, y, z);
91+
}
92+
93+
public void setAdditionalPrar(Object additionalprar) {}
94+
};
95+
96+
double[] sita = FunctionSpaceUtil.lineSpace(0, Math.PI * 4, 300);
97+
98+
double[] offset = FunctionSpaceUtil.lineSpace(-3.1, 3.1, 5);
99+
100+
processer.addData(f, sita, offset, "1",new TopBottomColorStyle(ColorStyle.DEFAULT_COLORS_REVERSE_ARRAY) ,1f);
101+
102+
matPlot3DMgr.setCoordianteSysShowType(matPlot3DMgr.COORDINATE_SYS_ALWAYS_FURTHER);
103+
matPlot3DMgr.setTitle("Mobius strip demo");
104+
105+
matPlot3DMgr.show();
106+
}
107+
}
108+
```
62109
<br/>
63110
<br/>
64111
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄

0 commit comments

Comments
 (0)