Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**luca-deltodesco****Member**- Registered: 2006-05-05
- Posts: 1,470

ive heard that from the equation for a shape, lets say the equation for a torus, that from the coordiante for a point on the torus, you can arbitarily find the normal vector via differentiating or something, ofcourse theres other ways of getting normal with a torus, like with a sphere etc

but for strange shapes that have no such easy way, there must be some way of calculating a normal vector just from the equaiton, in the same way that from a curve, you can find the tangent vector by finding the gradient

The Beginning Of All Things To End.

The End Of All Things To Come.

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

Yes, but how do you differentiate in 3-D?

**igloo** **myrtilles** **fourmis**

Offline

**luca****Guest**

John E. Franklin wrote:

Yes, but how do you differentiate in 3-D?

thats what im asking

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

Just thinking...

Is it possible to get 2-D equations of cross-sections at various angles that go thru the point of interest?? I don't know.

**igloo** **myrtilles** **fourmis**

Offline

**Zhylliolom****Real Member**- Registered: 2005-09-05
- Posts: 412

Sorry for taking a little while to respond to this, but I take forever to type up LaTeX and I had to head out for the day yesterday while I was typing it up. Anyway, here's my simple calculus/vector analysis method for doing it.

For a torus:

Since you mentioned a torus first, I'll use it for the first example. The parametric expression for a torus is

where *c* is the distance from the center to the inner boundary of the torus and *a* is the radius of the torus "tube."

Now, first we want to find the tangent vectors to the "curves" of the torus. To do this, we calculate the partial derivatives:

Since the magnitude of the vectors is irrevelant (unless the magnitude is 0, then that's no fun), we can simplify the partial derivatives by dividing through by *a* in *f[sub]u[/sub]* and (*c + a* cos *u*) in *f[sub]v[/sub]*:

Now we may simply put our parameter values *u* and *v* in for our point of interest. We have two partial derivatives here, so for our arbitrary parameter values, we will get two tangent vectors. This is a good thing, since from basic vector analysis, we know how to find a vector mutually perpendicular to two given vectors in **R**[sup]3[/sup]: the cross product. So now what we merely need to do is take the cross product of the two tangent vectors obtained:

This process can be used for other surfaces, such as a sphere (parametrically defined in **R**[sup]3[/sup] by [*r* cos *u* sin *v*, *r* sin *u* sin *v*, *r* cos *v*]).

I leave you with the following note:

Edits: It seems that the forum is thinner than the preview space... and I can't get some of the spacing right still. Oh well.

*Last edited by Zhylliolom (2006-06-23 15:17:47)*

Offline

**George,Y****Member**- Registered: 2006-03-12
- Posts: 1,306

You'd better get a vector calculus book or a calculus book with sufficient vector calculus.

**X'(y-Xβ)=0**

Offline

**luca-deltodesco****Member**- Registered: 2006-05-05
- Posts: 1,470

wow Zhylliolom, very interesting, but is it possible supposing there is no parametric definition? In a way such that it is a single equation equating zero for a point f(x,y,z)

for example, a torus again, but rather than parametric equations

that it were a single equation equating zero

ive never done partial derivatives before, but i guess you could do a partial derivative for x,y,z ... only what use would that be?

but for the sake of it, is that correct?

*Last edited by luca-deltodesco (2006-06-23 18:53:11)*

The Beginning Of All Things To End.

The End Of All Things To Come.

Offline

**Zhylliolom****Real Member**- Registered: 2005-09-05
- Posts: 412

A lot of the work is cleared away if the surface requires no parametric definition. In fact, if *F*(*x, y, z*) = 0 is the equation of the surface, then the normal to the surface is

where (*a, b, c*) is the arbitrary point of the surface which we wish to find the normal and the operator

So, for the surface you defined and found the first order partial derivatives for in your previous post,

Offline

**luca-deltodesco****Member**- Registered: 2006-05-05
- Posts: 1,470

what really annoys me

is that before i even posted this thread, i had tried just that

i took the surface equation for a torus equating zero, then differentaited with respect to x,y,z (i didnt know it was called partial differentiation, i just did it) and then used it for the normals x,y,z normalizing, and yet it didnt seem to work, so i asked here

and now ive tried it again, and it works perfectly! :X

thankyou very much for your help. but one last thing

what does the |(a,b,c) notation actually mean? Ive never seen it before

*Last edited by luca-deltodesco (2006-06-23 20:06:09)*

The Beginning Of All Things To End.

The End Of All Things To Come.

Offline

**Zhylliolom****Real Member**- Registered: 2005-09-05
- Posts: 412

luca-deltodesco wrote:

what does the |(a,b,c) notation actually mean? Ive never seen it before

It tells the reader to evaluate the preceding expression given that (*x, y, z*) = (*a, b, c*), where *a, b, c* are arbitrary points. For example:

Basically, in this situation, the notation tells you to evaluate the expression at the point indicated in the subscript.

I see the notation a lot with derivatives. Suppose *y* = *x*². Then

Offline

**luca-deltodesco****Member**- Registered: 2006-05-05
- Posts: 1,470

ah i get it now

note that ive ommited the '4x' in it, since it doesnt make any difference to the resulting normalized vector

and infact, this algebraic approach, is actually faster than the geometrical approach

The geometrical approach requires normalizing a vector, then subtracting, then normalizing again, and only works when R>r, this is only requires one normalisation after finding the vector, and gamma and alpha have already been calculated when finding the intersection with a ray

now all i need, is to calculate the tangent space at a given point on a surface

*Last edited by luca-deltodesco (2006-06-23 20:30:22)*

The Beginning Of All Things To End.

The End Of All Things To Come.

Offline

**Zhylliolom****Real Member**- Registered: 2005-09-05
- Posts: 412

If by "tangent space" you mean the tangent plane to the surface at a given point, that is just as easy to determine.

The rectangular form of the plane is given by

Edit: Hey, it looks better!

*Last edited by Zhylliolom (2006-06-23 20:54:35)*

Offline

**luca-deltodesco****Member**- Registered: 2006-05-05
- Posts: 1,470

ah wait, i think i have an easy solid method of calculating the tangent space, which will work quite well for what i need too

i need one of the tangents to be in the x,z plane

so i should be able to do this

taking the normal n.

normalize the vector after projecting it onto the x,z plane i.e. normalize (n.x,0,n.z), lets say its (a,0,b), then the first tangent vector will be (-b,0,a)

and then the second tangent vector via cross product

in the case that the normal vector is (0,1,0) you can use base axis (1,0,0) and (0,0,1)

The Beginning Of All Things To End.

The End Of All Things To Come.

Offline

**luca****Guest**

oh and by tangent space, i meant calculating 3 vectors from a surface, the normal, and two perpendicular tangents. i.e. to calculate a rotational matrix to transform a point from world space to the same base as the surface normal

its needed for stuff like normal mapping in graphical programming