Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Trapezoid {
- double x1, y1, z1;
- double x2, y2, z2;
- double x3, y3, z3;
- double x4, y4, z4;
- boolean flag;
- public boolean isFigure() {
- double xx1 = Math.abs(x1 - x2), yy1 = Math.abs(y1 - y2), zz1 = Math.abs(z1 - z2);
- double xx2 = Math.abs(x2 - x3), yy2 = Math.abs(y2 - y3), zz2 = Math.abs(z2 - z3);
- double xx3 = Math.abs(x3 - x4), yy3 = Math.abs(y3 - y4), zz3 = Math.abs(z3 - z4);
- double xx4 = Math.abs(x4 - x1), yy4 = Math.abs(y4 - y1), zz4 = Math.abs(z4 - z1);
- if (Math.abs((xx1 * xx3 + yy1 * yy3 + zz1 * zz3) / (Math.sqrt(xx1 * xx1 + yy1 * yy1 + zz1 * zz1) * Math.sqrt(xx3 * xx3 + yy3 * yy3 + zz3 * zz3))) == 1
- &&
- Math.abs((xx2 * xx4 + yy2 * yy4 + zz2 * zz4) / (Math.sqrt(xx2 * xx2 + yy2 * yy2 + zz2 * zz2) * Math.sqrt(xx4 * xx4 + yy4 * yy4 + zz4 * zz4))) != 1) {
- flag = true;
- }
- else {
- flag = false;
- }
- return flag;
- }
- public double getSquare(){
- double FinalSquare;
- if(flag){
- Dot Vector1 = new Dot(Math.abs(x3 - x4), Math.abs(y3 - y4), Math.abs(z3 - z4)),
- Vector2 = new Dot(Math.abs(x4 - x1), Math.abs(y4 - y1), Math.abs(z4 - z1)),
- Vector3 = new Dot(Math.abs(x1 - x2), Math.abs(y1 - y2), Math.abs(z1 - z2));
- Dot square = new Dot((Vector1.y * Vector2.z - Vector1.z * Vector2.y), (Vector1.x * Vector2.z - Vector1.z * Vector2.x), (Vector1.x * Vector2.y - Vector1.y * Vector2.x));
- double base1 = (Math.sqrt(Vector1.x * Vector1.x + Vector1.y * Vector1.y + Vector1.z * Vector1.z)),
- base2 = (Math.sqrt(Vector3.x * Vector3.x + Vector3.y * Vector3.y + Vector3.z * Vector3.z));
- double height = (Math.sqrt(square.x * square.x + square.y * square.y + square.z * square.z)) / base1;
- FinalSquare = (base1 + base2) * 0.5 * height;
- }
- else{
- System.out.println("ERROR!!!");
- FinalSquare = -1337;
- }
- return FinalSquare;
- }
- public Trapezoid(Dot A, Dot B, Dot C, Dot D){
- this.x1 = A.x; this.y1 = A.y; this.z1 = A.z;
- this.x2 = B.x; this.y2 = B.y; this.z2 = B.z;
- this.x3 = C.x; this.y3 = C.y; this.z3 = C.z;
- this.x4 = D.x; this.y4 = D.y; this.z4 = D.z;
- }
- public Trapezoid(double x1, double y1, double z1,
- double x2, double y2, double z2,
- double x3, double y3, double z3,
- double x4, double y4, double z4){
- this.x1 = x1; this.y1 = y1; this.z1 = z1;
- this.x2 = x2; this.y2 = y2; this.z2 = z2;
- this.x3 = x3; this.y3 = y3; this.z3 = z3;
- this.x4 = x4; this.y4 = y4; this.z4 = z4;
- }
- public Trapezoid(){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement