-
-
Save GlebGomenyuk/6032ce00e6a360dc6cc22656aeb378a6 to your computer and use it in GitHub Desktop.
HW1_3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com; | |
public class Main { | |
public static void main(String[] args) { | |
Vector3d vecOne = new Vector3d(1,2,3); | |
Vector3d vecTwo = new Vector3d(3,2,1); | |
System.out.println("Сложение векторов: " + vecOne.addVector(vecTwo.getX(), vecTwo.getY(), vecTwo.getZ())); | |
System.out.println("Скалярное произведения векторов: " + vecOne.scalVector(vecTwo.getX(), vecTwo.getY(), vecTwo.getZ())); | |
System.out.println("Векторное произведения векторов " + vecOne.vectorProduct(vecTwo.getX(), vecTwo.getY(), vecTwo.getZ())); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com; | |
public class Vector3d { | |
private int x; | |
private int y; | |
private int z; | |
public Vector3d(int x, int y, int z) { | |
super(); | |
this.x = x; | |
this.y = y; | |
this.z = z; | |
} | |
public Vector3d() { | |
super(); | |
} | |
public int getX() { | |
return x; | |
} | |
public void setX(int x) { | |
this.x = x; | |
} | |
public int getY() { | |
return y; | |
} | |
public void setY(int y) { | |
this.y = y; | |
} | |
public int getZ() { | |
return z; | |
} | |
public void setZ(int z) { | |
this.z = z; | |
} | |
public String addVector(int x, int y, int z) { | |
int i = x + this.x; | |
int j = y + this.y; | |
int k = z + this.z; | |
String addVector = Integer.toString(i) + ", " + Integer.toString(j) + ", " + Integer.toString(k); | |
return addVector; | |
} | |
public double scalVector(int x, int y, int z) { | |
double scalVector = x * this.x + y * this.y + z * this.z; | |
return scalVector; | |
} | |
public String vectorProduct(int x, int y, int z) { | |
int i = y * this.z - z * this.y; | |
int j = z * this.x - x *this.z; | |
int k = x * this.y - y *this.x; | |
String vectorProduct = Integer.toString(i) + ", " + Integer.toString(j) + ", " + Integer.toString(k); | |
return vectorProduct; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment