pythagoras.f.Point.y()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中pythagoras.f.Point.y()方法的一些代码示例,展示了Point.y()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Point.y()方法的具体详情如下:
包路径:pythagoras.f.Point
类名称:Point
方法名:y

Point.y介绍

[英]The y-coordinate of the point.
[中]点的y坐标。

代码示例

代码示例来源:origin: stackoverflow.com

  1. public double distanceFrom(Point other){
  2. double dx = (other.x() - x());
  3. double dy = (other.y() - y());
  4. return Math.sqrt(dx*dx + dy*dy);
  5. }

代码示例来源:origin: stackoverflow.com

  1. public double distanceFrom(Point other){
  2. double distance = 0.0;
  3. double dx = Math.abs(other.x() - this.x());
  4. double dy = Math.abs(other.y() - this.y());
  5. if (dx > dy) {
  6. double ratio = dy/dx;
  7. distance = dx*Math.sqrt(1.0+ratio*ratio);
  8. } else {
  9. double ratio = dx/dy;
  10. distance = dy*Math.sqrt(1.+ratio*ratio);
  11. }
  12. return distance;
  13. }

代码示例来源:origin: threerings/tripleplay

  1. protected float axisDistance (Point start, Point end) {
  2. if (start == null || end == null) return 0;
  3. float value;
  4. if (_direction == Direction.UP || _direction == Direction.DOWN)
  5. value = end.y() - start.y();
  6. else
  7. value = end.x() - start.x();
  8. return _axisSwipe ? Math.abs(value) : value * _directionModifier;
  9. }

代码示例来源:origin: stackoverflow.com

  1. public Rectangle setLocation(Point p) {
  2. return setLocation(p.x(), p.y());
  3. }

代码示例来源:origin: threerings/playn

  1. /**
  2. * Returns true if a coordinate on the screen touches a {@link Layer.HasSize}.
  3. */
  4. public static boolean hitTest(Layer.HasSize layer, float x, float y) {
  5. Point point = screenToLayer(layer, x, y);
  6. return (
  7. point.x() >= 0 && point.y() >= 0 &&
  8. point.x() <= layer.width() && point.y() <= layer.height());
  9. }

代码示例来源:origin: playn/playn

  1. /**
  2. * Returns true if a coordinate on the screen touches a {@link Layer}. Note: if the supplied
  3. * layer has no size, this will always return false.
  4. */
  5. public static boolean hitTest(Layer layer, float x, float y) {
  6. Point point = screenToLayer(layer, x, y);
  7. return (point.x() >= 0 && point.y() >= 0 &&
  8. point.x() <= layer.width() && point.y() <= layer.height());
  9. }

代码示例来源:origin: threerings/tripleplay

  1. /**
  2. * Optionally confines the menu area to the given element. By default the menu is confined
  3. * by the host's screen area (see {@link MenuHost#getScreenArea()}).
  4. */
  5. public Pop inElement (Element<?> elem) {
  6. Point tl = LayerUtil.layerToScreen(elem.layer, 0, 0);
  7. Point br = LayerUtil.layerToScreen(
  8. elem.layer, elem.size().width(), elem.size().height());
  9. bounds = new Rectangle(tl.x(), tl.y(), br.x() - tl.x(), br.y() - tl.y());
  10. return this;
  11. }

代码示例来源:origin: stackoverflow.com

  1. double A = (from.x() - to.x()) /(from.y() - to.y());
  2. double C = from.x() - A *from.y();
  3. double d = 0;
  4. double dmax = 0;

代码示例来源:origin: threerings/tripleplay

  1. offAxisDistance = Math.abs(current.x() - startLoc.x());
  2. else
  3. offAxisDistance = Math.abs(current.y() - startLoc.y());

代码示例来源:origin: com.samskivert/pythagoras

  1. @Override // from RectangularShape
  2. public Rectangle bounds (Rectangle target) {
  3. if (isEmpty()) {
  4. target.setBounds(x(), y(), width(), height());
  5. return target;
  6. }
  7. float rx1 = x();
  8. float ry1 = y();
  9. float rx2 = rx1 + width();
  10. float ry2 = ry1 + height();
  11. Point p1 = startPoint(), p2 = endPoint();
  12. float bx1 = containsAngle(180f) ? rx1 : Math.min(p1.x(), p2.x());
  13. float by1 = containsAngle(90f) ? ry1 : Math.min(p1.y(), p2.y());
  14. float bx2 = containsAngle(0f) ? rx2 : Math.max(p1.x(), p2.x());
  15. float by2 = containsAngle(270f) ? ry2 : Math.max(p1.y(), p2.y());
  16. if (arcType() == PIE) {
  17. float cx = centerX();
  18. float cy = centerY();
  19. bx1 = Math.min(bx1, cx);
  20. by1 = Math.min(by1, cy);
  21. bx2 = Math.max(bx2, cx);
  22. by2 = Math.max(by2, cy);
  23. }
  24. target.setBounds(bx1, by1, bx2 - bx1, by2 - by1);
  25. return target;
  26. }

