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:
Multi Dimensional ArrayList in Java
Java Program to Implement Naor-Reingold Pseudo Random Function
Jackson Date
Loại bỏ các phần tử trùng trong một ArrayList như thế nào trong Java 8?
The Thread.join() Method in Java
Toán tử instanceof trong java
Java Program to Solve any Linear Equation in One Variable
Lớp Properties trong java
Java Program to Perform Stooge Sort
An Introduction to Java.util.Hashtable Class
How to Use if/else Logic in Java 8 Streams
A Guide to JUnit 5 Extensions
Apache Camel with Spring Boot
An Intro to Spring Cloud Zookeeper
Hướng dẫn sử dụng Lớp FilePermission trong java
Java Program to Implement Direct Addressing Tables
Java Program to Find the Median of two Sorted Arrays using Binary Search Approach
Iterating over Enum Values in Java
Java Program to Generate a Random UnDirected Graph for a Given Number of Edges
Java Switch Statement
Java Program to Implement AttributeList API
Java Program to Perform Uniform Binary Search
Check If Two Lists are Equal in Java
Spring Webflux with Kotlin
Java – Reader to InputStream
Form Validation with AngularJS and Spring MVC
Map Serialization and Deserialization with Jackson
Debug a HttpURLConnection problem
Login For a Spring Web App – Error Handling and Localization
Java Program to Implement Insertion Sort
Tránh lỗi ConcurrentModificationException trong Java như thế nào?
A Guide to the ResourceBundle