calculate a point between two other points

calculate a point between two other points

Anonymous
Not applicable
387 Views
62 Replies
Message 1 of 63

calculate a point between two other points

Anonymous
Not applicable
Hello group,

Using LISP, how would one calc a point (p3), between two other points (p1
and p2), a given distance (dist) from p1?
Example:

p1 = (2.0 2.5 0.0)
p2 = (6.5 2.2 1.0)
dist = 1.5
p3 = ?

I'm sure there is a simple formula, however, I failed 3rd grade math five
times.
--
Eric S. eschneider@jensenprecast.com
0 Likes
388 Views
62 Replies
Replies (62)
Message 21 of 63

Anonymous
Not applicable
Doesn't work.

Your function must return a differing 'Z', not one of the 'Z' coord. from
one of the points but a calculated 'Z' of the slope between the (2)two
points.

--
rudy@cadentity.com
Practical Utilities for Productive Solutions

Jadranko Stjepanovic wrote in message
news:4C00F38CB8AAD0006AE264306820AD56@in.WebX.SaUCah8kaAW...
> This one is faster (45%, roughly measured):
>
> (defun point-along-line (p1 p2 dist / sc)
> (setq sc (/ dist (distance p1 p2)))
> (mapcar '(lambda (p1 p2) (+ p1 (* sc (- p2 p1)))) p1 p2)
> )
>
> This one is slightly slower than the previous one, but wont fail with
> "divide by zero error" if p1 equals p2:
>
> (defun point-along-line (p1 p2 dist / d sc)
> (if (zerop (setq d (distance p1 p2)))
> p1
> (progn
> (setq sc (/ dist d))
> (mapcar '(lambda (p1 p2) (+ p1 (* sc (- p2 p1)))) p1 p2)
> )
> )
> )
>
> This one is short and funny:
>
> (c:cal "pld(p1,p2,d)")
>
> Jadranko
>
> Tony Tanzillo wrote in message <39A44FAA.16A37871@worldnet.att.net>...
> >What Frank posted doesn't work in the 3D case, as
> >original example requires.
> >
> >;; (point-on-line )
> >;;
> >;; Returns a point on the line -
> >;; a specified distance from
> >
> >(defun point-on-line (p1 p2 dist / sc)
> > (setq sc (/ dist (distance p1 p2)))
> > (mapcar '+ p1
> > (mapcar '*
> > (mapcar '- p2 p1)
> > (list sc sc sc)
> > )
> > )
> >)
> >
>
0 Likes
Message 22 of 63

Anonymous
Not applicable
That's odd. It worked perfectly in my tests.

--
Attitudes are contagious. Is yours worth catching?
http://www.acadx.com

"Cadentity.Com" wrote in message
news:A7332421BBE2A91D8C0E9D8B44E98757@in.WebX.SaUCah8kaAW...
> Here's a repeat of my reply, since my message disappeared.
>
> I don't use running object snaps, that a bad habit.
>
> Your function still doesn't return the right point.
0 Likes
Message 23 of 63

Anonymous
Not applicable
> 1) How would you calculate the 2D distance
> from the supplied 3D distance?

My original reply will do just that (as Tony so astutely pointed out).

--
Attitudes are contagious. Is yours worth catching?
http://www.acadx.com

"Ian Bryant" wrote in message
news:65D95F46AF541E7BA4537DEF40BC2753@in.WebX.SaUCah8kaAW...
> Frank,
> 1) How would you calculate the 2D distance
> from the supplied 3D distance?
> 2) If either or both of the point arguments are 2D
> Tony's solution returns a 2D point calculated
> using X,Y values only. This is consistent with
> Autocad's treatment of mixed points.
> (e.g. refer the AutoLisp distance function).
> If you want a different result, (there are lots of
> different possibilities), you will have
> to program for it either by altering the
> input points or massaging the output.
> Regards Ian
0 Likes
Message 24 of 63

Anonymous
Not applicable
I should point out the obvious lack of knowlege behind this statement. Not
only should the (angle) function be excluded but it must be excluded since
it projects the angle between 3D points onto the current construction plane.
This is why (polar p1 (angle p1 p2) d) while fine for 2D points, does not
return the correct coord for 3D points.

