This is a java program to show the duality transformation of line and point. The transformation corresponds from line to point and point to line.
Here is the source code of the Java Program to Show the Duality Transformation of Line and Point. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
package com.maixuanviet.computationalgeometry; import java.util.Scanner; public class DualityTransformationofPointandLine { public static void performLineTransformation(double a, double b) { System.out.println("X: " + (b / a) + ", Y: " + (b * -1)); } public static void performPointTransformation(double x, double y) { System.out.println("y=" + (-1 * y / x) + "x +" + (-1 * y)); } public static void main(String[] args) { System.out .println("Perform what transformation.\n1. Line Transformation\n2. Point Transformation"); Scanner sc = new Scanner(System.in); int option = sc.nextInt(); switch (option) { case 1: System.out.println("Enter the coefficients of line <y=ax-b>"); double a = sc.nextDouble(); double b = sc.nextDouble(); performLineTransformation(a, b); break; case 2: System.out.println("Enter the coordinate of point <x, y>"); double x = sc.nextDouble(); double y = sc.nextDouble(); performPointTransformation(x, y); break; default: break; } sc.close(); } }
Output:
$ javac DualityTransformationofPointandLine.java $ java DualityTransformationofPointandLine Perform what transformation. 1. Line Transformation 2. Point Transformation 1 Enter the coefficients of line <y=ax-b> 1 2 X: 2.0, Y: -2.0 Perform what transformation. 1. Line Transformation 2. Point Transformation 2 Enter the coordinate of point <x, y> 2 -2 y=1.0x +2.0
Related posts:
The Guide to RestTemplate
Spring Security OAuth2 – Simple Token Revocation
Java Program to Implement Range Tree
Java Program to Implement Patricia Trie
Java Program to Check whether Graph is Biconnected
How to Remove the Last Character of a String?
Java equals() and hashCode() Contracts
A Guide to Iterator in Java
Guide to Apache Commons CircularFifoQueue
Check If a File or Directory Exists in Java
Java Program to Generate All Possible Subsets with Exactly k Elements in Each Subset
Exploring the New Spring Cloud Gateway
Java Program to Generate Random Hexadecimal Byte
Java Program to Generate a Random UnDirected Graph for a Given Number of Edges
Java Program to Find the Shortest Path Between Two Vertices Using Dijkstra’s Algorithm
A Guide to JPA with Spring
Unsatisfied Dependency in Spring
Java – Write an InputStream to a File
Java Program for Topological Sorting in Graphs
Java Program to Implement Shunting Yard Algorithm
Hướng dẫn sử dụng Printing Service trong Java
Filtering a Stream of Optionals in Java
The Java 8 Stream API Tutorial
Supplier trong Java 8
Java Program to Implement Hash Tables Chaining with Doubly Linked Lists
Java Program to Implement Find all Forward Edges in a Graph
Java Program to Implement ArrayBlockingQueue API
Disable DNS caching
Java Program to Find the Mode in a Data Set
Deque và ArrayDeque trong Java
Java Program to Implement an Algorithm to Find the Global min Cut in a Graph
Guide to Spring 5 WebFlux