COMPGROUPS.NET | Post | Groups | Users | Stream | Browse | About | |

### Shortest distance from a point to a sampled surface?

• Email
• Follow

```I have a 2-D matrix of sampled values on a regular, uniform grid of x and y.
The data can be analogied to being vertical height at every point.

I then have an arbitrary point (a,b,c) and I want to know the shortest
distance from that point to the sampled surface.  The x and y coordinates of
the point (a,b,c) will coincide with those on the sampled grid (so it's not
completely arbitrary).

I know I can find the distance to every point on the surface and find a
minimum, but that doesn't acount for when the shortest distance is to a face
or edge of the surface rather than a point.  And if possible I'd like to
find the shortest distance to a smoothly interpolated (cubic spline or
similar) of the surface.

Are there any fast algorithms for doing this?  I'm working in MATLAB mostly
if that helps.

It needs to be as fast as possible because in practice I have an entire
surface of points (a,b,c) and i need to find the shortest disatance for each
one.  i.e. I have two surfaces and at a whole bunch of points x,y I need to
find the shortest distance between the two planes.

The planes will be about 200x300 in size mostly.

Any help muchly appreciated.

--
Ian Cowley
Bishop's Stortford/Cambridge, UK

www.iancowley.co.uk/contact

```
 0
Reply me3 (245) 7/26/2005 11:23:54 AM

See related articles to this posting

```In article <dc56dq\$gtl\$1@gemini.csx.cam.ac.uk>,
"Ian Cowley" <me3@privacy.net> writes:
|>
|> I have a 2-D matrix of sampled values on a regular, uniform grid of x and y.
|> The data can be analogied to being vertical height at every point.
|>
|> I then have an arbitrary point (a,b,c) and I want to know the shortest
|> distance from that point to the sampled surface.  The x and y coordinates of
|> the point (a,b,c) will coincide with those on the sampled grid (so it's not
|> completely arbitrary).
|>
|> I know I can find the distance to every point on the surface and find a
|> minimum, but that doesn't acount for when the shortest distance is to a face
|> or edge of the surface rather than a point.  And if possible I'd like to
|> find the shortest distance to a smoothly interpolated (cubic spline or
|> similar) of the surface.
|>
|> Are there any fast algorithms for doing this?  I'm working in MATLAB mostly
|> if that helps.

No.  You need to specify the problem more precisely before it is

1) You need to specify the interpolation, because the properties
will affect the search very considerably.  There are several
variants of cubic splines, and most of those will produce a
surface that can extend beyond the extrema of your points.

2) If you have a single point per surface, you will clearly not
do better than a fairly simple search, as the cost of setting up
a data structure will be more than it's worth.  If you have many
of them, the problem is different.

For a single point, start at the closest point on the grid plane
to the point and work outwards, maintaining the closest distance
so far.  When you have reached that distance away on the plane,
you can stop, as no subsequent point can be closer.

Even then, you may be able to optimise that if you can make
assumptions about the properties of the surface.

Regards,
Nick Maclaren.
```
 0
Reply nmm1 (190) 7/26/2005 11:44:52 AM

```In message dc57nk\$ju3\$1@gemini.csx.cam.ac.uk, Nick Maclaren burbled:
> In article <dc56dq\$gtl\$1@gemini.csx.cam.ac.uk>,
> "Ian Cowley" <me3@privacy.net> writes:
>>>
>>> I have a 2-D matrix of sampled values on a regular, uniform grid of
>>> x and y. The data can be analogied to being vertical height at
>>> every point.
>>>
>>> I then have an arbitrary point (a,b,c) and I want to know the
>>> shortest distance from that point to the sampled surface.  The x
>>> and y coordinates of the point (a,b,c) will coincide with those on
>>> the sampled grid (so it's not completely arbitrary).
>
> No.  You need to specify the problem more precisely before it is
> answerable.  There are two aspects:
>
> 1) You need to specify the interpolation, because the properties
> will affect the search very considerably.  There are several
> variants of cubic splines, and most of those will produce a
> surface that can extend beyond the extrema of your points.

OK, we'll ignore interpolation for now, I should get good enough answers
without.
Assuming then that I can take each square (in the x,y plane) and divide it
into two triangles, I'm looking for an algorithm that'll give me the
shortest distance from an arbitrary point in to a triangle in 3D.  I've
found algorithms for distance from a point to an infinite planes, but I
can't find out the more specific point-to-triangle.

So, can anyone point me in the direction of a point-to-triangle distance
algorithm?

--
Ian Cowley
Bishop's Stortford/Cambridge, UK

www.iancowley.co.uk/contact

```
 0
