Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package app;
- /**
- *
- * @author Ihor Fedchenko
- *
- */
- public class Vector {
- /**
- *
- */
- double x1;
- /**
- *
- */
- double x2;
- /**
- *
- */
- double x3;
- /**
- *
- */
- Vector() {
- x1 = 0.0;
- x2 = 0.0;
- x3 = 0.0;
- }
- /**
- *
- * @param x1
- * @param x2
- * @param x3
- */
- Vector(double x1, double x2, double x3) {
- this.x1 = x1;
- this.x2 = x2;
- this.x3 = x3;
- }
- double getX1() {
- return x1;
- }
- void setX1(double x1) {
- this.x1 = x1;
- }
- double getX2() {
- return x2;
- }
- void setX2(double x2) {
- this.x2 = x2;
- }
- double getX3() {
- return x3;
- }
- void setX3(double x3) {
- this.x3 = x3;
- }
- /**
- *
- * @param value
- * @return
- */
- Vector getVectorSum(Vector value) {
- return new Vector(this.x1 + value.getX1(), this.x2 + value.getX2(), this.x3 + value.getX3());
- }
- /**
- *
- * @param value
- * @return
- */
- double getScalarProguct(Vector value) {
- return ((this.x1 * value.getX1()) + (this.x2 * value.getX2()) + (this.x3 * value.getX3()));
- }
- /**
- *
- * @param value
- * @return
- */
- Vector get2VectorsProguct(Vector value) {
- return new Vector(this.x2 * value.getX3() - this.x3 * value.getX2(), this.x3 * value.getX1() - this.x1 * value.getX3(),
- this.x1 * value.getX2() - this.x2 * value.getX1());
- }
- /**
- *
- * @return
- */
- double getModule() {
- return Math.sqrt((this.x1*=this.x1)+(this.x2*=this.x2)+(this.x3*=this.x3));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement