geometry

How to calculate distance from a point to a line segment, on a sphere?

I have a line segment (great circle part) on earth. The line segment is defined by the coordinates of its ends. Obviously, two points define two line segments, so assume I am interested in the shorter one. I am given a third point, and I am looking for the (shortest) distance between the line and the point. All the coordinates are gi...

Actionscript Angle of a Line Trig

How can I find the Angle of a line between two points in actionscript 3. I have an object that dynamically animates out arrows, given the points that represent start, elbows, and then end point. I need the angle of the line to rotate the arrow at the tip to accurately point with the current segment being drawn I can easily get the ang...

Algorithm for spread-out 2D point distribution

In a 2D pixel array, I need an efficient algorithm that will select p% of pixels that are the most spread out. This can be done adaptively by selecting points, then repeatedly adjusting the positions of points that are too close together. But this isn't efficient since it would require many iterations and distance calculations. It doe...

How does GraphicsPath.AddArc use the startAngle and sweepAngle parameters?

I am trying to use System.Drawing.Drawing2D.GraphicsPath.AddArc to draw an arc of an ellipse starting at 0 degrees and sweeping to 135 degrees. The issue I am running in to is that for an ellipse, the arc drawn does not match up with what I would expect. For example, the following code generates the image below. The green circles are w...

Identifying the corners of a polygon in 2d space

Given four (x,y) pairs that represent the four corners of an arbitrary polygon (quadrilateral) in 2d space, I'd like to identify: Whether the polygon is convex If it is convex, Which particular point represents the top left, top right, bottom left, and bottom right corner I'm doing this as part of an image processing program, so assu...

which data structure is appropriate to query "all points within distance d from point p"

hey there! i have a 3D pointcloud and i'd like to efficiently query all points within distance d from an arbitrary point p (which is not necessarily part of the stored pointcloud) the querry would look something like Pointcloud getAllPoints(Point p, float d); what accelerationstructure would be appropriate for this? A range-tree see...

How to compute a pair of closest points on two 3d circles?

I have two 2d circles in 3d space (defined by a center, normal, and radius) and I'm trying to come up with a pair of points that is one of the set of closest pairs of points. I know that there are anywhere from 1 to an infinite number of point pairs, I just need a single matching pair. Is there a simple way to do that? Precision is no...

How should I create an algorithm for the centroid of any System.Windows.Media.Geometry object?

I plan on having to split up the Geometry object into a series of simpler shapes, and combine their centroids using this formula: Mathematical details of this formula can be found in this Wikipedia article. NOTICE: Don't be suprised if my view of the mathematics is incorrect. I haven't done any complex math past trigonometry, and I'v...

What's a good algorithm for calculating the area of a quadrilateral?

I see there's a good question already for general polygons here. Are there any simpler or more efficient algorithms specific to quadrilaterals? ...

WPF 2d Graphics and 'group' transform in c#

Hi, I'm writing an application that creates a graphical 'dial', like a clock. Each element in the dial is created and then added to the dial in a clockwise fashion - imagine creating a single element with the hour 1 that includes the minute strokes, the number '1' and other embelishments, drawing it, then repeting for the hour 2, etc. ...

2D bounding box of a sector?

I've googled till I'm blue in the face, and unless I'm missing something really obvious, I can't find any algorithms for calculating the bounding box of a 2D sector. Given the centre point of the enclosing circle, the radius, and the angles of the extent of the sector, what's the best algorithm to calculate the axis-aligned bounding rec...

WPF drawing that stretches without stretching the Pen

I need to draw some simple lines within a Border control (or similar) that always stretch to the bounds of the Border. Is there a way to stretch the lines only but not its pen? Without involving lots of C#? In this version the lines stretch: <Border> <Border.Background> <DrawingBrush> <DrawingBrush.Drawing> ...

How do I stop rails from escaping values in SQL for a particular column?

I'm trying to manually manage some geometry (spatial) columns in a rails model. When updating the geometry column I do this in rails: self.geom="POINTFROMTEXT('POINT(#{lat},#{lng})')" Which is the value I want to be in the SQL updates and so be evaluated by the database. However by the time this has been through the active record mag...

Calculating area enclosed by arbitrary polygon on Earth's surface

Say I have an arbitrary set of latitude and longitude pairs representing points on some simple, closed curve. In Cartesian space I could easily calculate the area enclosed by such a curve using Green's Theorem. What is the analogous approach to calculating the area on the surface of a sphere? I guess what I am after is (even some appr...

Rasterizing a 2D polygon

I need to create a binary bitmap from a closed 2D polygon represented as a list of points. Could you please point me to efficient and sufficiently simple algorithms to do that, or, even better, some C++ code? Thanks a lot! PS: I would like to avoid adding a dependency to my project. However if you suggest an open-source library, I can ...

about LIDAR .las files...

hi, i have .las (lidar data) file, now i wanted to know the size of it, for example how long it's width and height in kilometers... how is it possible to retrieve these kind of info? thanks a lot!!! ...

Find a tangent point on circle?

Given a line with first end point P(x1,y1) another end point is unknown, intersect with a circle that located at origin with radius R at only one point(tangent) T(x2,y2). Anyone know how to get the point T? Thanks in advance! ...

Fast algorithm for calculating union of 'local convex hulls'

I have a set of 2D points from which I want to generate a polygon (or collection of polygons) outlining the 'shape' of those points, using the following concept: For each point in the set, calculate the convex hull of all points within radius R of that point. After doing this for each point, take the union of these convex hulls to produ...

tools for viewing TIN files...

hi, is there any free open source tools available for viewing TIN (triangular irregular networks) files( which i got from LAS (Lidar data) file...)? thanks! ...

two sets of 3d points

Hi everybody, I´ve got a question concerning two sets of points in a 3d space. I defined a volume by 40 coordinates in one cartesian coordinate system, in another coordinate system with different (0,0,0) i have s slightly different volume also defined by 40 coordinates. I know the matching pairs of the point sets and I want to measure t...