Reply me3 (245) 7/26/2005 12:46:21 PM

```In article <dc5b8d\$rm5\$1@gemini.csx.cam.ac.uk>,
"Ian Cowley" <me3@privacy.net> writes:
|>
|> OK, we'll ignore interpolation for now, I should get good enough answers
|> without.
|> Assuming then that I can take each square (in the x,y plane) and divide it
|> into two triangles, I'm looking for an algorithm that'll give me the
|> shortest distance from an arbitrary point in to a triangle in 3D.  I've
|> found algorithms for distance from a point to an infinite planes, but I
|> can't find out the more specific point-to-triangle.

That's linear interpolation :-)

|> So, can anyone point me in the direction of a point-to-triangle distance
|> algorithm?

You work out the nearest point on the plane, check if it is within
the triangle, and use it if so.  If not, you find where the point
is relative to the sides and do the similar task for the nearest
side.  If the nearest point on that side is within the side, use
it if so.  If not, use the distance to the nearest point.

It isn't hard, can be optimised tolerably well by ensuring that
your calculations deliver information in a form that can be used
for both the distance and the selection, but is messy and it is
a hell of a long time since I did it.  Sorry I can't help more.

Regards,
Nick Maclaren.
```
 0
Reply nmm1 (190) 7/26/2005 12:54:06 PM

```Ian Cowley wrote:
> In message dc57nk\$ju3\$1@gemini.csx.cam.ac.uk, Nick Maclaren burbled:
> > In article <dc56dq\$gtl\$1@gemini.csx.cam.ac.uk>,
> > "Ian Cowley" <me3@privacy.net> writes:
> >>>
> >>> I have a 2-D matrix of sampled values on a regular, uniform grid of
> >>> x and y. The data can be analogied to being vertical height at
> >>> every point.
> >>>
> >>> I then have an arbitrary point (a,b,c) and I want to know the
> >>> shortest distance from that point to the sampled surface.  The x
> >>> and y coordinates of the point (a,b,c) will coincide with those on
> >>> the sampled grid (so it's not completely arbitrary).
> >
> > No.  You need to specify the problem more precisely before it is
> > answerable.  There are two aspects:
> >
> > 1) You need to specify the interpolation, because the properties
> > will affect the search very considerably.  There are several
> > variants of cubic splines, and most of those will produce a
> > surface that can extend beyond the extrema of your points.
>
> OK, we'll ignore interpolation for now, I should get good enough answers
> without.
> Assuming then that I can take each square (in the x,y plane) and divide it
> into two triangles, I'm looking for an algorithm that'll give me the
> shortest distance from an arbitrary point in to a triangle in 3D.  I've
> found algorithms for distance from a point to an infinite planes, but I
> can't find out the more specific point-to-triangle.
>
> So, can anyone point me in the direction of a point-to-triangle distance
> algorithm?

A (non-degenerate) triangle determines a plane, so you can find the
distance from your point to that plane. Then find the projection of
your point onto that plane. If that projection is in the triangle, you
are done. Otherwse, find the shortest distance to the perimeter of the
triangle by any method you like (I suggest parametrizing the sides, and
finding the minimum of each edge. This is a simple problem)

```
 0
Reply qurqirishd (16) 7/26/2005 1:14:30 PM

