本文整理了Java中pythagoras.f.Point.x()
方法的一些代码示例,展示了Point.x()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Point.x()
方法的具体详情如下:
包路径:pythagoras.f.Point
类名称:Point
方法名:x
[英]The x-coordinate of the point.
[中]点的x坐标。
代码示例来源:origin: stackoverflow.com
public double distanceFrom(Point other){
double dx = (other.x() - x());
double dy = (other.y() - y());
return Math.sqrt(dx*dx + dy*dy);
}
代码示例来源:origin: stackoverflow.com
public double distanceFrom(Point other){
double distance = 0.0;
double dx = Math.abs(other.x() - this.x());
double dy = Math.abs(other.y() - this.y());
if (dx > dy) {
double ratio = dy/dx;
distance = dx*Math.sqrt(1.0+ratio*ratio);
} else {
double ratio = dx/dy;
distance = dy*Math.sqrt(1.+ratio*ratio);
}
return distance;
}
代码示例来源:origin: threerings/tripleplay
protected float axisDistance (Point start, Point end) {
if (start == null || end == null) return 0;
float value;
if (_direction == Direction.UP || _direction == Direction.DOWN)
value = end.y() - start.y();
else
value = end.x() - start.x();
return _axisSwipe ? Math.abs(value) : value * _directionModifier;
}
代码示例来源:origin: stackoverflow.com
public Rectangle setLocation(Point p) {
return setLocation(p.x(), p.y());
}
代码示例来源:origin: threerings/playn
/**
* Returns true if a coordinate on the screen touches a {@link Layer.HasSize}.
*/
public static boolean hitTest(Layer.HasSize layer, float x, float y) {
Point point = screenToLayer(layer, x, y);
return (
point.x() >= 0 && point.y() >= 0 &&
point.x() <= layer.width() && point.y() <= layer.height());
}
代码示例来源:origin: playn/playn
/**
* Returns true if a coordinate on the screen touches a {@link Layer}. Note: if the supplied
* layer has no size, this will always return false.
*/
public static boolean hitTest(Layer layer, float x, float y) {
Point point = screenToLayer(layer, x, y);
return (point.x() >= 0 && point.y() >= 0 &&
point.x() <= layer.width() && point.y() <= layer.height());
}
代码示例来源:origin: threerings/tripleplay
/**
* Optionally confines the menu area to the given element. By default the menu is confined
* by the host's screen area (see {@link MenuHost#getScreenArea()}).
*/
public Pop inElement (Element<?> elem) {
Point tl = LayerUtil.layerToScreen(elem.layer, 0, 0);
Point br = LayerUtil.layerToScreen(
elem.layer, elem.size().width(), elem.size().height());
bounds = new Rectangle(tl.x(), tl.y(), br.x() - tl.x(), br.y() - tl.y());
return this;
}
代码示例来源:origin: stackoverflow.com
double A = (from.x() - to.x()) /(from.y() - to.y());
double C = from.x() - A *from.y();
double d = 0;
double dmax = 0;
代码示例来源:origin: threerings/tripleplay
lastNode == null ? null : lastNode.location, current);
if (_direction == Direction.UP || _direction == Direction.DOWN)
offAxisDistance = Math.abs(current.x() - startLoc.x());
else
offAxisDistance = Math.abs(current.y() - startLoc.y());
代码示例来源:origin: com.samskivert/pythagoras
@Override // from RectangularShape
public Rectangle bounds (Rectangle target) {
if (isEmpty()) {
target.setBounds(x(), y(), width(), height());
return target;
}
float rx1 = x();
float ry1 = y();
float rx2 = rx1 + width();
float ry2 = ry1 + height();
Point p1 = startPoint(), p2 = endPoint();
float bx1 = containsAngle(180f) ? rx1 : Math.min(p1.x(), p2.x());
float by1 = containsAngle(90f) ? ry1 : Math.min(p1.y(), p2.y());
float bx2 = containsAngle(0f) ? rx2 : Math.max(p1.x(), p2.x());
float by2 = containsAngle(270f) ? ry2 : Math.max(p1.y(), p2.y());
if (arcType() == PIE) {
float cx = centerX();
float cy = centerY();
bx1 = Math.min(bx1, cx);
by1 = Math.min(by1, cy);
bx2 = Math.max(bx2, cx);
by2 = Math.max(by2, cy);
}
target.setBounds(bx1, by1, bx2 - bx1, by2 - by1);
return target;
}
代码示例来源:origin: samskivert/pythagoras
@Override // from RectangularShape
public Rectangle bounds (Rectangle target) {
if (isEmpty()) {
target.setBounds(x(), y(), width(), height());
return target;
}
float rx1 = x();
float ry1 = y();
float rx2 = rx1 + width();
float ry2 = ry1 + height();
Point p1 = startPoint(), p2 = endPoint();
float bx1 = containsAngle(180f) ? rx1 : Math.min(p1.x(), p2.x());
float by1 = containsAngle(90f) ? ry1 : Math.min(p1.y(), p2.y());
float bx2 = containsAngle(0f) ? rx2 : Math.max(p1.x(), p2.x());
float by2 = containsAngle(270f) ? ry2 : Math.max(p1.y(), p2.y());
if (arcType() == PIE) {
float cx = centerX();
float cy = centerY();
bx1 = Math.min(bx1, cx);
by1 = Math.min(by1, cy);
bx2 = Math.max(bx2, cx);
by2 = Math.max(by2, cy);
}
target.setBounds(bx1, by1, bx2 - bx1, by2 - by1);
return target;
}
代码示例来源:origin: samskivert/pythagoras
@Override // from RectangularShape
public boolean contains (float rx, float ry, float rw, float rh) {
if (!(contains(rx, ry) && contains(rx + rw, ry) &&
contains(rx + rw, ry + rh) && contains(rx, ry + rh))) {
return false;
}
float absExtent = Math.abs(angleExtent());
if (arcType() != PIE || absExtent <= 180f || absExtent >= 360f) {
return true;
}
Rectangle r = new Rectangle(rx, ry, rw, rh);
float cx = centerX(), cy = centerY();
if (r.contains(cx, cy)) {
return false;
}
Point p1 = startPoint(), p2 = endPoint();
return !r.intersectsLine(cx, cy, p1.x(), p1.y()) &&
!r.intersectsLine(cx, cy, p2.x(), p2.y());
}
代码示例来源:origin: com.samskivert/pythagoras
@Override // from RectangularShape
public boolean contains (float rx, float ry, float rw, float rh) {
if (!(contains(rx, ry) && contains(rx + rw, ry) &&
contains(rx + rw, ry + rh) && contains(rx, ry + rh))) {
return false;
}
float absExtent = Math.abs(angleExtent());
if (arcType() != PIE || absExtent <= 180f || absExtent >= 360f) {
return true;
}
Rectangle r = new Rectangle(rx, ry, rw, rh);
float cx = centerX(), cy = centerY();
if (r.contains(cx, cy)) {
return false;
}
Point p1 = startPoint(), p2 = endPoint();
return !r.intersectsLine(cx, cy, p1.x(), p1.y()) &&
!r.intersectsLine(cx, cy, p2.x(), p2.y());
}
代码示例来源:origin: samskivert/pythagoras
if (r.intersectsLine(p1.x(), p1.y(), cx, cy) ||
r.intersectsLine(p2.x(), p2.y(), cx, cy)) {
return true;
if (r.intersectsLine(p1.x(), p1.y(), p2.x(), p2.y())) {
return true;
代码示例来源:origin: com.samskivert/pythagoras
if (r.intersectsLine(p1.x(), p1.y(), cx, cy) ||
r.intersectsLine(p2.x(), p2.y(), cx, cy)) {
return true;
if (r.intersectsLine(p1.x(), p1.y(), p2.x(), p2.y())) {
return true;
内容来源于网络,如有侵权,请联系作者删除!