# Re: [Fwd: Direct manipulation along a line]

```Hi Bill-

Thanks for the suggestion.

Bill Hibbard wrote:

```
```Strange your original message never appeared on the list.

What you generally need is a way to find the closest point
on a 1-D manifold to a ray (the ray defined by the cursor).
There are two similar things in the system:

1. DataRenderer.findRayManifoldIntersection() uses Newton's
method to find the intersection of a ray with a 2-D
manifold.
2. DataRenderer.java, lines 2140-2155 finds the closest
point on a 1-D line (a straight 1-D manifold) to a ray.

If I were you, I'd start with a simple approach and add
complexity only as needed. So I'd start with a manipulable
point initialized somewhere on your 1-D manifold, linked
to your Display via a DirectManipulationRendererJ3D. As
the user drags this point, it will move in a plane parallel
to the screen but not be constrained to move along your
1-D manifold. In fact, such constraint is impossible given
that in general the ray defined by the user's cursor location
will not intersect the 1-D manifold. So render the manipulable
point as just a single dim point. But also display a more
prominent point that moves along the 1-D manifold, at the
sample along the manifold that your CellImpl (triggered by
changes in the manipulable point) calculates to be the
nearest point on the 1-D maniold to the manipulable point.
```
```
This is a good suggestion.  The only downside would be having
the manipulable point visible.  It might be better to have
some display listener listen for clicks and do the screen
transforms below.

```
```Given the visual feedback to the user of the prominent point
moving along the 1-D manifold, this may be good enough. If
it isn't, the next iteration would be for the CellImpl to
compute the closest point on the 1-D manifold to the ray
defined by the manipulable point. You might get this ray
by converting from the Data coords of the manipulable point
to (XAxis, YAxis, ZAxis) via the ScalarMaps, then pass this
to MouseBehaviorJ3D.cursorRay() to get the ray. But only do
this ray business if the firts approach isn't good enough.

Given the general utility of this answer, I will take the
liberty of CC'ing to the list.
```
```
In either case, the suggestion of having the indicator on the
line not be the manipulable one is the way to go.  I'll just
move it with either another manipulable point or a display
listener.  We already have the latter on the IDV map display,
so it might just be a matter of connecting to that.

Thanks again.

Don
*************************************************************
Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307
http://www.unidata.ucar.edu/staff/donm
"Time makes everyone interesting, even YOU!"
*************************************************************

```