```In article <dc5b8d\$rm5\$1@gemini.csx.cam.ac.uk>,
"Ian Cowley" <me3@privacy.net> wrote:

> In message dc57nk\$ju3\$1@gemini.csx.cam.ac.uk, Nick Maclaren burbled:
> > In article <dc56dq\$gtl\$1@gemini.csx.cam.ac.uk>,
> > "Ian Cowley" <me3@privacy.net> writes:
> >>>
> >>> I have a 2-D matrix of sampled values on a regular, uniform grid of
> >>> x and y. The data can be analogied to being vertical height at
> >>> every point.
> >>>
> >>> I then have an arbitrary point (a,b,c) and I want to know the
> >>> shortest distance from that point to the sampled surface.  The x
> >>> and y coordinates of the point (a,b,c) will coincide with those on
> >>> the sampled grid (so it's not completely arbitrary).
> >
> > No.  You need to specify the problem more precisely before it is
> > answerable.  There are two aspects:
> >
> > 1) You need to specify the interpolation, because the properties
> > will affect the search very considerably.  There are several
> > variants of cubic splines, and most of those will produce a
> > surface that can extend beyond the extrema of your points.
>
> OK, we'll ignore interpolation for now, I should get good enough answers
> without.
> Assuming then that I can take each square (in the x,y plane) and divide it
> into two triangles, I'm looking for an algorithm that'll give me the
> shortest distance from an arbitrary point in to a triangle in 3D.  I've
> found algorithms for distance from a point to an infinite planes, but I
> can't find out the more specific point-to-triangle.
>
> So, can anyone point me in the direction of a point-to-triangle distance
> algorithm?

I can tell you what I used.

Given a point x0, and a triangulation in a 3d space:

0. Compute the "in-plane" circumspheres for each triangle.
You would only do this once for many points, so its not
that bad, and its fast anyway. A circumsphere is the sphere
that contains each point on its circumference. In this case,
it will have the additional feature that the centrer of the
sphere must lie in the plane of the triangle. It can be
done by solving a linear system of equations.

I. Find the closest vertex on the triangulation to x0.
Compute that distance.

2. Find the distances from x0 to each circumcenter. Use
these distances with the radii of the corresponding spheres
to compare to the closest point we found so far. This
allows you to eliminate most of the triangles. (Note that
all points on a triangle must lie inside its circumsphere.)

3. For those few triangles which remain, use algorithm
LDP to find the closest point to x0.

What is LDP? Its from a book by Lawson & Hanson, "Solving
Least Squares Problems". LDP finds the closest point to
the origin of the set of points which satisfies a set of
convex inequalities. (LDP stands for Least Distance
Programming.) You can describe a triangle as such a set.
One inequality is defined by the normal to the plane of
the triangle, the rest by the 3 sides of the triangle.

Lawson and Hanson also show how to convert the LDP problem
into a non-negative least squares problem, as is solved
in matlab by lsqnonneg (nnls for older versions of matlab.)

HTH,
John D'Errico

--
The best material model of a cat is another, or
preferably the same, cat.
A. Rosenblueth, Philosophy of Science, 1945
```
 0
Reply woodchips (7941) 7/26/2005 3:42:53 PM

```In article <dc56dq\$gtl\$1@gemini.csx.cam.ac.uk>,
Ian Cowley <me3@privacy.net> wrote:

>I have a 2-D matrix of sampled values on a regular, uniform grid of x and y.
>The data can be analogied to being vertical height at every point.
>
>I then have an arbitrary point (a,b,c) and I want to know the shortest
>distance from that point to the sampled surface.

x y z=f(x,y)
------------
0 0   0
0 1   1
1 0   1
1 1   0

then you can put a polyhedral surface to these data which looks like a
valley between  (0,0) and (1,1), with two hills on the sides, or which
looks like a mountain ridge between (0,1) and (1,0), with two valleys
off to the sides.

Lesson learned: that the sampling data do not specify a unique surface
in the same way that a 1-D array of sampled values specifies a unique
piecewise-linear curve. This can, obviously, affect decisions about
where on "the surface" is the nearest point to any given  (x,y,z) in R^3.

dave
```
 0
Reply rusin (29) 7/26/2005 8:20:41 PM

