本文整理汇总了C++中ParticleSystem::evalF方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSystem::evalF方法的具体用法?C++ ParticleSystem::evalF怎么用?C++ ParticleSystem::evalF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystem
的用法示例。
在下文中一共展示了ParticleSystem::evalF方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: midpointStep
void midpointStep(ParticleSystem& ps, float step) {
const auto& x0 = ps.state();
auto n = x0.size();
auto f0 = ps.evalF(x0);
auto xm = State(n), x1 = State(n);
for (auto i = 0u; i < n; ++i) {
xm[i] = x0[i] + (0.5f * step) * f0[i];
}
auto fm = ps.evalF(xm);
for (auto i = 0u; i < n; ++i) {
x1[i] = x0[i] + step * fm[i];
}
ps.set_state(x1);
}
示例2: trapezoidStep
void trapezoidStep(ParticleSystem& ps, float step) {
// YOUR CODE HERE (R3)
// Implement a trapezoid integrator.
const auto& x0 = ps.state();
auto n = x0.size();
auto f0 = ps.evalF(x0);
auto x1 = State(n);
auto xt = State(n);
for (unsigned i = 0; i < n; i++) {
x1[i] = x0[i] + step * f0[i];
}
auto ft = ps.evalF(x1);
for (unsigned i = 0; i < n; i++) {
xt[i] = x0[i] + (0.5f * step) * (f0[i] + ft[i]);
}
ps.set_state(xt);
}
示例3: eulerStep
void eulerStep(ParticleSystem& ps, float step) {
// YOUR CODE HERE (R1)
// Implement an Euler integrator.
const auto& x0 = ps.state();
auto n = x0.size();
auto f0 = ps.evalF(x0);
auto x1 = State(n);
for (unsigned i = 0; i < n; i++) {
x1[i] = x0[i] + step * f0[i];
}
ps.set_state(x1);
};