What I should have asked for was to exclude the (distance) function. I find
that it helps to retard the atrophy of brain cells to "manually" do the math
that we normally rely on functions to do for us plus I learn things (like
the caveat of the angle function with 3D points).

So I offer the following for comments, processing speed analysis,
whatever...

(defun point-on-line (p1 p2 d1 / d2 sc)
(setq
d2 (sqrt (apply '+ (mapcar '(lambda (a b) (expt (- a b) 2.0)) p1 p2)))
sc (/ d1 d2)
)
(mapcar '(lambda (a b) (+ a (* sc (- b a)))) p1 p2)
)

Credit to my son for the formula to calculate the distance between two
points [there may be other and better ways to lispify it] and the
(mapcar...) is from Mr. Stjepanovics contribution.

Thank you for the clinic and happy trails, all.

Cliffo

Cliff Middleton wrote in message
news:262A663F02360D27C76A0A5BC0F12EEA@in.WebX.SaUCah8kaAW...
| I suppose we should exclude the (angle) function from the challenge as
well.
|
| Cliff Middleton wrote in message
| news:CC9E64BF786FB517CB8A226714A62D90@in.WebX.SaUCah8kaAW...
| | So without using the (polar) function, what is the formula for Eric's
| | objective? (he said as his gauntlet cascaded to the floor...)
| |
| | Cliff
| |
| | R. Robert Bell wrote in message
| | news:1D358B650846B6463EEED3017A46CF93@in.WebX.SaUCah8kaAW...
| | | Don't feel bad Eric, it's not really *math* in this case (reduced to
| | | giggling on the floor...)
| | |
| | | --
| | | R. Robert Bell, MCSE
| | | Xtending the Power
| | | www.acadx.com
| | |
| | | "Frank Oquendo" wrote in message
| | | news:17C804620D8B5BFA92D3993CF9AC8371@in.WebX.SaUCah8kaAW...
| | | | (polar p1 (angle p1 p2) d)
| | | |
| | | | --
| | | | Attitudes are contagious. Is yours worth catching?
| | | | http://www.acadx.com
| | | |
| | | | "Eric Schneider" wrote in message
| | | | news:CEE5E0063099941F31A459F2A130DFD6@in.WebX.SaUCah8kaAW...
| | | | > Hello group,
| | | | >
| | | | > Using LISP, how would one calc a point (p3), between two other
| points
| | | (p1
| | | | > and p2), a given distance (dist) from p1?
| | | | > Example:
| | | | >
| | | | > p1 = (2.0 2.5 0.0)
| | | | > p2 = (6.5 2.2 1.0)
| | | | > dist = 1.5
| | | | > p3 = ?
| | | | >
| | | | > I'm sure there is a simple formula, however, I failed 3rd grade
math
| | | five
| | | | > times.
| | | | > --
| | | | > Eric S. eschneider@jensenprecast.com
| | | | >
| | | |
| | |
| |
|
0 Likes
Message 25 of 63

Anonymous
Not applicable
Rudy, something's wrong on your end. It works here. Look at the code after
all... there's no distinction between the X,Y or Z. If it works for X,Y, it
will work for Z.

