Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IDATT2003 Mappevurdering
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
Håvard Johannes Versto Daleng
IDATT2003 Mappevurdering
Commits
f1053aa2
Commit
f1053aa2
authored
1 year ago
by
Håvard Daleng
Browse files
Options
Downloads
Patches
Plain Diff
Created class Vector2D.
parent
dd6651dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Merge master and main
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.idea/misc.xml
+0
-1
0 additions, 1 deletion
.idea/misc.xml
.idea/vcs.xml
+6
-0
6 additions, 0 deletions
.idea/vcs.xml
src/main/java/edu/ntnu/stud/model/Vector2D.java
+67
-0
67 additions, 0 deletions
src/main/java/edu/ntnu/stud/model/Vector2D.java
with
73 additions
and
1 deletion
.idea/misc.xml
+
0
−
1
View file @
f1053aa2
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ExternalStorageConfigurationManager"
enabled=
"true"
/>
<component
name=
"MavenProjectsManager"
>
...
...
This diff is collapsed.
Click to expand it.
.idea/vcs.xml
0 → 100644
+
6
−
0
View file @
f1053aa2
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
""
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/edu/ntnu/stud/model/Vector2D.java
0 → 100644
+
67
−
0
View file @
f1053aa2
package
edu.ntnu.stud.model
;
/**
* Class representing a 2D vector.
*/
public
class
Vector2D
{
/**
* The x0 component of the vector.
*/
private
double
x0
;
/**
* The x1 component of the vector.
*/
private
double
x1
;
/**
* Create a new 2D vector.
*
* @param x0 The x0 component of the vector.
* @param x1 The x1 component of the vector.
*/
public
Vector2D
(
double
x0
,
double
x1
)
{
this
.
x0
=
x0
;
this
.
x1
=
x1
;
}
/**
* Get the x0 component of the vector.
*
* @return The x0 component of the vector.
*/
public
double
getX0
()
{
return
x0
;
}
/**
* Get the x1 component of the vector.
*
* @return The x1 component of the vector.
*/
public
double
getX1
()
{
return
x1
;
}
/**
* Add another vector to this vector.
*
* @param other The other vector to add.
* @return A new vector that is the sum of this vector and the other vector.
*/
public
Vector2D
add
(
Vector2D
other
)
{
return
new
Vector2D
(
x0
+
other
.
x0
,
x1
+
other
.
x1
);
}
/**
* Subtract another vector from this vector.
*
* @param other The other vector to subtract.
* @return A new vector that is the difference between this vector and the other vector.
*/
public
Vector2D
subtract
(
Vector2D
other
)
{
return
new
Vector2D
(
x0
-
other
.
x0
,
x1
-
other
.
x1
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment