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 List UnsupportedOperationException
The Basics of Java Security
So sánh HashSet, LinkedHashSet và TreeSet trong Java
Java Program to Apply DFS to Perform the Topological Sorting of a Directed Acyclic Graph
Java Program to Implement Merge Sort Algorithm on Linked List
Java Program to Implement Aho-Corasick Algorithm for String Matching
The Spring @Controller and @RestController Annotations
Tạo chương trình Java đầu tiên sử dụng Eclipse
How to Convert List to Map in Java
Java Program to Implement Bit Array
A Quick Guide to Using Keycloak with Spring Boot
Spring Boot - Tracing Micro Service Logs
Binary Numbers in Java
Interface trong Java 8 – Default method và Static method
Spring Boot - Twilio
Java Program to implement Array Deque
Java Program to Compare Binary and Sequential Search
Java Program to Implement Queue
Spring Cloud Connectors and Heroku
Java Program to Implement Fenwick Tree
Java Program to Find Nearest Neighbor for Static Data Set
OAuth2 Remember Me with Refresh Token
Java Program to Generate a Sequence of N Characters for a Given Specific Case
Spring Cloud AWS – Messaging Support
Java Program to Implement Extended Euclid Algorithm
4 tính chất của lập trình hướng đối tượng trong Java
@Lookup Annotation in Spring
A Guide to JUnit 5 Extensions
Java Program to Perform Matrix Multiplication
Java Program to Implement DelayQueue API
Spring Security and OpenID Connect
Java Program to Implement Sorted Circular Doubly Linked List