"Cadentity.Com" wrote in message
news:B23E80BBF6F2EAEB082404485737F9F1@in.WebX.SaUCah8kaAW...
| Doesn't work.
|
| Your function must return a differing 'Z', not one of the 'Z' coord. from
| one of the points but a calculated 'Z' of the slope between the (2)two
| points.
|
| --
| rudy@cadentity.com
| Practical Utilities for Productive Solutions
|
| Jadranko Stjepanovic wrote in message
| news:4C00F38CB8AAD0006AE264306820AD56@in.WebX.SaUCah8kaAW...
| > This one is faster (45%, roughly measured):
| >
| > (defun point-along-line (p1 p2 dist / sc)
| > (setq sc (/ dist (distance p1 p2)))
| > (mapcar '(lambda (p1 p2) (+ p1 (* sc (- p2 p1)))) p1 p2)
| > )
| >
| > This one is slightly slower than the previous one, but wont fail with
| > "divide by zero error" if p1 equals p2:
| >
| > (defun point-along-line (p1 p2 dist / d sc)
| > (if (zerop (setq d (distance p1 p2)))
| > p1
| > (progn
| > (setq sc (/ dist d))
| > (mapcar '(lambda (p1 p2) (+ p1 (* sc (- p2 p1)))) p1 p2)
| > )
| > )
| > )
| >
| > This one is short and funny:
| >
| > (c:cal "pld(p1,p2,d)")
| >
| > Jadranko
| >
| > Tony Tanzillo wrote in message <39A44FAA.16A37871@worldnet.att.net>...
| > >What Frank posted doesn't work in the 3D case, as
| > >original example requires.
| > >
| > >;; (point-on-line )
| > >;;
| > >;; Returns a point on the line -
| > >;; a specified distance from
| > >
| > >(defun point-on-line (p1 p2 dist / sc)
| > > (setq sc (/ dist (distance p1 p2)))
| > > (mapcar '+ p1
| > > (mapcar '*
| > > (mapcar '- p2 p1)
| > > (list sc sc sc)
| > > )
| > > )
| > >)
| > >
| >
|
0 Likes
Message 26 of 63

Anonymous
Not applicable
Yes, we should all give Eric a gold start (*, here's mine!) for starting an
innocent thread that has generated such a wide response. So Cliff, did you
throw down the gauntlet before, or after, you asked your son for the
math?...

--
R. Robert Bell, MCSE
Xtending the Power
www.acadx.com

"Cliff Middleton" wrote in message
news:47769F75527D27E7BD40F621D5C688F8@in.WebX.SaUCah8kaAW...
| I should point out the obvious lack of knowlege behind this statement.
Not
| only should the (angle) function be excluded but it must be excluded since
| it projects the angle between 3D points onto the current construction
plane.
| This is why (polar p1 (angle p1 p2) d) while fine for 2D points, does not
| return the correct coord for 3D points.
|
| What I should have asked for was to exclude the (distance) function. I
find
| that it helps to retard the atrophy of brain cells to "manually" do the
math
| that we normally rely on functions to do for us plus I learn things (like
| the caveat of the angle function with 3D points).
|
| So I offer the following for comments, processing speed analysis,
| whatever...
|
| (defun point-on-line (p1 p2 d1 / d2 sc)
| (setq
| d2 (sqrt (apply '+ (mapcar '(lambda (a b) (expt (- a b) 2.0)) p1 p2)))
| sc (/ d1 d2)
| )
| (mapcar '(lambda (a b) (+ a (* sc (- b a)))) p1 p2)
| )
|
| Credit to my son for the formula to calculate the distance between two
| points [there may be other and better ways to lispify it] and the
| (mapcar...) is from Mr. Stjepanovics contribution.
|
| Thank you for the clinic and happy trails, all.
|
| Cliffo
|
0 Likes
Message 27 of 63

Anonymous
Not applicable
Rudy,
I don't know what you (or your computer) are on
but both Tony's & Jadranko's solutions work for me.
However, I use
(defun frac_pt (pt1 pt2 frac)
(mapcar '+ pt1
(mapcar '(lambda (x) (* x frac))
(mapcar '- pt2 pt1)))
)
where frac is distance from pt1 to required point
divided by distance from pt1 to pt2.
i.e. frac = 0.5 returns the midpt between pt1 & pt2
Then to get a user_distance along the line between
pp1 & pp2 use
(frac_pt pp1 pp2 (/ user_distance (distance pp1 pp2)))
Regards Ian

Cadentity.Com wrote in message
news:B23E80BBF6F2EAEB082404485737F9F1@in.WebX.SaUCah8kaAW...
> Doesn't work.
>
> Your function must return a differing 'Z', not one of the 'Z' coord. from
> one of the points but a calculated 'Z' of the slope between the (2)two
> points.
>
> --
> rudy@cadentity.com
> Practical Utilities for Productive Solutions
>
> Jadranko Stjepanovic wrote in message
> news:4C00F38CB8AAD0006AE264306820AD56@in.WebX.SaUCah8kaAW...
> > This one is faster (45%, roughly measured):
> >
> > (defun point-along-line (p1 p2 dist / sc)
> > (setq sc (/ dist (distance p1 p2)))
> > (mapcar '(lambda (p1 p2) (+ p1 (* sc (- p2 p1)))) p1 p2)
> > )
> >
> > This one is slightly slower than the previous one, but wont fail with
> > "divide by zero error" if p1 equals p2:
> >
> > (defun point-along-line (p1 p2 dist / d sc)
> > (if (zerop (setq d (distance p1 p2)))
> > p1
> > (progn
> > (setq sc (/ dist d))
> > (mapcar '(lambda (p1 p2) (+ p1 (* sc (- p2 p1)))) p1 p2)
> > )
> > )
> > )
> >
> > This one is short and funny:
> >
> > (c:cal "pld(p1,p2,d)")
> >
> > Jadranko
> >
> > Tony Tanzillo wrote in message <39A44FAA.16A37871@worldnet.att.net>...
> > >What Frank posted doesn't work in the 3D case, as
> > >original example requires.
> > >
> > >;; (point-on-line )
> > >;;
> > >;; Returns a point on the line -
> > >;; a specified distance from
> > >
> > >(defun point-on-line (p1 p2 dist / sc)
> > > (setq sc (/ dist (distance p1 p2)))
> > > (mapcar '+ p1
> > > (mapcar '*
> > > (mapcar '- p2 p1)
> > > (list sc sc sc)
> > > )
> > > )
> > >)
> > >
> >
>
0 Likes
Message 28 of 63

Anonymous
Not applicable
Frank,
in a word - no.
Pythagorus or some such geezer had it sussed
many moons ago.
Regards Ian

Frank Oquendo wrote in message
news:57B0A840B67EFE392DF56D0966FBF75A@in.WebX.SaUCah8kaAW...
> > 1) How would you calculate the 2D distance
> > from the supplied 3D distance?
>
> My original reply will do just that (as Tony so astutely pointed out).
>
> --
> Attitudes are contagious. Is yours worth catching?
> http://www.acadx.com
>
> "Ian Bryant" wrote in message
> news:65D95F46AF541E7BA4537DEF40BC2753@in.WebX.SaUCah8kaAW...
> > Frank,
> > 1) How would you calculate the 2D distance
> > from the supplied 3D distance?
> > 2) If either or both of the point arguments are 2D
> > Tony's solution returns a 2D point calculated
> > using X,Y values only. This is consistent with
> > Autocad's treatment of mixed points.
> > (e.g. refer the AutoLisp distance function).
> > If you want a different result, (there are lots of
> > different possibilities), you will have
> > to program for it either by altering the
> > input points or massaging the output.
> > Regards Ian
>
0 Likes
Message 29 of 63

Anonymous
Not applicable
Cliff,

FYI, I ran some light timer tests, and found that Jadranko's was fastest by
11%, over Tony's, with yours next at 13% slower than Tony's, and a
(vl-catch-all-apply) variation bringing up a *very* distant last.

--
R. Robert Bell, MCSE
Xtending the Power
www.acadx.com

"Cliff Middleton" wrote in message
news:47769F75527D27E7BD40F621D5C688F8@in.WebX.SaUCah8kaAW...
| I should point out the obvious lack of knowlege behind this statement.
Not
| only should the (angle) function be excluded but it must be excluded since
| it projects the angle between 3D points onto the current construction
plane.
| This is why (polar p1 (angle p1 p2) d) while fine for 2D points, does not
| return the correct coord for 3D points.
|
| What I should have asked for was to exclude the (distance) function. I
find
| that it helps to retard the atrophy of brain cells to "manually" do the
math
| that we normally rely on functions to do for us plus I learn things (like
| the caveat of the angle function with 3D points).
|
| So I offer the following for comments, processing speed analysis,
| whatever...
|
| (defun point-on-line (p1 p2 d1 / d2 sc)
| (setq
| d2 (sqrt (apply '+ (mapcar '(lambda (a b) (expt (- a b) 2.0)) p1 p2)))
| sc (/ d1 d2)
| )
| (mapcar '(lambda (a b) (+ a (* sc (- b a)))) p1 p2)
| )
|
| Credit to my son for the formula to calculate the distance between two
| points [there may be other and better ways to lispify it] and the
| (mapcar...) is from Mr. Stjepanovics contribution.
|
| Thank you for the clinic and happy trails, all.
|
| Cliffo
|
| Cliff Middleton wrote in message
| news:262A663F02360D27C76A0A5BC0F12EEA@in.WebX.SaUCah8kaAW...
| | I suppose we should exclude the (angle) function from the challenge as
| well.
| |
| | Cliff Middleton wrote in message
| | news:CC9E64BF786FB517CB8A226714A62D90@in.WebX.SaUCah8kaAW...
| | | So without using the (polar) function, what is the formula for Eric's
| | | objective? (he said as his gauntlet cascaded to the floor...)
| | |
| | | Cliff
| | |
| | | R. Robert Bell wrote in message
| | | news:1D358B650846B6463EEED3017A46CF93@in.WebX.SaUCah8kaAW...
| | | | Don't feel bad Eric, it's not really *math* in this case (reduced to
| | | | giggling on the floor...)
| | | |
| | | | --
| | | | R. Robert Bell, MCSE
| | | | Xtending the Power
| | | | www.acadx.com
| | | |
| | | | "Frank Oquendo" wrote in message
| | | | news:17C804620D8B5BFA92D3993CF9AC8371@in.WebX.SaUCah8kaAW...
| | | | | (polar p1 (angle p1 p2) d)
| | | | |
| | | | | --
| | | | | Attitudes are contagious. Is yours worth catching?
| | | | | http://www.acadx.com
| | | | |
| | | | | "Eric Schneider" wrote in message
| | | | | news:CEE5E0063099941F31A459F2A130DFD6@in.WebX.SaUCah8kaAW...
| | | | | > Hello group,
| | | | | >
| | | | | > Using LISP, how would one calc a point (p3), between two other
| | points
| | | | (p1
| | | | | > and p2), a given distance (dist) from p1?
| | | | | > Example:
| | | | | >
| | | | | > p1 = (2.0 2.5 0.0)
| | | | | > p2 = (6.5 2.2 1.0)
| | | | | > dist = 1.5
| | | | | > p3 = ?
| | | | | >
| | | | | > I'm sure there is a simple formula, however, I failed 3rd grade
| math
| | | | five
| | | | | > times.
| | | | | > --
| | | | | > Eric S. eschneider@jensenprecast.com
| | | | | >
| | | | |
| | | |
| | |
| |
|
0 Likes
Message 30 of 63

Anonymous
Not applicable
Ahh.... quite sharp. Thanks for the guidance.

--
Attitudes are contagious. Is yours worth catching?
http://www.acadx.com

"Ian Bryant" wrote in message
news:6CCB4DD1822B273BB198753E1A56269B@in.WebX.SaUCah8kaAW...
> Frank,
> in a word - no.
> Pythagorus or some such geezer had it sussed
> many moons ago.
> Regards Ian
0 Likes
Message 31 of 63

Anonymous
Not applicable
Eric,
What is 3rd grade maths?
I have noticed in this disscussion group that
simple queries tend to generate longer threads.
Remove two variables (after the first post from
each of these variables) from the thread and
you are close to geting some sense.
Regards Ian.

Eric Schneider wrote in message
news:CEE5E0063099941F31A459F2A130DFD6@in.WebX.SaUCah8kaAW...
> Hello group,
>
> Using LISP, how would one calc a point (p3), between two other points (p1
> and p2), a given distance (dist) from p1?
> Example:
>
> p1 = (2.0 2.5 0.0)
> p2 = (6.5 2.2 1.0)
> dist = 1.5
> p3 = ?
>
> I'm sure there is a simple formula, however, I failed 3rd grade math five
> times.
> --
> Eric S. eschneider@jensenprecast.com
>
0 Likes
Message 32 of 63

Anonymous
Not applicable
Your slip is showing. Tony and I are not "variables". We're people. My
response was flawed, Tony's is dead-on. If you wish to pare the all posts
that do not directly answer Eric's query, Tony's is the only the one that
matters. But then again, it looks to me like the folks here are just
discussing different approaches to the same goal. And all on a discussion
server. Imagine that.

--
Attitudes are contagious. Is yours worth catching?
http://www.acadx.com

"Ian Bryant" wrote in message
news:309E0C4814363CAD253C92A301D097F4@in.WebX.SaUCah8kaAW...
> Eric,
> What is 3rd grade maths?
> I have noticed in this disscussion group that
> simple queries tend to generate longer threads.
> Remove two variables (after the first post from
> each of these variables) from the thread and
> you are close to geting some sense.
> Regards Ian.
0 Likes
Message 33 of 63

Anonymous
Not applicable
🙂 Neither, Bobby Bee, it was the towel (not the gauntlet) at that point
:)...on the other hand, I should get some credit for my son's brain, eh?

R. Robert Bell wrote in message
news:C97237B9B8FA38C6044A93B132070B5A@in.WebX.SaUCah8kaAW...
| Yes, we should all give Eric a gold start (*, here's mine!) for starting
an
| innocent thread that has generated such a wide response. So Cliff, did you
| throw down the gauntlet before, or after, you asked your son for the
| math?...
|
| --
| R. Robert Bell, MCSE
| Xtending the Power
| www.acadx.com
|
| "Cliff Middleton" wrote in message
| news:47769F75527D27E7BD40F621D5C688F8@in.WebX.SaUCah8kaAW...
| | I should point out the obvious lack of knowlege behind this statement.
| Not
| | only should the (angle) function be excluded but it must be excluded
since
| | it projects the angle between 3D points onto the current construction
| plane.
| | This is why (polar p1 (angle p1 p2) d) while fine for 2D points, does
not
| | return the correct coord for 3D points.
| |
| | What I should have asked for was to exclude the (distance) function. I
| find
| | that it helps to retard the atrophy of brain cells to "manually" do the
| math
| | that we normally rely on functions to do for us plus I learn things
(like
| | the caveat of the angle function with 3D points).
| |
| | So I offer the following for comments, processing speed analysis,
| | whatever...
| |
| | (defun point-on-line (p1 p2 d1 / d2 sc)
| | (setq
| | d2 (sqrt (apply '+ (mapcar '(lambda (a b) (expt (- a b) 2.0)) p1 p2)))
| | sc (/ d1 d2)
| | )
| | (mapcar '(lambda (a b) (+ a (* sc (- b a)))) p1 p2)
| | )
| |
| | Credit to my son for the formula to calculate the distance between two
| | points [there may be other and better ways to lispify it] and the
| | (mapcar...) is from Mr. Stjepanovics contribution.
| |
| | Thank you for the clinic and happy trails, all.
| |
| | Cliffo
| |
|
0 Likes
Message 34 of 63

Anonymous
Not applicable
Just curious what would happen speed-wise if we take out my setq of the
distance.

(defun point-on-line (p1 p2 d1 / sc)
(setq sc (/ d1 (sqrt (apply '+ (mapcar '(lambda (a b) (expt (- a b) 2.0))
p1 p2)))))
(mapcar '(lambda (a b) (+ a (* sc (- b a)))) p1 p2)
)

R. Robert Bell wrote in message
news:87B082F435869ED59B9791F24240B29F@in.WebX.SaUCah8kaAW...
| Cliff,
|
| FYI, I ran some light timer tests, and found that Jadranko's was fastest
by
| 11%, over Tony's, with yours next at 13% slower than Tony's, and a
| (vl-catch-all-apply) variation bringing up a *very* distant last.
|
| --
| R. Robert Bell, MCSE
| Xtending the Power
| www.acadx.com
|
| "Cliff Middleton" wrote in message
| news:47769F75527D27E7BD40F621D5C688F8@in.WebX.SaUCah8kaAW...
| | I should point out the obvious lack of knowlege behind this statement.
| Not
| | only should the (angle) function be excluded but it must be excluded
since
| | it projects the angle between 3D points onto the current construction
| plane.
| | This is why (polar p1 (angle p1 p2) d) while fine for 2D points, does
not
| | return the correct coord for 3D points.
| |
| | What I should have asked for was to exclude the (distance) function. I
| find
| | that it helps to retard the atrophy of brain cells to "manually" do the
| math
| | that we normally rely on functions to do for us plus I learn things
(like
| | the caveat of the angle function with 3D points).
| |
| | So I offer the following for comments, processing speed analysis,
| | whatever...
| |
| | (defun point-on-line (p1 p2 d1 / d2 sc)
| | (setq
| | d2 (sqrt (apply '+ (mapcar '(lambda (a b) (expt (- a b) 2.0)) p1 p2)))
| | sc (/ d1 d2)
| | )
| | (mapcar '(lambda (a b) (+ a (* sc (- b a)))) p1 p2)
| | )
| |
| | Credit to my son for the formula to calculate the distance between two
| | points [there may be other and better ways to lispify it] and the
| | (mapcar...) is from Mr. Stjepanovics contribution.
| |
| | Thank you for the clinic and happy trails, all.
| |
| | Cliffo
| |
| | Cliff Middleton wrote in message
| | news:262A663F02360D27C76A0A5BC0F12EEA@in.WebX.SaUCah8kaAW...
| | | I suppose we should exclude the (angle) function from the challenge as
| | well.
| | |
| | | Cliff Middleton wrote in message
| | | news:CC9E64BF786FB517CB8A226714A62D90@in.WebX.SaUCah8kaAW...
| | | | So without using the (polar) function, what is the formula for
Eric's
| | | | objective? (he said as his gauntlet cascaded to the floor...)
| | | |
| | | | Cliff
| | | |
| | | | R. Robert Bell wrote in message
| | | | news:1D358B650846B6463EEED3017A46CF93@in.WebX.SaUCah8kaAW...
| | | | | Don't feel bad Eric, it's not really *math* in this case (reduced
to
| | | | | giggling on the floor...)
| | | | |
| | | | | --
| | | | | R. Robert Bell, MCSE
| | | | | Xtending the Power
| | | | | www.acadx.com
| | | | |
| | | | | "Frank Oquendo" wrote in message
| | | | | news:17C804620D8B5BFA92D3993CF9AC8371@in.WebX.SaUCah8kaAW...
| | | | | | (polar p1 (angle p1 p2) d)
| | | | | |
| | | | | | --
| | | | | | Attitudes are contagious. Is yours worth catching?
| | | | | | http://www.acadx.com
| | | | | |
| | | | | | "Eric Schneider" wrote in message
| | | | | | news:CEE5E0063099941F31A459F2A130DFD6@in.WebX.SaUCah8kaAW...
| | | | | | > Hello group,
| | | | | | >
| | | | | | > Using LISP, how would one calc a point (p3), between two other
| | | points
| | | | | (p1
| | | | | | > and p2), a given distance (dist) from p1?
| | | | | | > Example:
| | | | | | >
| | | | | | > p1 = (2.0 2.5 0.0)
| | | | | | > p2 = (6.5 2.2 1.0)
| | | | | | > dist = 1.5
| | | | | | > p3 = ?
| | | | | | >
| | | | | | > I'm sure there is a simple formula, however, I failed 3rd
grade
| | math
| | | | | five
| | | | | | > times.
| | | | | | > --
| | | | | | > Eric S. eschneider@jensenprecast.com
| | | | | | >
| | | | | |
| | | | |
| | | |
| | |
| |
|
0 Likes
Message 35 of 63

Anonymous
Not applicable
I just hate it when the boy shows me up !
0 Likes
Message 36 of 63

Anonymous
Not applicable
Sorry,
That was my clumsy attempt at a bit of humour.
I have been mucking around with lisp since
before they moved the decimal point from 2.0
to 2000.0, but I am still learning VLISP/VB,
and find this news group very helpful.
Regards Ian

Frank Oquendo wrote in message
news:722FE9533B2D0BBE50C1F56CE8F7AA35@in.WebX.SaUCah8kaAW...
> Your slip is showing. Tony and I are not "variables". We're people. My
> response was flawed, Tony's is dead-on. If you wish to pare the all posts
> that do not directly answer Eric's query, Tony's is the only the one that
> matters. But then again, it looks to me like the folks here are just
> discussing different approaches to the same goal. And all on a discussion
> server. Imagine that.
>
> --
> Attitudes are contagious. Is yours worth catching?
> http://www.acadx.com
>
> "Ian Bryant" wrote in message
> news:309E0C4814363CAD253C92A301D097F4@in.WebX.SaUCah8kaAW...
> > Eric,
> > What is 3rd grade maths?
> > I have noticed in this disscussion group that
> > simple queries tend to generate longer threads.
> > Remove two variables (after the first post from
> > each of these variables) from the thread and
> > you are close to geting some sense.
> > Regards Ian.
>
0 Likes
Message 37 of 63

Anonymous
Not applicable
Ian,

> What is 3rd grade maths?
I'm not the one to ask. I can tell you all about 2nd grade math though.
After all, I sat in the same seat for two years.

On the flipper, I've gotten more out of this group than all six years in
second and third grades!
--
Eric S. eschneider@jensenprecast.com

P.S. This thread's not dead yet!
0 Likes
Message 38 of 63

Anonymous
Not applicable
Wow. That long, huh? Impressive.

--
Attitudes are contagious. Is yours worth catching?
http://www.acadx.com

"Ian Bryant" wrote in message
news:1D7EBE034EB652EF9A386B86F4277ABF@in.WebX.SaUCah8kaAW...
> Sorry,
> That was my clumsy attempt at a bit of humour.
> I have been mucking around with lisp since
> before they moved the decimal point from 2.0
> to 2000.0, but I am still learning VLISP/VB,
> and find this news group very helpful.
> Regards Ian
0 Likes
Message 39 of 63

Anonymous
Not applicable
No appreciable difference in my tests.

"Cliff Middleton" wrote in message
news:06DC9D6BD680EE967F6FA97E48C03E8E@in.WebX.SaUCah8kaAW...
| Just curious what would happen speed-wise if we take out my setq of the
| distance.
|
| (defun point-on-line (p1 p2 d1 / sc)
| (setq sc (/ d1 (sqrt (apply '+ (mapcar '(lambda (a b) (expt (- a b) 2.0))
| p1 p2)))))
| (mapcar '(lambda (a b) (+ a (* sc (- b a)))) p1 p2)
| )
|
0 Likes
Message 40 of 63

Anonymous
Not applicable
I'm not debating that it doesn't return the x,y and z.

It's suppose to return in space the proper location of z.

If one 'z' is at 0 and the other 'z' is at 12, the midpoint is 6.

rudy@cadentity.com

R. Robert Bell wrote in message
news:3053468E50EBEAF45093DB4D20B61A64@in.WebX.SaUCah8kaAW...
> Rudy, something's wrong on your end. It works here. Look at the code after
> all... there's no distinction between the X,Y or Z. If it works for X,Y,
it
> will work for Z.
>
> "Cadentity.Com" wrote in message
> news:B23E80BBF6F2EAEB082404485737F9F1@in.WebX.SaUCah8kaAW...
> | Doesn't work.
> |
> | Your function must return a differing 'Z', not one of the 'Z' coord.
from
> | one of the points but a calculated 'Z' of the slope between the (2)two
> | points.
> |
> | --
> | rudy@cadentity.com
> | Practical Utilities for Productive Solutions
> |
> | Jadranko Stjepanovic wrote in message
> | news:4C00F38CB8AAD0006AE264306820AD56@in.WebX.SaUCah8kaAW...
> | > This one is faster (45%, roughly measured):
> | >
> | > (defun point-along-line (p1 p2 dist / sc)
> | > (setq sc (/ dist (distance p1 p2)))
> | > (mapcar '(lambda (p1 p2) (+ p1 (* sc (- p2 p1)))) p1 p2)
> | > )
> | >
> | > This one is slightly slower than the previous one, but wont fail with
> | > "divide by zero error" if p1 equals p2:
> | >
> | > (defun point-along-line (p1 p2 dist / d sc)
> | > (if (zerop (setq d (distance p1 p2)))
> | > p1
> | > (progn
> | > (setq sc (/ dist d))
> | > (mapcar '(lambda (p1 p2) (+ p1 (* sc (- p2 p1)))) p1 p2)
> | > )
> | > )
> | > )
> | >
> | > This one is short and funny:
> | >
> | > (c:cal "pld(p1,p2,d)")
> | >
> | > Jadranko
> | >
> | > Tony Tanzillo wrote in message <39A44FAA.16A37871@worldnet.att.net>...
> | > >What Frank posted doesn't work in the 3D case, as
> | > >original example requires.
> | > >
> | > >;; (point-on-line )
> | > >;;
> | > >;; Returns a point on the line -
> | > >;; a specified distance from
> | > >
> | > >(defun point-on-line (p1 p2 dist / sc)
> | > > (setq sc (/ dist (distance p1 p2)))
> | > > (mapcar '+ p1
> | > > (mapcar '*
> | > > (mapcar '- p2 p1)
> | > > (list sc sc sc)
> | > > )
> | > > )
> | > >)
> | > >
> | >
> |
>
0 Likes