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
c3aaf8aa
Commit
c3aaf8aa
authored
Jul 06, 2015
by
Chinmay Garde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test individial spring types
parent
ab7a6dd6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
1 deletion
+59
-1
spring.dart
packages/newton/lib/src/spring.dart
+1
-1
newton_test.dart
packages/newton/test/newton_test.dart
+58
-0
No files found.
packages/newton/lib/src/spring.dart
View file @
c3aaf8aa
...
...
@@ -12,7 +12,7 @@ class SpringDesc {
final
double
springConstant
;
/// The damping coefficient.
/// Note: Not to be confused with the damping ratio
(zeta)
. Use the separate
/// Note: Not to be confused with the damping ratio. Use the separate
/// constructor provided for this purpose
final
double
damping
;
...
...
packages/newton/test/newton_test.dart
View file @
c3aaf8aa
...
...
@@ -74,4 +74,62 @@ void main() {
var
other
=
new
Spring
(
new
SpringDesc
(
1.0
,
100.0
,
20.0
),
0.0
,
20.0
,
20.0
);
expect
(
other
.
type
,
SpringType
.
criticallyDamped
);
});
test
(
'crit_spring'
,
()
{
var
crit
=
new
Spring
(
new
SpringDesc
.
withDampingRatio
(
1.0
,
100.0
,
1.0
),
0.0
,
500.0
,
0.0
);
expect
(
crit
.
type
,
SpringType
.
criticallyDamped
);
expect
(
crit
.
isDone
(
0.0
),
false
);
expect
(
crit
.
x
(
0.0
),
0.0
);
expect
(
crit
.
dx
(
0.0
),
5000.0
);
expect
(
crit
.
x
(
0.25
).
floor
(),
458.0
);
expect
(
crit
.
x
(
0.50
).
floor
(),
496.0
);
expect
(
crit
.
x
(
0.75
).
floor
(),
499.0
);
expect
(
crit
.
dx
(
0.25
).
floor
(),
410
);
expect
(
crit
.
dx
(
0.50
).
floor
(),
33
);
expect
(
crit
.
dx
(
0.75
).
floor
(),
2
);
expect
(
crit
.
isDone
(
1.50
),
true
);
expect
(
crit
.
x
(
1.5
)
>
499.0
&&
crit
.
x
(
1.5
)
<
501.0
,
true
);
expect
(
crit
.
dx
(
1.5
)
<
0.1
,
true
/* basically within tolerance */
);
});
test
(
'overdamped_spring'
,
()
{
var
over
=
new
Spring
(
new
SpringDesc
.
withDampingRatio
(
1.0
,
100.0
,
1.25
),
0.0
,
500.0
,
0.0
);
expect
(
over
.
type
,
SpringType
.
overDamped
);
expect
(
over
.
isDone
(
0.0
),
false
);
expect
(
over
.
x
(
0.0
),
0.0
);
expect
(
over
.
x
(
0.5
).
floor
(),
445.0
);
expect
(
over
.
x
(
1.0
).
floor
(),
495.0
);
expect
(
over
.
x
(
1.5
).
floor
(),
499.0
);
expect
(
over
.
dx
(
0.5
).
floor
(),
273.0
);
expect
(
over
.
dx
(
1.0
).
floor
(),
22.0
);
expect
(
over
.
dx
(
1.5
).
floor
(),
1.0
);
expect
(
over
.
isDone
(
3.0
),
true
);
});
test
(
'underdamped_spring'
,
()
{
var
under
=
new
Spring
(
new
SpringDesc
.
withDampingRatio
(
1.0
,
100.0
,
0.25
),
0.0
,
300.0
,
0.0
);
expect
(
under
.
type
,
SpringType
.
underDamped
);
expect
(
under
.
isDone
(
0.0
),
false
);
// Overshot with negative velocity
expect
(
under
.
x
(
1.0
).
floor
(),
325
);
expect
(
under
.
dx
(
1.0
).
floor
(),
-
65
);
expect
(
under
.
dx
(
6.0
).
floor
(),
0.0
);
expect
(
under
.
x
(
6.0
).
floor
(),
299
);
expect
(
under
.
isDone
(
6.0
),
true
);
});
}
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