This is a Java Program to compute cross product of two vectors. In mathematics, the cross product or vector product is a binary operation on two vectors in three-dimensional space. It results in a vector that is perpendicular to both and therefore normal to the plane containing them.
Here is the source code of the Java Program to Compute Cross Product of Two Vectors. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
//This is a java program to find the cross product of two vectors import java.util.Random; public class Cross_Product { public static void main(String args[]) { Random random = new Random(); int u1, u2, u3, v1, v2, v3; u1 = random.nextInt(10); u2 = random.nextInt(10); u3 = random.nextInt(10); v1 = random.nextInt(10); v2 = random.nextInt(10); v3 = random.nextInt(10); int uvi, uvj, uvk; uvi = u2 * v3 - v2 * u3; uvj = v1 * u3 - u1 * v3; uvk = u1 * v2 - v1 * u2; System.out.println("The cross product of the 2 vectors \n u = " + u1 + "i + " + u2 + "j + " + u3 + "k and \n v = " + u1 + "i + " + u2 + "j + " + u3 + "k \n "); System.out.println("u X v : " + uvi + "i +" + uvj + "j+ " + uvk + "k "); } }
Output:
$ javac Cross_Product.java $ java Cross_Product The cross product of the 2 vectors u = 3i + 8j + 9k and v = 3i + 8j + 9k u X v : -2i +48j+ -42k
Related posts:
HttpAsyncClient Tutorial
Autoboxing và Unboxing trong Java
How to Find an Element in a List with Java
How to Count Duplicate Elements in Arraylist
Tìm hiểu về Web Service
Generating Random Dates in Java
Custom JUnit 4 Test Runners
Guide to Spring Cloud Kubernetes
Java Program to Implement Radix Sort
Remove All Occurrences of a Specific Value from a List
Quick Guide to Spring MVC with Velocity
Java Program to Implement Self Balancing Binary Search Tree
Tìm hiểu cơ chế Lazy Evaluation của Stream trong Java 8
Java Program to Generate Randomized Sequence of Given Range of Numbers
Java Program to Implement Randomized Binary Search Tree
HttpClient Basic Authentication
Java Program to Construct K-D Tree for 2 Dimensional Data
Spring’s RequestBody and ResponseBody Annotations
Introduction to Spring Data MongoDB
Jackson – Decide What Fields Get Serialized/Deserialized
Java Program to Check if an UnDirected Graph is a Tree or Not Using DFS
Using Java Assertions
Java Program to Implement LinkedList API
Automatic Property Expansion with Spring Boot
Tạo chương trình Java đầu tiên sử dụng Eclipse
Finding the Differences Between Two Lists in Java
Java Program to Implement Euclid GCD Algorithm
Java Program to Implement Bresenham Line Algorithm
OAuth2.0 and Dynamic Client Registration
Java Program to Find the Vertex Connectivity of a Graph
Hướng dẫn sử dụng luồng vào ra ký tự trong Java
An Introduction to Java.util.Hashtable Class