Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

distance point to line java

//returns the distance between the infinite line(x1,y1)(x2,y2) and a point(x,y)
public float pDistance(float x, float y, float x1, float y1, float x2, float y2) {

      float A = x - x1; // position of point rel one end of line
      float B = y - y1;
      float C = x2 - x1; // vector along line
      float D = y2 - y1;
      float E = -D; // orthogonal vector
      float F = C;

      float dot = A * E + B * F;
      float len_sq = E * E + F * F;

      return (float) Math.abs(dot) / Math.sqrt(len_sq);
    }
Comment

PREVIOUS NEXT
Code Example
Java :: esponente in java 
Java :: Java for and while loops 
Java :: Java program to print decimal to octal conversion 
Java :: array contain java 
Java :: set spring context 
Java :: how to make a dictionary in java 
Java :: set view size android 
Java :: how to create alert dialog in android studio 
Java :: json array get json object 
Java :: java array sortieren 
Java :: how to check number format exception in java 
Java :: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.5.0:repackage failed: 
Java :: H2 enabling remote database creation first 
Java :: android setTextColor not working 
Java :: tostring in java 
Java :: java search arraylist 
Java :: current time stamp android java 
Java :: stringbuilder insert beginning 
Java :: spring log info 
Java :: phone number format java 
Java :: largest number in an array in java 
Java :: icon share android 
Java :: if else statement 
Java :: rock paper scissors java 
Java :: what are method in java 
Java :: Hash map, Hash set and Hash Table difference 
Java :: set text in edittext android 
Java :: java run jar with args 
Java :: Java How to use List? 
Java :: java.lang.NoClassDefFoundError: 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =