Whilst sifting through old documents this evening, I stumbled across something from back when I was a little baby coder, the first program I ever wrote over a decade ago! Precious!
//Hannah Noble
import java.util.Scanner;
public class Ex1
{
public static void main (String[] args)
{
double ax, ay, az, bx, by, bz, cx, cy, cz;
Scanner keys = new Scanner(System.in);
System.out.println(“Enter x for point A:”);
ax = keys.nextDouble();
System.out.println(“Enter y for point A:”);
ay = keys.nextDouble();
System.out.println(“Enter z for point A:”);
az = keys.nextDouble();
System.out.println(“Enter x for point B:”);
bx = keys.nextDouble();
System.out.println(“Enter y for point B:”);
by = keys.nextDouble();
System.out.println(“Enter z for point B:”);
bz = keys.nextDouble();
System.out.println(“Enter x for point C:”);
cx = keys.nextDouble();
System.out.println(“Enter y for point C:”);
cy = keys.nextDouble();
System.out.println(“Enter z for point C:”);
cz = keys.nextDouble();
double vx = (bx - ax), vy = (by - ay), vz = (bz - az);
double wx = (cx - ax), wy = (cy - ay), wz = (cz - az);
double nx = (vy * wz - wy * vz);
double ny = (wx * vz - vx * wz);
double nz = (vx * wy - wx * vy);
double vn = (vx * nx + vy * ny + vz * nz);
double wn = (wx * nx + wy * ny + wz * nz);
System.out.println(“B-A is (” + vx + “, ” + vy + “, ” + vz + “)” );
System.out.println(“C-A is (” + wx + “, ” + wy + “, ” + wz + “)” );
System.out.println(“N is (” + nx + “, ” + ny + “, ” + nz + “)” );
System.out.println(“dot product of B-A and N is ” + vn);
System.out.println(“dot product of C-A and N is ” + wn);
}
}