Author Topic: Faces  (Read 7022 times)

0 Members and 1 Guest are viewing this topic.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Faces
« Reply #60 on: June 18, 2011, 04:59:07 PM »
Here's what I have:


Code: [Select]
-- for a plane defined by coordinates (Px1, Py1, Pz1), (Px2, Py2, Pz2), and (Px3, Py3, Pz3)
-- and a line defined by coordinates (Lx1, Ly1, Lz1), (Lx2, Ly2, Lz2)
-- find the X, Y, and Z coordinates at which they intersect

-- first get 2 vectors along the plane
-- ("PV1x" stands for Plane Vector #1, X-coordinate)

PV1x = Px2 - Px1
PV1y = Py2 - Py1
PV1z = Pz2 - Pz1

PV2x = Px3 - Px1
PV2y = Py3 - Py1
PV2z = Pz3 - Pz1

-- now find the cross product
-- PV1 X PV2 = normal vector!

i = (PV1y * PV2z) - (PV1z * PV2y)
j = (PV1z * PV2x) - (PV1x * PV2z)
k = (PV1x * PV2y) - (PV1y * PV2x)


-- define d
planex = i
planey = j
planek = k
d = (i * PV1x) + (j * PV1y) + (k * PV1z)



-- for the line, calculate tx, ty, tz
tx = Lx2 - Lx1
ty = Ly2 - Ly1
tz = Lz2 - Lz1


-- calculate t

t = (i * (tx + PV1x)) + (j * (ty + PV1y)) + (k * (tz + PV1z))


-- calculate intersection coordinates
intersectX = t * tx
intersectY = t * ty
intersectZ = t * tz


It doesn't work perfectly.  There's something wrong.  But what..? :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Faces
« Reply #61 on: June 18, 2011, 05:07:57 PM »
Sudden crash for me D:

Edit: If it is dependand of dividing with camerax or y then that mi9ght be it... I got no real idea, but not recreateable :/
« Last Edit: June 18, 2011, 05:11:00 PM by Aino »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Faces
« Reply #62 on: June 18, 2011, 05:12:35 PM »
Fixed it, I think.  I was calculating "t" using the normal vector instead of the vertex coordinate.  :P  And I needed to subtract "d".


annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Faces
« Reply #63 on: June 18, 2011, 05:14:12 PM »
Oh, wait.. no...  it's still broken. :<

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Faces
« Reply #64 on: June 18, 2011, 05:14:57 PM »
Talking stuff that I don't have much idea of... By the way annikk; what is "t" for you?

Just asking, I have a sense that it might mean temporarily

And what is the problem, I don't see any... or is it that the lines ain't disapearing?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Faces
« Reply #65 on: June 19, 2011, 01:18:48 AM »
It's "t" from the parametric equation of a line.  It's a maths convention that I just copied for the variable name.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Faces
« Reply #66 on: June 20, 2011, 01:42:45 PM »
No further forward with this..

I'm having a lot of difficulty translating this from maths into code.
A lot of the programming examples out there use facilities available in the language in which they are written to represent things like vectors, and there are shortcut commands such as cross() for the cross product...  the rest all seem to be written in complex mathematical notation, or substitute in coordinates at some point in order to solve something.  Argh...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: Faces
« Reply #67 on: June 20, 2011, 03:32:15 PM »
What?!

The great Annikk can't be in vain D:

Well, I'm no good at that, so I'm to no help yet again -.-'

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Faces
« Reply #68 on: June 20, 2011, 04:45:08 PM »
Hmm, for the "great Annikk" standing on the shoulders of giants is one thing, balancing is another...

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 77
  • -Receive: 8
  • Posts: 629
  • Was born, still alive.
    • German Mac Mailing Lists
  • Eufloria: Yes
Re: Faces
« Reply #69 on: June 20, 2011, 05:55:27 PM »
Youze folks are a luvable bunch!

Just sayin’.
Google+
Do you play Go? (aka iGo aka Baduk aka Weiqi)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Faces
« Reply #70 on: June 21, 2011, 12:07:43 AM »
With some help, I have identified a possible algebra problem.


I have this:

Code: [Select]
0 = (i * ((t * tx) + Lx1) - Px1)) + (j * ((t * ty) + Ly1) - Py1)) + (k * ((t * tz) + Lz1) - Pz1))
t is the unknown, and the value i need to calculate.  The equation has to be reshuffled to have t on the left side, and all the other terms on the right side.

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 77
  • -Receive: 8
  • Posts: 629
  • Was born, still alive.
    • German Mac Mailing Lists
  • Eufloria: Yes
Re: Faces
« Reply #71 on: June 21, 2011, 12:36:05 AM »
I can’t do such things, but I know that something’s wrong with your parentheses here. Two or three closing ones too many.
Google+
Do you play Go? (aka iGo aka Baduk aka Weiqi)

Sniped50

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 97
  • Don't ask. About anything.
Re: Faces
« Reply #72 on: June 21, 2011, 08:44:31 AM »
My advice would be (don't know if this would work) splitting the equation into three equal parts (so they contain 1 t each), then working out t = ? for each of them. Once you've done that, I think you can just add them together so you get 3t = ? + ? + ?, and then just divide by 3, t = (? + ? + ?)/3.

Would that work, Annikk?

PS: Bonobo is right. You do actually have too many closing parentheses. By my count, 9 opening ones and 12 closing ones.
"Sometimes, the simplest solutions work the best."
- Mythbusters

"But the complex solutions look prettier."
- Me

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Faces
« Reply #73 on: June 21, 2011, 10:26:14 AM »
Ah, well-spotted.  It should be like this, I think:


Code: [Select]
0 = (i * (((t * tx) + Lx1) - Px1)) + (j * (((t * ty) + Ly1) - Py1)) + (k * (((t * tz) + Lz1) - Pz1))

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Faces
« Reply #74 on: June 21, 2011, 12:55:22 PM »
Code: [Select]
t = ((i * (Px1 - Lx1)) + (j * (Py1 - Ly1)) + (k * (Pz1 - Lz1))) / ((i * (Lx2 - Lx1)) + (j * (Ly2 - Ly1)) + (k * (Lz2 - Lz1)))

Perhaps this?
« Last Edit: June 21, 2011, 01:14:46 PM by annikk.exe »