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:
Java – Delete a File
Lớp Collectors trong Java 8
Map to String Conversion in Java
Assertions in JUnit 4 and JUnit 5
@Lookup Annotation in Spring
Java 8 – Powerful Comparison with Lambdas
Spring Data MongoDB Transactions
Java Program to Find Basis and Dimension of a Matrix
REST Pagination in Spring
Request a Delivery / Read Receipt in Javamail
Java Program to Implement Ternary Search Tree
RegEx for matching Date Pattern in Java
Java Program to Generate All Subsets of a Given Set in the Lexico Graphic Order
Spring Boot - Creating Docker Image
Java Program to Implement Sieve Of Sundaram
New Features in Java 10
Java Program to Find All Pairs Shortest Path
How to Add a Single Element to a Stream
Tìm hiểu về xác thực và phân quyền trong ứng dụng
Java Program to Implement Sorted Array
Java Program to Repeatedly Search the Same Text (such as Bible by building a Data Structure)
Java Program to Implement ConcurrentLinkedQueue API
Hướng dẫn Java Design Pattern – Interpreter
Introduction to the Java NIO Selector
Chuyển đổi từ HashMap sang ArrayList
Java Program to Implement Solovay Strassen Primality Test Algorithm
Hướng dẫn sử dụng biểu thức chính quy (Regular Expression) trong Java
So sánh Array và ArrayList trong Java
Vector trong Java
Java Program to Solve Set Cover Problem assuming at max 2 Elements in a Subset
String Joiner trong Java 8
How to Delay Code Execution in Java