Code Examples
A repository of 155 code examples for BeepBeep
basic.PointDistance Class Reference

Calculate the Euclidean distance of each two successive points in an input trace of (x,y) coordinates. More...

Classes

class  Distance
 We create a new function: Distance.
 
class  Point
 

Static Public Member Functions

static void main (String[] args)
 
static Object [] getListOfPoints ()
 Creates a dummy array of points. More...
 

Detailed Description

Calculate the Euclidean distance of each two successive points in an input trace of (x,y) coordinates.

For two points (x1,y1) and (x2,y2), the Euclidean distance is defined as the square root of (x1-x2)2 + (y1-y2)2. The chain of processors in this example can be represented graphically as:

Processor graph

In this picture, light green pipes correspond to streams of Point objects. The processor with a ruler and a "d" is the Distance processor defined below.

On an input stream made of points (2,7), (1,8), (2,8), (1,8), …, the expected output of this program should look like:

1.4142135
1.0
1.0
1.0
3.6055512
…
Author
Sylvain Hallé Easy

Definition at line 60 of file PointDistance.java.

Member Function Documentation

◆ getListOfPoints()

static Object [] basic.PointDistance.getListOfPoints ( )
static

Creates a dummy array of points.

Returns
An array of points

Definition at line 139 of file PointDistance.java.

140  {
141  return new Object[]{
142  new Point(2, 7),
143  new Point(1, 8),
144  new Point(2, 8),
145  new Point(1, 8),
146  new Point(2, 8),
147  new Point(4, 5),
148  new Point(9, 0),
149  new Point(4, 5),
150  new Point(2, 3),
151  new Point(5, 3),
152  new Point(6, 0),
153  new Point(2, 8)
154  };
155  }

The documentation for this class was generated from the following file: