public class Projector
extends java.lang.Object
Specifically, a projector computes u = shift+scale*v, where scale = (u1-u0)/(v1-v0), and shift = u0-scale*v0. The projection exists only for v1 != v0. However, v0 and v1 are otherwise unconstrained. v0 may be greater than v1.
The projection from normalized coordinates u to world coordinates v is simply the inverse, and this inverse exists only for u1 != u0.
By definition, u0 is closest to normalized coordinate u=0, and u1 is closest to normalized coordinate u=1. These coordinates must satisfy the constraints 0.0 <= u0 < u1 <= 1.0.
Typically, the coordinates (v0,v1) represent bounds in world coordinate space. Then, the gaps in normalized coordinate space [0,u0) and (u1,1] represent margins, extra space needed for graphic rendering. The amount of extra space required varies, depending on the graphics. Accounting for this varying amount of extra space is a complex but important aspect of aligning the coordinate systems of two or more graphics.
Alignment is accomplished by simply rendering all graphics using the same projector. We obtain this shared projector by merging the preferred projectors of each graphic. A preferred projector is one that a graphic might use if it were the only one being rendered.
We assume that each graphic has a preferred projector that indicates the world coordinate span [v0,v1] and margins [0,u0) and (u1,1] that it would prefer if it were the only graphic rendered. We then merge two projectors into one so that the merged projector contains the union of the two world coordinate spans and has adequate margins.
A projector has a sign, which is the sign of v1-v0. Note that this sign is never ambiguous, because v1 never equals v0. When merging a projector B into into a projector A, we preserve the sign of projector A.
Constructor and Description |
---|
Projector(double v0,
double v1)
Constructs a projector with specified v values, u0=0, and u1=1.
|
Projector(double v0,
double v1,
double u0,
double u1)
Constructs a projector with specified v and u values.
|
Projector(Projector p)
Constructs a copy of the specified projector.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
double |
getScaleRatio(Projector p)
Gets the scale ratio for this projector and a specified projector.
|
int |
hashCode() |
void |
merge(Projector p)
Merges the specified projector into this projector.
|
java.lang.String |
toString() |
double |
u(double v)
Returns normalized coordinate u corresponding to world coordinate v.
|
double |
u0()
Returns the u-coordinate bound closest to u=0.
|
double |
u1()
Returns the u-coordinate bound closest to u=1.
|
double |
v(double u)
Returns world coordinate v corresponding to normalized coordinate u.
|
double |
v0()
Returns the v-coordinate bound closest to u=0.
|
double |
v1()
Returns the v-coordinate bound closest to u=1.
|
public Projector(double v0, double v1)
v0
- the v coordinate that corresponds to u coordinate 0;
v0 != v1 is required.v1
- the v coordinate that corresponds to u coordinate 1;
v0 != v1 is required.public Projector(double v0, double v1, double u0, double u1)
v0
- the v coordinate that corresponds to u coordinate u0;
v0 != v1 is required.v1
- the v coordinate that corresponds to u coordinate u1;
v0 != v1 is required.u0
- the u coordinate closest to normalized coordinate 0;
0.0 <= u0 < u1 is required.u1
- the u coordinate closest to normalized coordinate 1;
u0 < u1 <= 1.0 is required.public Projector(Projector p)
p
- the projector.public double u(double v)
v
- world coordinate v.public double v(double u)
u
- normalized coordinate u.public double u0()
public double u1()
public double v0()
public double v1()
public void merge(Projector p)
p
- the projector.public double getScaleRatio(Projector p)
This method is typically used to account for the effects of merging two or more projectors. For example, after merging, parameters that are proportional to the sizes of margins [0,u0) or (u1,1] in the specified projector should be scaled by this ratio before being used with this projector.
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object