Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ea1a8ee3
Commit
ea1a8ee3
authored
Jul 27, 2015
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added BoundedFrictionSimulation
parent
1ad857b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
friction_simulation.dart
packages/newton/lib/src/friction_simulation.dart
+22
-0
No files found.
packages/newton/lib/src/friction_simulation.dart
View file @
ea1a8ee3
...
...
@@ -24,3 +24,25 @@ class FrictionSimulation extends Simulation {
@override
bool
isDone
(
double
time
)
=>
dx
(
time
).
abs
()
<
this
.
tolerance
.
velocity
;
}
class
BoundedFrictionSimulation
extends
FrictionSimulation
{
BoundedFrictionSimulation
(
double
drag
,
double
position
,
double
velocity
,
double
this
.
_minX
,
double
this
.
_maxX
)
:
super
(
drag
,
position
,
velocity
);
final
double
_minX
;
final
double
_maxX
;
double
x
(
double
time
)
{
return
super
.
x
(
time
).
clamp
(
_minX
,
_maxX
);
}
bool
isDone
(
double
time
)
{
return
super
.
isDone
(
time
)
||
(
x
(
time
)
-
_minX
).
abs
()
<
tolerance
.
distance
||
(
x
(
time
)
-
_maxX
).
abs
()
<
tolerance
.
distance
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment