POV-Ray : Newsgroups : povray.general : Working with vectors Server Time
5 Nov 2024 05:22:25 EST (-0500)
  Working with vectors (Message 1 to 8 of 8)  
From: Peter McCombs
Subject: Working with vectors
Date: 6 Jul 2003 13:46:14
Message: <3f086066$1@news.povray.org>
How can I find a point on a vector with POV-Ray?

-Peter


Post a reply to this message

From: Ray Gardener
Subject: Re: Working with vectors
Date: 6 Jul 2003 15:22:29
Message: <3f0876f5$1@news.povray.org>
> How can I find a point on a vector with POV-Ray?

What kind of point are you looking for?
Something that intersects an object (use trace()),
or just a point some distance along a ray
(use #declare vecResult = vec.normalize() * the_distance + position;)?


Ray Gardener
Daylon Graphics Ltd.
"Heightfield modeling perfected"
http://www.daylongraphics.com


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Working with vectors
Date: 6 Jul 2003 22:57:04
Message: <3f08e180@news.povray.org>
Given a "vector"  <a,b,c>,  povray thinks of this as a vector with one end
at origin, the other at <a,b,c>.  I'm assuming this would answer your
question.


Post a reply to this message

From: Warp
Subject: Re: Working with vectors
Date: 7 Jul 2003 05:23:26
Message: <3f093c0d@news.povray.org>
Greg M. Johnson <gregj;-)565### [at] aolcom> wrote:
> Given a "vector"  <a,b,c>,  povray thinks of this as a vector with one end
> at origin, the other at <a,b,c>.  I'm assuming this would answer your
> question.

  Mathematically speaking, you are confusing a vector with a line segment.

  They are not the same thing. A vector does *not* have two points. A
vector has a single point, which describes solely its direction and length.
A vector can also be represented by two angles and a scalar (representing
its length), nothing more.
  A line segment consists of two points: A starting point and an ending
point. This is effectively more than a vector since it places the vector
at certain coordinates.

  Your sentence "povray thinks of this as a vector with one
end at the origin, the other at <a,b,c>" is not accurate, and not
only because a vector does not have two endpoints, but because
there are several places where POV-Ray does not "think" a vector
as starting from the origin (eg. smooth triangle vertex normals, or
the normal vector return value of trace()).

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Peter McCombs
Subject: Re: Working with vectors
Date: 7 Jul 2003 11:45:41
Message: <slrnbgj5d5.6nn.pmccombs@xmission.xmission.com>
In article <3f0876f5$1@news.povray.org>, Ray Gardener wrote:
>> How can I find a point on a vector with POV-Ray?
>
>What kind of point are you looking for?
>Something that intersects an object (use trace()),
>or just a point some distance along a ray
>(use #declare vecResult = vec.normalize() * the_distance + position;)?


What I am trying to do is wrap a spline around another spline, which has doubled
 back on itself. I'm taking a segment of the spline, and normalizing it to find
the "direction" that the spline is going (#declare direction = 
vnormalize(segmentEnd - segmentStart);). Then I get a vector that is 
perpendicular to that direction (#declare p = vperp_to_vector(direction);).

I want to get a point on that perpendicular vector, and gradually rotate it 
around a point point on my spline until I wrap around it completely.

In my scene, this is going to help me make a siezing on a rope that I have 
modeled.

So what I think I need is any point along that perpendicular vector, which I 
think I can get using your example:

#declare vecResult = vec.normalize() * the_distance + position;

Where "vec" is my perpendicular vector that I want to find the point on, and 
"the_distance" is an arbitrary distance along that vector?  What does "position"
 represent on the vector? 

I'm not an expert at 3d math at all, so I hope I am on the right track with 
this idea.

Thanks,

-Peter


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Working with vectors
Date: 7 Jul 2003 12:35:20
Message: <3f09a148$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:3f093c0d@news.povray.org...
>   Your sentence "povray thinks of this as a vector with one
> end at the origin, the other at <a,b,c>" is not accurate, and not
> only because a vector does not have two endpoints, but because
> there are several places where POV-Ray does not "think" a vector
> as starting from the origin (eg. smooth triangle vertex normals, or
> the normal vector return value of trace()).
>

With the trace function, it will return an <a,b,c>.  What meaning does
<a,b,c> have way out on surface point <d,e,f>, unless it means parallel to a
vector {<0,0,0>, <a,b,c>}?,   or  the vector {<d,e,f>,<d+a, e+b, f+c> }?


Post a reply to this message

From: Christopher James Huff
Subject: Re: Working with vectors
Date: 7 Jul 2003 13:14:15
Message: <cjameshuff-97CA71.12115507072003@netplex.aussie.org>
In article <3f09a148$1@news.povray.org>,
 "Greg M. Johnson" <gregj:-)565### [at] aolcom> wrote:

> With the trace function, it will return an <a,b,c>.  What meaning does
> <a,b,c> have way out on surface point <d,e,f>, unless it means parallel to a
> vector {<0,0,0>, <a,b,c>}?,   or  the vector {<d,e,f>,<d+a, e+b, f+c> }?

It means the interesection is at the point represented by the vector < 
a, b, c>. "{<0,0,0>, <a,b,c>}" is not a vector, it is two vectors, 
representing either a line segment or a ray (I'm not sure which you are 
thinking of). A vector is a mathematical construct with direction and 
magnitude, nothing more. POV represents a vector as 3 floating point 
values for x, y, and z coordinates.

Or if you were talking about the normal value returned through the 
parameter, that is a direction vector. The normal points in the 
direction given by < a, b, c>. The intersection point is irrelevant.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Peter McCombs
Subject: Re: Working with vectors
Date: 7 Jul 2003 14:14:25
Message: <slrnbgje41.2bp.pmccombs@xmission.xmission.com>
In article <slr### [at] xmissionxmissioncom>, Peter McCombs wrote:
>Where "vec" is my perpendicular vector that I want to find the point on, and 
>"the_distance" is an arbitrary distance along that vector?  What does "position"
> represent on the vector? 


I think I can answer my own question on this now, thanks to the helpful
discussions in this thread:


A vector represents a direction in relation to the origin <0,0,0>, so in order
to find a point on a vector, I need to make sure the vector is translated
relative the object I am referencing with it. In my case, I want a point on a
vector that is perpendicular to the direction of my spline object.

I first normalize my perpendicular vector to ensure that its magnitude is 1
(a unit vector). This is so that I can specify points on the vector in terms
of units rather than factors of vector magnitude (right?).  This is
accomplished like so:

#declare vecPoint = vnormalize(vec) * distance;

Now, since this will get me a point relative to the origin, I should also 
add a translation into the equation:

#declare vecPoint = vnormalize(vec) * distance + aSpline(currentPoint);

This ought to give me a point relative to aSpline(currentPoint) at a distance 
of distance.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.