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:
Send email with JavaMail
Custom Cascading in Spring Data MongoDB
Java Program to Implement Pagoda
Weak References in Java
Java NIO2 Path API
Use Liquibase to Safely Evolve Your Database Schema
Check If a File or Directory Exists in Java
Đồng bộ hóa các luồng trong Java
An Intro to Spring Cloud Security
Java Program to Check Whether a Directed Graph Contains a Eulerian Cycle
Kết hợp Java Reflection và Java Annotations
Java Program to Implement Hamiltonian Cycle Algorithm
Java Program to Implement Queue using Linked List
4 tính chất của lập trình hướng đối tượng trong Java
Java Program to Implement Stack API
Adding Shutdown Hooks for JVM Applications
REST Web service: Tạo ứng dụng Java RESTful Client với Jersey Client 2.x
Spring Boot - Quick Start
Apache Commons Collections Bag
Java Program to Implement SimpeBindings API
Guide to java.util.Formatter
Hướng dẫn Java Design Pattern – Command
Show Hibernate/JPA SQL Statements from Spring Boot
Spring 5 Testing with @EnabledIf Annotation
Transactions with Spring and JPA
The Java 8 Stream API Tutorial
Java Program to Solve the 0-1 Knapsack Problem
Java Program to Implement Max Heap
Spring Security Login Page with React
An Introduction to Java.util.Hashtable Class
Instance Profile Credentials using Spring Cloud
Lớp Collections trong Java (Collections Utility Class)