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:
Exploring the Spring Boot TestRestTemplate
Comparing Long Values in Java
Java Program to Generate All Pairs of Subsets Whose Union Make the Set
Map Serialization and Deserialization with Jackson
Tìm hiểu về Web Service
Convert String to Byte Array and Reverse in Java
Spring Boot - Hystrix
Java 8 Collectors toMap
Vòng lặp for, while, do-while trong Java
Java Program to Implement the Vigenere Cypher
A Quick JUnit vs TestNG Comparison
Java Deep Learning Essentials - Yusuke Sugomori
Introduction to Java 8 Streams
Java Program to Find the Median of two Sorted Arrays using Binary Search Approach
Java toString() Method
Handling Errors in Spring WebFlux
Converting between an Array and a List in Java
Guide to Java 8’s Collectors
Guide to System.gc()
Converting Between an Array and a Set in Java
Java Program to Find Transpose of a Graph Matrix
Một số nguyên tắc, định luật trong lập trình
A Guide to JUnit 5
Java Program for Douglas-Peucker Algorithm Implementation
Java Program to Implement Iterative Deepening
Display Auto-Configuration Report in Spring Boot
Java Program to Represent Graph Using Adjacency Matrix
Login For a Spring Web App – Error Handling and Localization
Java Program to Implement D-ary-Heap
Check If a File or Directory Exists in Java
Java Program to Check Whether a Directed Graph Contains a Eulerian Cycle
Java Program to Implement ArrayDeque API