代码示例来源:origin: samskivert/pythagoras

  1. @Override // from RectangularShape
  2. public Rectangle bounds (Rectangle target) {
  3. if (isEmpty()) {
  4. target.setBounds(x(), y(), width(), height());
  5. return target;
  6. }
  7. float rx1 = x();
  8. float ry1 = y();
  9. float rx2 = rx1 + width();
  10. float ry2 = ry1 + height();
  11. Point p1 = startPoint(), p2 = endPoint();
  12. float bx1 = containsAngle(180f) ? rx1 : Math.min(p1.x(), p2.x());
  13. float by1 = containsAngle(90f) ? ry1 : Math.min(p1.y(), p2.y());
  14. float bx2 = containsAngle(0f) ? rx2 : Math.max(p1.x(), p2.x());
  15. float by2 = containsAngle(270f) ? ry2 : Math.max(p1.y(), p2.y());
  16. if (arcType() == PIE) {
  17. float cx = centerX();
  18. float cy = centerY();
  19. bx1 = Math.min(bx1, cx);
  20. by1 = Math.min(by1, cy);
  21. bx2 = Math.max(bx2, cx);
  22. by2 = Math.max(by2, cy);
  23. }
  24. target.setBounds(bx1, by1, bx2 - bx1, by2 - by1);
  25. return target;
  26. }

代码示例来源:origin: samskivert/pythagoras

  1. @Override // from RectangularShape
  2. public boolean contains (float rx, float ry, float rw, float rh) {
  3. if (!(contains(rx, ry) && contains(rx + rw, ry) &&
  4. contains(rx + rw, ry + rh) && contains(rx, ry + rh))) {
  5. return false;
  6. }
  7. float absExtent = Math.abs(angleExtent());
  8. if (arcType() != PIE || absExtent <= 180f || absExtent >= 360f) {
  9. return true;
  10. }
  11. Rectangle r = new Rectangle(rx, ry, rw, rh);
  12. float cx = centerX(), cy = centerY();
  13. if (r.contains(cx, cy)) {
  14. return false;
  15. }
  16. Point p1 = startPoint(), p2 = endPoint();
  17. return !r.intersectsLine(cx, cy, p1.x(), p1.y()) &&
  18. !r.intersectsLine(cx, cy, p2.x(), p2.y());
  19. }

代码示例来源:origin: com.samskivert/pythagoras

  1. @Override // from RectangularShape
  2. public boolean contains (float rx, float ry, float rw, float rh) {
  3. if (!(contains(rx, ry) && contains(rx + rw, ry) &&
  4. contains(rx + rw, ry + rh) && contains(rx, ry + rh))) {
  5. return false;
  6. }
  7. float absExtent = Math.abs(angleExtent());
  8. if (arcType() != PIE || absExtent <= 180f || absExtent >= 360f) {
  9. return true;
  10. }
  11. Rectangle r = new Rectangle(rx, ry, rw, rh);
  12. float cx = centerX(), cy = centerY();
  13. if (r.contains(cx, cy)) {
  14. return false;
  15. }
  16. Point p1 = startPoint(), p2 = endPoint();
  17. return !r.intersectsLine(cx, cy, p1.x(), p1.y()) &&
  18. !r.intersectsLine(cx, cy, p2.x(), p2.y());
  19. }

代码示例来源:origin: samskivert/pythagoras

  1. if (r.intersectsLine(p1.x(), p1.y(), cx, cy) ||
  2. r.intersectsLine(p2.x(), p2.y(), cx, cy)) {
  3. return true;
  4. if (r.intersectsLine(p1.x(), p1.y(), p2.x(), p2.y())) {
  5. return true;

代码示例来源:origin: com.samskivert/pythagoras

  1. if (r.intersectsLine(p1.x(), p1.y(), cx, cy) ||
  2. r.intersectsLine(p2.x(), p2.y(), cx, cy)) {
  3. return true;
  4. if (r.intersectsLine(p1.x(), p1.y(), p2.x(), p2.y())) {
  5. return true;

相关文章