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:
Notify User of Login From New Device or Location
Service Registration with Eureka
Luồng Daemon (Daemon Thread) trong Java
Xử lý ngoại lệ đối với trường hợp ghi đè phương thức trong java
Các nguyên lý thiết kế hướng đối tượng – SOLID
Hướng dẫn tạo và sử dụng ThreadPool trong Java
Java Program to Find the Longest Subsequence Common to All Sequences in a Set of Sequences
Java Program to Implement Repeated Squaring Algorithm
Java Program to Construct a Random Graph by the Method of Random Edge Selection
Quản lý bộ nhớ trong Java với Heap Space vs Stack
Java Program to Find a Good Feedback Edge Set in a Graph
Chuyển đổi từ HashMap sang ArrayList
Rest Web service: Filter và Interceptor với Jersey 2.x (P1)
Guide to the ConcurrentSkipListMap
Request Method Not Supported (405) in Spring
Xử lý ngoại lệ trong Java (Exception Handling)
Spring Boot - Google OAuth2 Sign-In
Using a Spring Cloud App Starter
Java Program to Implement VList
The Order of Tests in JUnit
Iterating over Enum Values in Java
Introduction to Java 8 Streams
Introduction to the Java NIO Selector
REST Web service: Tạo ứng dụng Java RESTful Client với Jersey Client 2.x
Java Program to Create the Prufer Code for a Tree
Java Program to Generate Random Numbers Using Multiply with Carry Method
Hướng dẫn Java Design Pattern – Adapter
Giới thiệu SOAP UI và thực hiện test Web Service
Giới thiệu Json Web Token (JWT)
Ignore Null Fields with Jackson
Java Program to Give an Implementation of the Traditional Chinese Postman Problem
Tổng quan về ngôn ngữ lập trình java