```In article <dc5bpe\$sre\$1@gemini.csx.cam.ac.uk>, nmm1@cus.cam.ac.uk
says...
> |> So, can anyone point me in the direction of a point-to-triangle distance
> |> algorithm?
>
> You work out the nearest point on the plane, check if it is within
> the triangle, and use it if so.  If not, you find where the point
> is relative to the sides and do the similar task for the nearest
> side.  If the nearest point on that side is within the side, use
> it if so.  If not, use the distance to the nearest point.

That'll work, but it's not very efficient.  The most efficient
method considers the Voronoi feature regions defined by the
triangle: 3 vertex regions, 3 edge regions, and 1 triangle
interior.  You classify the query point to the first 6
regions, and if it is found residing in one of them, you
project the query point onto the feature (the vertex or
edge).  The projection is the closest point on the triangle
to the query point (which trivially gives the distance).
If the query point is not in one of the first 6 regions,
the projection onto the triangle plane is the nearest point.

If Q is the query point and ABC is the triangle, you can test
if Q is in the Voronoi region of, say, A by testing if
Dot(Q - A, B - A) < 0 and Dot(Q - A, C - A) < 0.  The
other regions are tested in a similarly simple fashion.
You can find all the tests in my SIGGRAPH'04 slides on
GJK as available here:

http://realtimecollisiondetection.net/pubs/

The math for the edge Voronoi regions can be simplified
using the Lagrange identity so that the 6 dot products
for testing the vertex Voronoi regions are being reused.

It doesn't get faster than that.

--
Christer Ericson
http://realtimecollisiondetection.net/
```
 0
Reply christer_ericson (167) 7/27/2005 5:56:18 AM

```In article <MPG.1d50c1dce7942e10989822@news.verizon.net>,
Christer Ericson  <christer_ericson@NOTplayTHISstationBIT.sony.com> wrote:
>In article <dc5bpe\$sre\$1@gemini.csx.cam.ac.uk>, nmm1@cus.cam.ac.uk
>says...
>> |> So, can anyone point me in the direction of a point-to-triangle distance
>> |> algorithm?
>>
>> You work out the nearest point on the plane, check if it is within
>> the triangle, and use it if so.  If not, you find where the point
>> is relative to the sides and do the similar task for the nearest
>> side.  If the nearest point on that side is within the side, use
>> it if so.  If not, use the distance to the nearest point.
>
>That'll work, but it's not very efficient.  The most efficient
>method considers the Voronoi feature regions defined by the
>triangle: 3 vertex regions, 3 edge regions, and 1 triangle
>interior.  You classify the query point to the first 6
>regions, and if it is found residing in one of them, you
>project the query point onto the feature (the vertex or
>edge).  The projection is the closest point on the triangle
>to the query point (which trivially gives the distance).
>If the query point is not in one of the first 6 regions,
>the projection onto the triangle plane is the nearest point.

I was simplifying.  If you optimise the operation I suggested, you
end up with doing approximately the same calculation in a slightly
different order.  My experience is that all ways of doing this are
a pain, because a lot of the performance comes from not recalculating
things - and adding data structures to manage that costs too much.

>The math for the edge Voronoi regions can be simplified
>using the Lagrange identity so that the 6 dot products
>for testing the vertex Voronoi regions are being reused.
>
>It doesn't get faster than that.

Only by a small constant factor, which depends on the detail of the
coding and not the mathematics.

Regards,
Nick Maclaren.
```
 0
Reply nmm1 (190) 7/27/2005 9:22:18 AM
 comp.soft-sys.matlab 203745 articles. 537 followers.

8 Replies
201 Views

Similar Articles

[PageSpeed] 37

• Email
• Follow

Similar Artilces:

