Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.text.DecimalFormat;
- public class Vector {
- private int x_;
- private int y_;
- private int z_;
- Vector(int x, int y, int z) {
- x_ = x;
- y_ = y;
- z_ = z;
- }
- void calculateLength() {
- String formattedDouble = new DecimalFormat("#0.00").format(Math.sqrt(Double.valueOf(x_ * x_ + y_ * y_ + z_ * z_)));
- System.out.println("length = " + formattedDouble);
- }
- double calculate() {
- return (Math.sqrt(Double.valueOf(x_ * x_ + y_ * y_ + z_ * z_)));
- }
- void print() {
- System.out.println("(" + x_ + " , " + y_ + " , " + z_ + ")");
- }
- Vector sumOfVectors(Vector vector) {
- return new Vector(this.x_ + vector.x_, this.y_ + y_, this.z_ + vector.z_);
- }
- Vector differenceOfVectors(Vector vector) {
- return new Vector(
- this.x_ - vector.x_, this.y_ - y_, this.z_ - vector.z_
- );
- }
- int scMultiplyOfVector(Vector vector) {
- return this.x_ * vector.x_ + this.y_ * y_ + this.z_ * vector.z_;
- }
- double vcMultiplyOfVectors(Vector vector) {
- return this.scMultiplyOfVector(vector) * this.foundSin(vector);
- }
- double foundCos(Vector vector) {
- return (this.scMultiplyOfVector(vector) / (this.calculate() * vector.calculate()));
- }
- double foundSin(Vector vector) {
- return Math.sqrt(1 - this.foundAngle(vector) * this.foundAngle(vector));
- }
- int foundAngle(Vector vector) {
- return (int) Math.acos((this.scMultiplyOfVector(vector) / (this.calculate() * vector.calculate())));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement