Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sphere
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PIERRON Laurent
sphere
Compare revisions
dd694a9eb2236656f9bd6caca0652df846bbf5cd to c0bfe28a11266c2b4af4517ce2194a3c3ca59817
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
pierron9/sphere
Select target project
No results found
c0bfe28a11266c2b4af4517ce2194a3c3ca59817
Select Git revision
Branches
akooobon1u
doan5u
lucas
main
mandler4u
mingot2u
paulin38u
pierron9
pozzodib1u
wissle1u
10 results
Swap
Target
pierron9/sphere
Select target project
pierron9/sphere
1 result
dd694a9eb2236656f9bd6caca0652df846bbf5cd
Select Git revision
Branches
akooobon1u
doan5u
lucas
main
mandler4u
mingot2u
paulin38u
pierron9
pozzodib1u
wissle1u
10 results
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (3)
Correction de computeVolume() mise au cube au lieu du carré. Respect des indications SonarLint.
· b1fa800d
PIERRON Laurent
authored
2 years ago
b1fa800d
Adding .idea to .gitignore
· 7dfdb4b0
PIERRON Laurent
authored
2 years ago
7dfdb4b0
Tous les tests passent. La couverture est à 100%.
· c0bfe28a
PIERRON Laurent
authored
2 years ago
c0bfe28a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
src/main/java/fr/nancy/iut/Sphere.java
+14
-14
14 additions, 14 deletions
src/main/java/fr/nancy/iut/Sphere.java
src/test/java/fr/nancy/iut/SphereTest.java
+51
-2
51 additions, 2 deletions
src/test/java/fr/nancy/iut/SphereTest.java
with
66 additions
and
16 deletions
.gitignore
View file @
c0bfe28a
target
.DS_Store
.vscode
.idea
This diff is collapsed.
Click to expand it.
src/main/java/fr/nancy/iut/Sphere.java
View file @
c0bfe28a
...
...
@@ -10,53 +10,53 @@ public class Sphere {
// Constructors
// ***********************************************************************
public
Sphere
()
{
radius
_
=
0.0
;
pos
_
=
new
Point3d
();
radius
Protected
=
0.0
;
pos
Protected
=
new
Point3d
();
}
public
Sphere
(
double
radius
)
{
radius
_
=
radius
;
pos
_
=
new
Point3d
();
radius
Protected
=
radius
;
pos
Protected
=
new
Point3d
();
}
public
Sphere
(
double
radius
,
Point3d
pos
)
{
radius
_
=
radius
;
pos
_
=
pos
;
radius
Protected
=
radius
;
pos
Protected
=
pos
;
}
// ***********************************************************************
// Methods
// ***********************************************************************
public
double
computeVolume
()
{
return
4
*
Math
.
PI
*
Math
.
pow
(
radius
_
,
2
)
/
3
;
return
4
*
Math
.
PI
*
Math
.
pow
(
radius
Protected
,
3
)
/
3
;
}
public
double
distanceTo
(
Sphere
other
)
{
return
pos
_
.
distance
(
other
.
pos
_
);
return
pos
Protected
.
distance
(
other
.
pos
Protected
);
}
public
double
distanceSquaredTo
(
Sphere
other
)
{
return
pos
_
.
distanceSquared
(
other
.
pos
_
);
return
pos
Protected
.
distanceSquared
(
other
.
pos
Protected
);
}
public
boolean
inContactWith
(
Sphere
other
)
{
return
distanceSquaredTo
(
other
)
<=
Math
.
pow
(
radius
_
+
other
.
radius
_
,
2
);
return
distanceSquaredTo
(
other
)
<=
Math
.
pow
(
radius
Protected
+
other
.
radius
Protected
,
2
);
}
// ***********************************************************************
// Accessors
// ***********************************************************************
public
Point3d
getPos
()
{
return
pos
_
;
return
pos
Protected
;
}
public
double
getRadius
()
{
return
radius
_
;
return
radius
Protected
;
}
// ***********************************************************************
// Attributes
// ***********************************************************************
protected
double
radius
_
=
0.0
;
protected
Point3d
pos
_
;
protected
double
radius
Protected
=
0.0
;
protected
Point3d
pos
Protected
;
}
This diff is collapsed.
Click to expand it.
src/test/java/fr/nancy/iut/SphereTest.java
View file @
c0bfe28a
package
fr.nancy.iut
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
javax.vecmath.Point3d
;
/**
* Created by dparsons on 12/08/15.
*/
public
class
SphereTest
{
class
SphereTest
{
private
Sphere
sphere1
;
private
Sphere
sphere2
;
private
Sphere
sphere3
;
@Test
public
void
testComputeVolume
()
throws
Exception
{
void
testComputeVolume
()
throws
Exception
{
Sphere
mySphere
=
new
Sphere
(
1.5
);
assertEquals
(
14.137166941154069
,
mySphere
.
computeVolume
(),
0.0
);
}
@BeforeEach
void
setUp
()
{
sphere1
=
new
Sphere
();
sphere2
=
new
Sphere
(
3.0
);
sphere3
=
new
Sphere
(
5.0
,
new
Point3d
(
1
,
2
,
3
));
}
@Test
void
distanceTo
()
{
assertEquals
(
0.0
,
sphere1
.
distanceTo
(
sphere2
));
assertEquals
(
3.7416573867739413
,
sphere1
.
distanceTo
(
sphere3
),
0.0001
);
assertEquals
(
3.7416573867739413
,
sphere2
.
distanceTo
(
sphere3
),
0.0001
);
}
@Test
void
distanceSquaredTo
()
{
assertEquals
(
0.0
,
sphere1
.
distanceSquaredTo
(
sphere2
));
assertEquals
(
14.0
,
sphere1
.
distanceSquaredTo
(
sphere3
),
0.0001
);
assertEquals
(
14.0
,
sphere2
.
distanceSquaredTo
(
sphere3
),
0.0001
);
}
@Test
void
inContactWith
()
{
assertTrue
(
sphere1
.
inContactWith
(
sphere2
));
assertFalse
(!
sphere1
.
inContactWith
(
sphere3
));
assertFalse
(!
sphere2
.
inContactWith
(
sphere3
));
}
@Test
void
getPos
()
{
Point3d
point0
=
new
Point3d
();
Point3d
point123
=
new
Point3d
(
1
,
2
,
3
);
assertEquals
(
point0
,
sphere1
.
getPos
());
assertEquals
(
point0
,
sphere2
.
getPos
());
assertEquals
(
point123
,
sphere3
.
getPos
());
}
@Test
void
getRadius
()
{
assertEquals
(
0.0
,
sphere1
.
getRadius
());
assertEquals
(
3.0
,
sphere2
.
getRadius
());
assertEquals
(
5.0
,
sphere3
.
getRadius
());
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.