Shortest distance from point to ellipsoid surface
I have a ellipsoid "defined" at a point E. I have its shape information stored: elpsd_props{i,1}(:,:) = [centroid xyz coords; unit semi-axis vector a; unit semi-axis vector b; unit semi-axis vector c; semi-axis lengths a,b,c] I have a matrix called astrd_int which holds a massive grid 3-D points. All of these points lie outside of the ellipsoid. I call these interior points (we're inside another shape). I wish to find the minimum distance from...

how to calculate shortest distance between two point on a surface
Could anyone suggest me methods on how to calculate shortest distance between two point along a surface. The surface is not standard one like sphere. Thanks. In article <34590a0b-3ceb-456d-93ae-522b32dec017@c3g2000yqd.googlegroups.com>, Arkward <sunjigang1965@yahoo.com.cn> wrote: >Could anyone suggest me methods on how to calculate shortest distance >between two point along a surface. The surface is not standard one >like sphere. >Thanks. Why do you want to know? I use to have students construct geodesics numerically via matlab, but calculus of variatio...

3D surface: get distance to points on the surface
Hallo, I want to calculated the distance from one point to a point on a 3D surface. If one creates a cylinder using the following command t = 0:pi/10:2*pi; [X,Y,Z] = cylinder(2+cos(t)); surf(X,Y,Z); you get a nice surface made with polygons only in the plot. I want to have the quite simple surface in memory so that I can access it. It is possible to describe surfaced using some kind of polygon...? I have already tried to calculate hundreds of point of the cylinder. But it takes a lot of time, you only get some points of the whole surface and plotting each of this hundreds point tak...

Clock Estimation, OIffset from Sampled point to Ideal Sample point??
Hi, I have a method of working out the phase difference of when I am sampling the IQ data stream, to the ideal position (peak of the data) (802.11b data (11Mhz), IQ sampled at 44Mhz, giving 4 samples per symbol) Although I don't fully understand how it works. Could somebody here put some light on to the subject? Here is the method: Take sampled IQ (44MHz, 4 samples per symbol) Bandpass through 5.5MHz filter Square IQ signal (spectral line @ 11Mhz) Multiply I with COS(11MHz); 0,1,0,-1 sequence 44MSPS on 11MHz cosine wave Multiply Q with -SIN(11Mhz); 1,0,-1,0 sequence 44MSPS on 11MHz si...

Shortest Distance between a point and a curve ?
I am looking for the current function that can estimate the shortest distance between a point and a curve. The hard partial of my question is that the curve is fitted from some discrete point and the fitness function is changing by some conditions. The footless resolution is to using the approach of minimum value from point to curve. However, the the length of curve is too large and the number of point is also very big, the calculation effect is very poor. Anyone knows some smart algorithms of the shortest distance estimation for the shortest distance between a point and a obtained cu...

minimum distance from a point to a surface
Hey, I need to compute the minimum distance between a point and a surface. I have created the 3d surface using convhulln so i know the vertices of every point and i am able to get the minimum distance to a single point on my surface using the dsearchn function. But what i would like to get is the minimum distance to the surface created, not the minimum distance to the points used to create the surface. I hope my wording of my problem hasn't confused you guys to much and thank you in advance On 1=D4=C229=C8=D5, =C9=CF=CE=E77=CA=B133=B7=D6, "Robert Kirdeikis" <kirde.= ...@ualbe...

Shortest Distance between a point and a function ?
This question is not linked with a concrete problem I�m working on. It�s only something that I�m interested in. How is it possible to calculate the shortest distance (In 2 dimensions it�s square root(dx^2+dy^2)) between a point and a function ? For example: f=sin(x) and p=(x1,y1). Say p=(pi/3,pi/2). Is it possible to calculate this without the optimization toolbox ? Hans-Werner Marschke wrote: > > > This question is not linked with a concrete problem I�m working on. > It�s only something that I�m interested in. > How is it possible to calculate the shortest distance (In 2 > ...

Distance between two points on the surface of a ellipsoid
Dear all, I want to calculate the ' great circle distance' between two points on the surface of an ellipsoid. Though because of the extra radius, the great circle distance is not what I am looking for. Also I have not a center of the ellipsoid on [0,0,0], which makes the calculation more difficult, besides this I only have the cartesian coordinates of the two points and the center. This is what I have now, anyone knows how to calculate this distance? % construct of center ellipsoid a= rand(1,3)*10 cx=a(1) cy=a(2) cz=a(3) % construct the three different radii b= rand(...

Max distance from point on ellipsoid to surface
I want to find a point on an given ellipsoid that is the farthest from a given surface. (The distance between a point on ellipsoid and the surface should be max). So how can I do this? I was thinking about some kind of Lagrange multipliers. But what do you think? Thanks. "stefaneli" wrote in message <jpgh3q\$c1\$1@newscl01ah.mathworks.com>... > I want to find a point on an given ellipsoid that is the farthest from a given surface. (The distance between a point on ellipsoid and the surface should be max). So how can I do this? I was thinking about some kind of Lagrange multip...

Distances from a point to a set of points
Hello there, I would need some help with the following matter: I have an array with a set of coordinates (3D) and another 3D vector defining the coordinates of a single point. Is there a function in matlab that calculates the distances from that single point to each of the others? Cheers, dani Dani Barrera-Medrano wrote: > > <snip, distance between points in N-dim space... If your points are p1 and p2, then: norm(p1-p2) Will give you the distance. ...

shortest distance between point and connected comp. label
I have a binary image with one connected component label. I have one point p1 outside this label. I need to find the point p2 inside the connected component label which gives the shortest distance between p1 and p2. label. What is the quickest way to do this? On Aug 21, 10:22=A0am, "Ahmad" <ahmad.hu...@gmail.com> wrote: > I have a binary image with one connected component label. I have one poin= t p1 outside this label. I need to find the point p2 inside the connected c= omponent label which gives the shortest distance between p1 and p2. label. = What is the quickest way to...

Shortest distance between two lines going through a point
Is there an easy formula for this ? For example, assume you have two points on each lines and the point the distance must go through. On Jul 11, 4:05 am, raphfrk <raph...@netscape.net> wrote: > Is there an easy formula for this ? > > For example, assume you have two points on each lines and the point > the distance must go through. To clarify, you have two lines, say L1 and L2, and a point P. You want to find the length of the shortest line segment that passes through P and has one endpoint on L1 and the other endpoint on L2. Is that correct? Is this in 2-D or 3-D? Dave ...

shortest distance between a point and vector (n dimension)
I have a direction vector (d) created from two vectors : d=x-g I have to find the perpendicular distance from a point to line d. All of above are in n dimensions. Please help me with this problem how can calculate this distance in Matlab?? "Kevin " <k.amouzgar@gmail.com> wrote in message <jdav08\$ru6\$1@newscl01ah.mathworks.com>... > I have a direction vector (d) created from two vectors : d=x-g > I have to find the perpendicular distance from a point to line d. > All of above are in n dimensions. > Please help me with this problem how can calculate this di...

Distance Between a B-Spline Surface & Point
Hi: My objective: Find the Distance Between a B-Spline Surface and a Point, {2,3,4}. (Note: The point {2,3,4}, is not on the B-spline surface.) Below is the Mathematica 8.0.4. code I used to try and find the closest point on the B-spline surface to the point {2,3,4}: cpts={{{1,1,-0.574058},{1,2,0.390267},{1,3,0.616214},{1,4,-0.115722},{1,5,0.436663}},{{2,1,0.809682},{2,2,-0.741927},{2,3,-0.865916},{2,4,-0.0998629},{2,5,-0.241853}},{{3,1,-0.196909},{3,2,0.796108},{3,3,-0.0602901},{3,4,0.486659},{3,5,-0.0134192}},{{4,1,0.657334},{4,2,-0.917066},{4,3,0.98301},{4,4,-0.875938},{4,5,-...

Samples, samples, samples...
What's your favourite (and characteristic) set of samples from old Amiga games? I have some canditates: Chaos Engine: "Food!", "Chaos activated" Alien Breed: "Player one requires first aid / ammo / keys", "Welcome to Intex system", "Destruction is imminent" Mega-lo-mania: "We nuked them!" ;), "You've got it bastard", "No way!", "We control the sector" and "We won" of course. Dune 2: "Enemy unit destroyed / is approaching" along with immortal "Yes sir!" and...

Constructing and displaying a 3D surface given a sampling of points on it.
Hello, I have with me a dense sampling of points on the (3D) surface of face. Given that, I am looking out for a program which will reconstruct the entire surface and shade it under various lighting conditions. I have two different models - one with 8000 points and one with 80,000 points. I have tried various softwares such as VTK (it has a surface reconstruction class) for this purpose but I havent got satisfactory results. I get weird artifacts several times. Could anyone suggest me some good package capable of doing this task? I need an absolutely accurate and very clear displa...

Code to compute minimal geodesic distance between points on a 3D surface
Hello, Could someone give me pointers to existing code for calculating the minimal geodesic distance between two arbitrary points on a 3D surface, given "N" points lying on the surface. Thanks, ==ajit (P.S.: Remove the shakespearean name to reply ) "ajit" <ajit_v_rROMEO@yahoo.co.uk> wrote in message news:79cfabc6.0401091316.22ce26f8@posting.google.com... > Could someone give me pointers to existing code for calculating the > minimal geodesic distance between two arbitrary points on a 3D > surface, given "N" points lying on the surface. Geodes...

how to determine if the shortest distance from one point to a line is inside the line segment or outside
Hello everyone, We know how to determine the shortest distance from a point to a line. http://www.mathworks.com/support/solutions/en/data/1-1BYSR/index.html?product=ML&solution=1-1BYSR However, can someone point me of a way of how to determine if such minimum distance fall within the line segment or it is determine it with respect to its projection. for example for the line line=[-15 -30 -50 75 -70 95] point=[0 0] for the first segment of the line the shortest distance (perpendicular distance) falls within the line segment but for the second segment the shortest distan...

point intersection (distance of a point to a line)
I have a problem to solve, could someone help me out. I have a point P (x1,y1) and a line L represented by two endpoints (x2, y2) (x3, y3) How do I find the distance from P to L I have a solution is that: 1. Find the function of L 2. Find the normal of L 3. Then create a function through (x1, y1) 4. Then solve the two equations to find the intersection. we cannot use syms, and solve function Thanks On Mar 21, 6:37=A0pm, phamtrungth...@gmail.com wrote: > I have a problem to solve, could someone help me out. > > I have a point P (x1,y1) > and a line L re...

Problem when exporting surface plot with points on surface
I have a problem when I export surface plots. What I have done in the fiugres is first to plot a 3D surface, used: surface(X,Y,Z) .. I have found maxima in the surface and indicated them with: plot3(X(i,j),Y(i,j),Z(i,j),'*b') That is, I have stars on the surface but they seem to dissapear when I export the figures to jpg,eps... well all formats. I have also tried to make an offset on the points so they are above the surface but no help there. The strange thing is that some of the points will be visible in the exported figure but not always. Very confusing to me and I have struggled ...

Point on sphere greatest distance from given points
How can I use Mathematica to solve this problem: Given n points on a sphere, I want to find a point x such that: Sum[distance[x,i],{i,1,n}] is maximal, where "distance" is spherical ("great circle") distance. In other words, I want to find the point x "furthest" from the given n points. Is there any chance x will coincide with one of the given points? If so, is there a better notion of distance to use? -- We're just a Bunch Of Regular Guys, a collective group that's trying to understand and assimilate technology. We feel that resistan...

Calculate distance between many points and one certain point
I have a large matrix, I want to calculate the distance of each point of the matrix from one certain point which is also in the matrix. if I used a loop, for i= 1:m for j= 1:n dist(i,j) = sqrt((i-x0)^2 + (j-y0)^2)); end end Is there any fast way to do this, because the matrix I am processing is large. Thanks a lot. "JohnMC " <nirmathink@gmail.com> wrote in message <i4hbuo\$fd2\$1@fred.mathworks.com>... > I have a large matrix, I want to calculate the distance of each point of the matrix from one certain point which is also in the matrix. >...

Surface fitting to point cloud -> 3D surface
I have set of data points obtained by sensor scanning the surface of a 3D object. I would like to reconstruct the surface based on the point cloud that I have now. Any advices on approach will help a lot. (I read the MATLAB help and found that griddata3 and related functions can fit surface. But I am not able to implement them !) please help out. Prasan In article <ef06ba6.-1@webx.raydaftYaTP>, Prasan <prasang@yahoo.com> wrote: > I have set of data points obtained by sensor scanning the surface of > a 3D object. I would like to reconstruct the surface based on the > p...

generate random points from a given point and given distance
Hi, How can i generate a random point from a given point (x,y) and in a distance of R? thanks On 6/20/2013 3:11 AM, sh wrote: > Hi, > How can i generate a random point from a given point (x,y) and in a distance of R? > thanks > may be: random points inside circle of radius R, centered at (x,y): ---------------------- x =.5; y =.6; R =2; theta = 2*pi*rand(1); randx = x+R*cos(theta); randy = y+R*sin(theta); ------------------------- --Nasser thanks Nasser, but i want to generate these points on the perimeter of the circle. i.e. points that are exact...