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:
Loại bỏ các phần tử trùng trong một ArrayList như thế nào?
Java Program to Implement Singly Linked List
Java Program to Implement Counting Sort
Tính đóng gói (Encapsulation) trong java
Apache Commons Collections MapUtils
Implementing a Runnable vs Extending a Thread
Send an email with an attachment
Java Program to Implement Heap’s Algorithm for Permutation of N Numbers
Java Program to Implement Floyd Cycle Algorithm
The Registration API becomes RESTful
Spring @RequestMapping New Shortcut Annotations
Hướng dẫn Java Design Pattern – Composite
Java Program to Perform Postorder Recursive Traversal of a Given Binary Tree
Spring Cloud – Securing Services
Tìm hiểu về xác thực và phân quyền trong ứng dụng
Java Program to Create a Random Graph Using Random Edge Generation
Java Program to Implement Johnson’s Algorithm
Introduction to Spring Boot CLI
Chương trình Java đầu tiên
Spring WebClient Filters
Compact Strings in Java 9
Database Migrations with Flyway
Auditing with JPA, Hibernate, and Spring Data JPA
Getting the Size of an Iterable in Java
Allow user:password in URL
Java Program to Use Dynamic Programming to Solve Approximate String Matching
Java String Conversions
Java Program to Generate All Subsets of a Given Set in the Lexico Graphic Order
Handling URL Encoded Form Data in Spring REST
Lớp Properties trong java
Error Handling for REST with Spring
Java Program to Implement Slicker Algorithm that avoids Triangulation to Find Area of a Polygon