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 Program to Implement the Schonhage-Strassen Algorithm for Multiplication of Two Numbers
Java Program to Find Maximum Element in an Array using Binary Search
Read an Outlook MSG file
Java Program to find the maximum subarray sum O(n^2) time(naive method)
Xây dựng ứng dụng Client-Server với Socket trong Java
CyclicBarrier in Java
Giới thiệu java.io.tmpdir
Life Cycle of a Thread in Java
Send email with SMTPS (eg. Google GMail)
Java Program to Find the Shortest Path from Source Vertex to All Other Vertices in Linear Time
Java Streams vs Vavr Streams
Spring Webflux and CORS
Deploy a Spring Boot WAR into a Tomcat Server
Java Program to Check if it is a Sparse Matrix
Java Program to Find the Edge Connectivity of a Graph
Java Program to Evaluate an Expression using Stacks
Java Program to implement Bit Matrix
Java Program to Implement ArrayBlockingQueue API
Tính đa hình (Polymorphism) trong Java
Mệnh đề if-else trong java
Java Program to Implement Coppersmith Freivald’s Algorithm
Extract links from an HTML page
Optional trong Java 8
Java Program to Implement Expression Tree
Java Program to Implement Euler Circuit Problem
Getting Started with Forms in Spring MVC
Java Program to Implement D-ary-Heap
Logout in an OAuth Secured Application
Java Program to Check Whether a Given Point is in a Given Polygon
Use Liquibase to Safely Evolve Your Database Schema
Find the Registered Spring Security Filters
ArrayList trong java