point

Find if point lays on line segment

爷,独闯天下 提交于 2019-11-27 03:58:22
I have line segment defined by two points A(x1,y1,z1) and B(x2,y2,z2) and point p(x,y,z). How can I check if the point lays on the line segment? Rob Agar If the point is on the line then: (x - x1) / (x2 - x1) = (y - y1) / (y2 - y1) = (z - z1) / (z2 - z1) Calculate all three values, and if they are the same (to some degree of tolerance), your point is on the line. To test if the point is in the segment, not just on the line, you can check that x1 < x < x2, assuming x1 < x2, or y1 < y < y2, assuming y1 < y2, or z1 < z < z2, assuming z1 < z2 Find the distance of point P from both the line end

Java: Calculating the angle between two points in degrees

帅比萌擦擦* 提交于 2019-11-27 03:33:49
I need to calculate the angle in degrees between two points for my own Point class, Point a shall be the center point. Method: public float getAngle(Point target) { return (float) Math.toDegrees(Math.atan2(target.x - x, target.y - y)); } Test 1: // returns 45 Point a = new Point(0, 0); System.out.println(a.getAngle(new Point(1, 1))); Test 2: // returns -90, expected: 270 Point a = new Point(0, 0); System.out.println(a.getAngle(new Point(-1, 0))); How can i convert the returned result into a number between 0 and 359? you could add the following: public float getAngle(Point target) { float angle

calculate a perpendicular offset from a diagonal line

为君一笑 提交于 2019-11-27 02:00:37
问题 I am writing a music display program and need to draw a 'slur' between two notes. A slur is a curved line linking two notes - just to be clear. I know the note positions and calculate where the start and end points of the curve should be - Start point A and End point B . I now need to obtain the offset C , given the distance required, for use within a quadratic curve. This is where my, very, limited knowledge and understanding of maths formulae comes in. I have indeed looked here in SO for my

Fast algorithm to find the x closest points to a given point on a plane

安稳与你 提交于 2019-11-27 01:40:47
问题 I would like to find a fast algorithm in order to find the x closest points to a given point on a plane. We are actually dealing with not too many points (between 1,000 and 100,000), but I need the x closest points for every of these points. (where x usually will be between 5 and 20.) I need to write it in C#. A bit more context about the use case: These points are coordinates on a map. (I know, this means we are not exactly talking about a plane, but I hope to avoid dealing with projection

How do I find all the Points in a Path in Android?

旧时模样 提交于 2019-11-27 01:27:09
问题 Awhile back I asked a question to see if I was able to find a pair of specific points in a path; however, this time I want to know if there is a way to know all points in a path? (I couldn't find a method that did so, which is unfortunate because Java provides a way to do this, just not Android?) The reason I ask this is because I have multiple geometric graphs and I want to compare the points to see where they intersect. I appreciate any helpful responses 回答1: If you have created a Path that

How to make UIImageView automatically resize to the size of the image loaded

天大地大妈咪最大 提交于 2019-11-27 01:08:24
问题 I have put an UIImageView control on my view with IB. The size of the control is just something I decided upon, pretty random size really What I want to do is the control to resize automatically whenever I set the image property to a new image. I want it to actually resize to the size of the image. Can it be done automatically ? without any code intervention ? If not - what will the best approach be in this case ? What happens today is strange. I load images into the ImageView and I see the

Hexagonal Grids, how do you find which hexagon a point is in?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 00:03:50
问题 I have a map made up of rows and columns of hexagons This isn't an actual image of the hex-map I am using, but uses the same size and shape hexagons I need to be able to tell which one the mouse is over when the user clicks, Each Hexagon is represented by an instance of a "Tile" class, however this doesn't hold any location specific data, or even a polygon, so basically the only way to tell where a particular hexagon is, is to know it's position in the 2D array. I have used a square grid

iterate through each point on a line/path in java

元气小坏坏 提交于 2019-11-26 23:24:57
问题 I'm new to using iterators and was wondering how one would iterate through each point on a line segment (Line2D.Double, to be precise) -- I need to check to see if each point on the line fulfills certain requirements. Also, given a path object (like GeneralPath), how would you do the same thing (iterate through each point on the outline of the shape)? Ideally I'd like something like this (with either a line or a path): Line2D line = new Line2D.Double(p1,p2); for (Point2D point : line) { point

opencv finding image cordinates on another image

女生的网名这么多〃 提交于 2019-11-26 23:09:43
问题 How to find image "A" coordinates on image "B" which contains image "A". I wrote this program which is only checking pixel values, does anyone know is there any library tool do this. 回答1: As Throwback1986 suggested, you will probably want to use matchTemplate. Here is one of my answers showing how to detect the Sun from virtual spacecraft. Here is the newer tutorial from OpenCV on using matchTemplate . Now, there are some caveats for using the matchTemplate approach. If image "A" can be at an

How to make the + operator work while adding two Points to each other?

牧云@^-^@ 提交于 2019-11-26 22:03:37
问题 Is there any way to get the + operator to work for the Point object? Take, for example, this tiny snippet: this.cm1.Show((MouseEventArgs)e.Location+this.i_rendered.Location); You see, I try to add two points to eachother. It just does not work (which was expected). I'd love to get this working. Any ideas? 回答1: It's not going to happen the way you expect. The only overload that the Point structure provides for the + (addition) operator is one that translates the coordinates of the Point by a