POV-Ray : Newsgroups : povray.general : Calculate 3D-Point based on two other Server Time
26 Nov 2024 07:44:18 EST (-0500)
  Calculate 3D-Point based on two other (Message 1 to 5 of 5)  
From: Chrisir
Subject: Calculate 3D-Point based on two other
Date: 8 Mar 2011 12:10:01
Message: <web.4d7662a2f7703718ce9a42b60@news.povray.org>
Hello,

I have a small mathematical question here.

(Please note: This is a completely different question than my last one, it just
sounds similar  ;-)
http://news.povray.org/povray.animations/thread/%3Cweb.4d6a542c8f7061ba22dbc4580%40news.povray.org%3E/
)


How can I calculate a 3D-Point C based on two other A and B?

The situation is as follows:

I have a Marble with the center C. I want to calculate this 3D-Center as CX, CY,
CZ (Marble Radius R).

The Marble runs on a track that consists of two small thin parallel wires. The
Marble is running between them, because their distance is a little smaller than
2R.
Like this:
http://www.youtube.com/watch?v=me1D1WZ0yNM

Anyway. Let's say the Marble is on the track and rolling. Continuously I will
have to calculate CX, CY, CZ during the animation.

The Marble is touching the left wire at point A (AX,AY,AZ) and the right wire at
a point B (BX,BY,BZ).

Let's assume the wires go parallel towards Z. Thus AX would be a little smaller
than BX and AY = BY (Height, the Marble is above the wires and has a higher
Y-value) and AZ = BZ (depth).

C would then be:
CX = (AX + BX) / 2 (in the middle between the wires)
CY = AY + R - 0.3 (or so, depending on how deep the Marble is between the wires)
CZ = AZ.

When the Marble rolls, the Z-values increase.

But the wires of course do curves and loopings and spirals and so on.

So the situation is always different and AX<>BX and AY<>BY and AZ<>BZ. So the
calculation of C is more difficult.

I am looking for a general formular that would be the solution for
CX=
CY=
CZ=

based on A and B.

The point C would always be in a right angle above the wires. Or, in a looping,
inside the looping, under the wires. Where my maths fail me.

All help is appreciated.


Thank you so much!

Chris


P.S.
I could write a lot more about this. Actually, it would be cooler to have a
physics-engine that simulates the Marble-Position based on my wires but it has
to be done via a formula for now.
At the moment my problem is that the Marble is above the wires or is cutting
through the wires which looks bad in my animation.


Post a reply to this message

From: Leroy Whetstone
Subject: Re: Calculate 3D-Point based on two other
Date: 8 Mar 2011 15:25:52
Message: <4D769087.9070000@joplin.com>
Chrisir wrote:
> 
> Hello,
> 
> I have a small mathematical question here.
> 
> (Please note: This is a completely different question than my last one, it just
> sounds similar  ;-)
>
http://news.povray.org/povray.animations/thread/%3Cweb.4d6a542c8f7061ba22dbc4580%40news.povray.org%3E/
> )
> 
> 
> How can I calculate a 3D-Point C based on two other A and B?
> 
> The situation is as follows:
> 
> I have a Marble with the center C. I want to calculate this 3D-Center as CX, CY,
> CZ (Marble Radius R).
> 
> The Marble runs on a track that consists of two small thin parallel wires. The
> Marble is running between them, because their distance is a little smaller than
> 2R.
> Like this:
> http://www.youtube.com/watch?v=me1D1WZ0yNM
> 
> Anyway. Let's say the Marble is on the track and rolling. Continuously I will
> have to calculate CX, CY, CZ during the animation.
> 
> The Marble is touching the left wire at point A (AX,AY,AZ) and the right wire at
> a point B (BX,BY,BZ).
> 
> Let's assume the wires go parallel towards Z. Thus AX would be a little smaller
> than BX and AY = BY (Height, the Marble is above the wires and has a higher
> Y-value) and AZ = BZ (depth).
> 
> C would then be:
> CX = (AX + BX) / 2 (in the middle between the wires)
> CY = AY + R - 0.3 (or so, depending on how deep the Marble is between the wires)
> CZ = AZ.
> 
> When the Marble rolls, the Z-values increase.
> 
> But the wires of course do curves and loopings and spirals and so on.
> 
> So the situation is always different and AX<>BX and AY<>BY and AZ<>BZ. So the
> calculation of C is more difficult.
> 
> I am looking for a general formular that would be the solution for
> CX=
> CY=
> CZ=
> 
> based on A and B.
> 
> The point C would always be in a right angle above the wires. Or, in a looping,
> inside the looping, under the wires. Where my maths fail me.
> 
> All help is appreciated.
> 
> 
> Thank you so much!
> 
> Chris
> 
> 
> P.S.
> I could write a lot more about this. Actually, it would be cooler to have a
> physics-engine that simulates the Marble-Position based on my wires but it has
> to be done via a formula for now.
> At the moment my problem is that the Marble is above the wires or is cutting
> through the wires which looks bad in my animation.
> 
> 

With
  W1 = vector point of wire 1
  W2 = vector point of wire 2
  Wr = radius of wires
  R  = radius of marble

  looking for: MCP = marble Center vector point

  Cp= (W1+W2)/2 , center point
  L=vlenght(Cp-W1);
  Cv= VPerp_To_Vector(Cp-W1), this when added to the Center point
                             is a Perpendicular line  between W1,W2
  H= sqrt(pow(Wr+R,2)-pow(L,2)) height along the Perpendicular line
                                   between W1,W2
  MCP=H*Cv+Cp; Done!

  If I understand your problem this should do it.

  The VPerp_To_Vector(Cp-W1) has the left handed right handed crap. So
if Cv is pointed in the wrong direction change (Cp-W1) to (W1-Cp)

Have fun!


Post a reply to this message

From: clipka
Subject: Re: Calculate 3D-Point based on two other
Date: 8 Mar 2011 18:44:49
Message: <4d76bf71$1@news.povray.org>
Am 08.03.2011 18:08, schrieb Chrisir:

> I am looking for a general formular that would be the solution for
> CX=
> CY=
> CZ=
>
> based on A and B.
>
> The point C would always be in a right angle above the wires. Or, in a looping,
> inside the looping, under the wires. Where my maths fail me.

Are you sure you're getting A and B right in the first place? It's not 
so trivial to get those from e.g. two splines. It might be easier to 
specify the marble's path, and from that calculate where the wires must run.


Post a reply to this message

From: Chrisir
Subject: Re: Calculate 3D-Point based on two other
Date: 14 Mar 2011 16:50:00
Message: <web.4d7e7f581434b3cb877585cf0@news.povray.org>
>
>   The VPerp_To_Vector(Cp-W1) has the left handed right handed crap. So
> if Cv is pointed in the wrong direction change (Cp-W1) to (W1-Cp)



Hello,

Thanks, this reply is just brillant.

It works perfect, but the marble is just under the wires.

the trick "change (Cp-W1) to (W1-Cp)" doesn't help.

Chrisir


Post a reply to this message

From: Chrisir
Subject: Re: Calculate 3D-Point based on two other
Date: 14 Mar 2011 16:55:01
Message: <web.4d7e804f1434b3cb877585cf0@news.povray.org>
Hello,

yes, that is just the way I work at the moment.

I lead the Marble on the right path and receive the A and B by this.

Due to some errors I couldn't resolve, my Marble-position went wrong.

At this moment I try desparate to retrieve my Marble-position based on A and B.

It is not always easy being me...

But you are right - in theory.

Chrisir


Post a reply to this message

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