public class Real2Vector extends Object implements EuclidConstants
Support is also given for the two component arrays as RealArrays
Default is an empty (Java) Vector;
C_AMP, C_APOS, C_ATSIGN, C_BACKSLASH, C_BACKSPACE, C_CARET, C_COLON, C_COMMA, C_DEL, C_DOLLAR, C_EQUALS, C_FORMFEED, C_HASH, C_LANGLE, C_LBRAK, C_LCURLY, C_LSQUARE, C_MINUS, C_NBSP, C_NEWLINE, C_NL, C_PERCENT, C_PERIOD, C_PIPE, C_PLUS, C_POUND, C_QUERY, C_QUOT, C_RANGLE, C_RBRAK, C_RCURLY, C_RETURN, C_RSQUARE, C_SEMICOLON, C_SHRIEK, C_SLASH, C_SPACE, C_STAR, C_TAB, C_TILDE, C_UNDER, EPS, F_S, NONWHITEPUNC, NONWHITEPUNC0, NONWHITEPUNC0REGEX, ONE_THIRD, PUNC, S_AMP, S_APOS, S_ATSIGN, S_BACKSLASH, S_CARET, S_COLON, S_COMMA, S_DOLLAR, S_EMPTY, S_EQUALS, S_FORMFEED, S_HASH, S_LANGLE, S_LBRAK, S_LCURLY, S_LSQUARE, S_MINUS, S_NEWLINE, S_NL, S_PERCENT, S_PERIOD, S_PIPE, S_PLUS, S_POUND, S_QUERY, S_QUOT, S_RANGLE, S_RBRAK, S_RCURLY, S_RETURN, S_RSQUARE, S_SEMICOLON, S_SHRIEK, S_SLASH, S_SPACE, S_STAR, S_TAB, S_TILDE, S_UNDER, S_WHITEREGEX, TWO_THIRDS, U_S, WHITESPACE| Constructor and Description |
|---|
Real2Vector()
constructor.
|
Real2Vector(double[] flarray)
Formed by feeding in an existing array to a 2xn matrix THE COLUMN IS THE
FASTEST MOVING INDEX, that is the matrix is filled as flarray(0,0,
flarray(0,1).
|
Real2Vector(int n,
double[] x,
double[] y)
from two parallel arrays of x, y - by REFERENCE.
|
Real2Vector(List<Real2> rList)
construct from list of Real2.
|
Real2Vector(Real2Array r2a)
conversion routine.
|
Real2Vector(Real2Vector pv)
copy constructor from Real2Vector COPIES pv
|
Real2Vector(RealArray m)
constructor from RealArray - by REFERENCE
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Real2 p)
appens a Real2.
|
Angle |
angle(int i1,
int i2,
int i3)
get angle between 3 points
|
Angle |
angle(IntSet is)
get angle between 3 points
|
double |
distance(int i1,
int i2)
get distance between 2 points
|
double |
distance(IntSet is)
get distance between 2 points
|
boolean |
encloses(Real2 point)
if real2Vector is treated as a polygon, determines whether point
is inside it
// The function will return true if the point x,y is inside the polygon, or
// false if it is not.
|
void |
flipX()
creates mirror image
changes sign of x-coords
|
void |
flipY()
creates mirror image
changes sign of y-coords
|
Real2 |
get(int i)
gets Real2 element.
|
Real2 |
getCentroid()
get centroid of all points.
|
int |
getClosestPoint(Real2 p)
get the closest point (both ranges are assumed to have the same scales
|
double |
getCoordinate(int i,
Axis.Axis2 j)
get a single coordinate value
|
RealMatrix |
getDistanceMatrix(List<Real2> coords2)
get rectangular distance matrix.
|
int |
getPoint(Real2 p,
double width,
double height)
get the index of the first point within a box centered on p (that is p+-
width/2, height/2) or -1 if none
|
RealRange |
getRange(Axis.Axis2 ax)
get range of one coordinate
|
Real2Range |
getRange2()
get range of both coordinates
|
Real2 |
getReal2(int i)
get the i'th Real2
|
Real2Array |
getReal2Array()
convenience
|
List<Real2> |
getReal2List()
get List of Real2s.
|
int |
getSerialOfNearestPoint(Real2 point)
get serialNumber of nearest point.
|
double |
getSquaredDifference(Real2Vector r2v)
squared difference between corresponding points in 2 real2Vectors.
|
double[] |
getSquaredDistances(Real2Vector r2v)
gets array of squared distances between corresponding points.
|
List<Real2> |
getVector()
access the vector.
|
RealArray |
getXArray()
get the X coordinate array
|
RealArray |
getXorY(Axis.Axis2 axis)
get a single coordinate array - for example all x-coordinates
|
RealArray |
getXY()
get the coordinate coordinate array as doubles x,y,x,y,
|
RealArray |
getYArray()
get the Y coordinate array
|
void |
multiplyBy(double f)
multiply all coordinates be a given scalar (that is expands scale)
|
static Real2Vector |
partOfRegularPolygon(int nsides,
int pointn,
double dist0n)
create part of regular polygon.
|
void |
plus(Real2 p)
add a Real2 to all elements of this.
|
static Real2Vector |
regularPolygon(int nsides,
double rad)
create regular polygon.
|
static Real2Vector |
regularPolygon(int nsides,
double rad,
double angle)
create regular polygon.
|
static Real2Vector |
regularPolygon(int nsides,
Real2 p1,
Real2 p2,
boolean flip)
create regular polygon.
|
void |
rotateAboutCentroid(Angle a)
rotate about centroid by given angle; MODIFIES 'this'
|
void |
set(int i,
Real2 v) |
int |
size()
size of vector.
|
Real2Vector |
sortAscending(Axis.Axis2 ax)
sort ARRAY on X or Y coordinate; returns new array
|
Real2Vector |
sortDescending(Axis.Axis2 ax)
sort ARRAY on X or Y coordinate; returns new array
|
Real2Vector |
subArray(IntSet is)
create a NEW subset of the points; points are COPIED
|
IntSet |
subSet(Real2Range r)
create a subset of the points within a box
|
void |
subtract(Real2 v)
translate negatively; MODIFIES 'this'
|
void |
swapXY()
swap all X and Y coordinates; MODIFIES array
|
String |
toString()
to string.
|
void |
transformBy(Transform2 t)
transforms 'this' by rotation-translation matrix; MODIFIES 'this'
|
void |
translateBy(Real2 v)
translate by a vector, synonym for plus.
|
public Real2Vector()
public Real2Vector(double[] flarray)
throws EuclidRuntimeException
flarray - EuclidRuntimeException - array must have even number of elementspublic Real2Vector(int n,
double[] x,
double[] y)
throws EuclidRuntimeException
n - x - y - EuclidRuntimeExceptionpublic Real2Vector(Real2Array r2a)
r2a - public Real2Vector(RealArray m) throws EuclidRuntimeException
m - EuclidRuntimeException - array must have even number of elementspublic Real2Vector(Real2Vector pv)
pv - public void add(Real2 p)
p - to appendpublic Real2 get(int i)
i - the positionpublic void set(int i,
Real2 v)
throws EuclidRuntimeException
i - v - EuclidRuntimeException - vector does not have an i'th elementpublic int size()
public List<Real2> getVector()
public RealRange getRange(Axis.Axis2 ax)
ax - public Real2Range getRange2()
public Real2Vector subArray(IntSet is) throws EuclidRuntimeException
is - EuclidRuntimeException - an element of is is out of range of thispublic IntSet subSet(Real2Range r)
r - public int getClosestPoint(Real2 p)
p - public int getPoint(Real2 p, double width, double height)
p - width - height - public void translateBy(Real2 v)
v - public void plus(Real2 p)
p - public void subtract(Real2 v)
v - public void multiplyBy(double f)
f - public double distance(int i1,
int i2)
i1 - i2 - public double distance(IntSet is) throws EuclidRuntimeException
is - EuclidRuntimeException - a value in IntSet is not in the range 0 ... nelem-1public Angle angle(int i1, int i2, int i3) throws EuclidRuntimeException
i1 - i2 - i3 - EuclidRuntimeException - two points are coincidentpublic Angle angle(IntSet is) throws EuclidRuntimeException
is - EuclidRuntimeException - a value in IntSet is not in the range 0 ... nelem-1public Real2 getReal2(int i)
i - public RealArray getXY()
public RealArray getXArray()
public RealArray getYArray()
public Real2Array getReal2Array()
public double getCoordinate(int i,
Axis.Axis2 j)
i - j - public RealArray getXorY(Axis.Axis2 axis)
axis - public void swapXY()
public Real2Vector sortAscending(Axis.Axis2 ax)
ax - public Real2Vector sortDescending(Axis.Axis2 ax)
ax - public void transformBy(Transform2 t)
t - public double getSquaredDifference(Real2Vector r2v)
r2v - vector to comparepublic double[] getSquaredDistances(Real2Vector r2v)
r2v - other vectorpublic void rotateAboutCentroid(Angle a)
a - public void flipX()
public void flipY()
public static Real2Vector regularPolygon(int nsides, double rad, double angle)
nsides - rad - the radiusangle - offset to vertical (radians)
(point 0 is at rad*cos(angle), rad*sin(angle))public static Real2Vector partOfRegularPolygon(int nsides, int pointn, double dist0n)
nsides - pointn - dist0n - between point0 and npointpublic static Real2Vector regularPolygon(int nsides, double rad)
nsides - rad - the radiuspublic static Real2Vector regularPolygon(int nsides, Real2 p1, Real2 p2, boolean flip)
nsides - p1 - first pointp2 - second pointflip - use mirror imagepublic Real2 getCentroid()
public int getSerialOfNearestPoint(Real2 point)
point - public RealMatrix getDistanceMatrix(List<Real2> coords2)
coords2 - public boolean encloses(Real2 point)
Copyright © 1994–2024 Peter Murray-Rust. All rights reserved.