![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
If i have 2 points A <x1,y1,z1> and B <x2,y2,z2>, how do i find coordinates
of point C <x3,y3,z3> which lies on the line AB, distance D from point A?
Thank you,
Boris.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
That's either
vnormalize(B-A)*D+A
or
-vnormalize(B-A)*D+A
depending on which direction you're thinking of. The first
will either move towards or pass B when D is either smaller
or larger than the distance from A to B,
the second will move away from A and B on the line.
Now that's POV-Code, if you want the actual formula
to do it by hand, you can easily look up vnormalize in
the docs or search the web for normalizing vectors (which
is actually just dividing a vector by its length, which
can be calculated by taking the square-root of the addition
of each component (x, y, and z) squared...
That'd be:
square_root( x*x + y*y + z*z)
That isn't POV-Code, its Pseudo-Code to aid in understanding
the complicated sentence above. :-)
--
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
> If i have 2 points A <x1,y1,z1> and B <x2,y2,z2>, how do i find
coordinates
> of point C <x3,y3,z3> which lies on the line AB, distance D from point A?
>
> Thank you,
>
> Boris.
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.501 / Virus Database: 299 - Release Date: 14.07.2003
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
BorisW37 wrote:
>If i have 2 points A <x1,y1,z1> and B <x2,y2,z2>, how do i find coordinates
>of point C <x3,y3,z3> which lies on the line AB, distance D from point A?
>
>Thank you,
>
>Boris.
>
I got it:
First find D=distance between A and B
D=sqrt((x2-x1)^2+(y2-y1)^2+(z2-z1)^2)
then
x3=x1+d/D(x2-x1)
y3=y1+d/D(y2-y1)
z3=z1+d/D(z2-z1)
but now i have another question, if I have a vector named my_vector
# declare my_vector=<1,2,3>;
how do i find individual values of x,y and z
so that i could find
#declare my_vector_X=.....; (shoud be 1)
#declare my_vector_Y=.....; (shoud be 2)
#declare my_vector_Z=.....; (shoud be 3)
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
In article <web.3f187c7a5afdf36ca6ac136d0@news.povray.org>,
"BorisW37" <Bor### [at] yahoo com> wrote:
> If i have 2 points A <x1,y1,z1> and B <x2,y2,z2>, how do i find coordinates
> of point C <x3,y3,z3> which lies on the line AB, distance D from point A?
vnormalize(B - A)*D + A
Find a vector pointing in the direction of the line (B-A), normalize it
so its length is 1, scale it by the desired distance, and add it to the
first point of the line. If you leave out the vnormalize(), D acts as
the percentage (as a fractional value in the range [0, 1]) of the
distance from A to B, rather than the absolute distance in units.
Or if you are just looking for the midpoint, (A + B)/2 will work.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
In article <web.3f18821015c57b22a6ac136d0@news.povray.org>,
"BorisW37" <Bor### [at] yahoo com> wrote:
> how do i find individual values of x,y and z
You're making it overly difficult. POV has features for making this kind
of math easier, the best ways to do it in POV have been explained in
other replies. You might want to look through math.inc, it has some
macros and functions that themselves may be useful to you as well as
showing you what you can do. To answer your question, you can access the
components with the dot syntax: MyVector.x, MyVector.y, etc. There are
more dot operators for various situations, this feature is fully
described in the manual, along with the other built-in vector math
functions.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
BorisW37 wrote:
> If i have 2 points A <x1,y1,z1> and B <x2,y2,z2>, how do i find coordinates
> of point C <x3,y3,z3> which lies on the line AB, distance D from point A?
x3 = x1 + D * (x2 - x1)
assuming 0 <= D <= 1 (in other words,
assuming D is normallized).
Repeat for y and z.
--
Steve Martin, CPBE CBNT
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
BorisW37 wrote:
> BorisW37 wrote:
>
>>If i have 2 points A <x1,y1,z1> and B <x2,y2,z2>, how do i find coordinates
>>of point C <x3,y3,z3> which lies on the line AB, distance D from point A?
>>
>>Thank you,
>>
>>Boris.
>>
>
>
> I got it:
> First find D=distance between A and B
> D=sqrt((x2-x1)^2+(y2-y1)^2+(z2-z1)^2)
> then
> x3=x1+d/D(x2-x1)
> y3=y1+d/D(y2-y1)
> z3=z1+d/D(z2-z1)
>
> but now i have another question, if I have a vector named my_vector
> # declare my_vector=<1,2,3>;
>
> how do i find individual values of x,y and z
> so that i could find
> #declare my_vector_X=.....; (shoud be 1)
> #declare my_vector_Y=.....; (shoud be 2)
> #declare my_vector_Z=.....; (shoud be 3)
>
When you have vector V, you access its coordinates with V.x, V.y and
V.z, but it's usually better to use vectors in your formulas.
JC
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |