Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / finding 2d points from a plane intersecting a 3d object

Author
Message
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 14th Aug 2009 02:27
I'm studying algebra2 right now, and in the book i'm using, it said something about basic graphing shapes being resembled by a plane intersecting two vertical cones, like this illustration:


A plane intersecting two vertical cones can resemble a circle, a hyperbole, a quadratic curve, and everything in between.

So... i'm trying to write a program (in dbpro), that you can move a plane around on the right side of the screen, and on the left side, it will show where the plane intersects the two vertical cones. Basically, i want to find a formula that will give you a series of 2d coordinates, given three points in 3d space (defining the plane), and the slope of the cone (the place where the two cones intersect is always at 0,0,0, and it is perpendicular to the x/z axes, just to simplify things).

x = 3d coordinate
y = 3d coordinate
z = 3d coordinate
x1/y1/z1 = a point defining the plane
x2/y2/z2 = a point defining the plane
x3/y3/z3 = a point defining the plane
a = the slope of the cone
x4/y4 = the final two 2d coordinates.

I figure that the formula for a cone should be pretty simple, so i wrote this down for my cone:

sqrt(x^2+z^2)<=ay

where a is the slope of the cone.

I looked up the formula for a plane (given three points in space), and found this:

bx + cy + dz + e = 0
b = y1 (z2 - z3) + y2 (z3 - z1) + y3 (z1 - z2)
c = z1 (x2 - x3) + z2 (x3 - x1) + z3 (x1 - x2)
d = x1 (y2 - y3) + x2 (y3 - y1) + x3 (y1 - y2)
- e = x1 (y2 z3 - y3 z2) + x2 (y3 z1 - y1 z3) + x3 (y1 z2 - y2 z1)

After this... i don't even know where to go. I figure that i would need to figure out how - given x and y 2d coordinates, and three points defining a plane - to get 3d coordinates. The thing is... i really don't know how to do this... any help?
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 14th Aug 2009 02:29
What level is that at? (GCSE/A/whatever)

Cranial explosion just trying to think of a potential use for that kind of maths.

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 14th Aug 2009 02:41 Edited at: 14th Aug 2009 02:46
Ahhhh. Conic sections! Fun fun fun. If I were you I would first attempt a 2D version, in other words instead of a 3D cone and plane, you would have a 2D cone (consisting of two opposing triangles) and a line, that represents the plane. The cone would still technically be 3D as far as the calculations would be concerned, but you wouldn't have to worry about the rotation of the plane--there would be one angle to deal with, not three.

NeX:

I'm pretty sure Neuro Fuzzy lives in the US. Here in Michigan this would be taught in Algebra II, usually taken in 9th or 10th grade. It might be different in Neuro Fuzzy's state.

i like orange
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 14th Aug 2009 03:25
thats algebra 2, gulp!

thats what im going into this year and im not sure im prepared for this......

Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 14th Aug 2009 04:32
naw, that's not an actual section in algebra 2.

AndrewT, i think i'll follow your advice.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 14th Aug 2009 09:59
I would cheat. But then I haven't studied maths since the class abacus broke.

I would get the plain in DBPro with your parameters, then do collision checks for the circumfrence of the cones, dunno if you could do both cones at once, but I'd get each collision and draw a line between collision points. I'm imagining the cones as a projected line spinning round and round like a disco laser, forming the 2 cones, put a post it note in the beam and your dancing - might not help in the classroom and would probably get you thrown out the disco for being weird.

This would at least show you what you should be getting from any formulas.


Health, Ammo, and bacon and eggs!
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 14th Aug 2009 11:39
Nobody's considered the truly important question yet: what possible use does this have, anywhere? It's a fairly impossible shape (I dare you to balance one cone atop another, point on point) and a fairly improbable operation.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 14th Aug 2009 14:17
I assumed this was so that he can generate the patterns, so the pattern itself is generated based on maybe just the 4 corner locations of the plain. For the patterns it can generate, it might be more straightforward to go for a system like that than to work with a few different techniques and ideas.

I would hope that this is not the sort of thing Neuro does just for fun, if it is then someone should take him paintballing or something .


Health, Ammo, and bacon and eggs!
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 14th Aug 2009 15:52
Quote: "Nobody's considered the truly important question yet: what possible use does this have, anywhere? It's a fairly impossible shape (I dare you to balance one cone atop another, point on point) and a fairly improbable operation."


The applications of conic sections are apparent in astronomy, aerodynamics, and architecture. However I think Neuro Fuzzy is doing this either to challenge himself, or for homework help.

i like orange
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 15th Aug 2009 06:35
Well... i figured it out for 2 dimensions. Basically, i figured out that a parametric representation of a line can turn a one dimensional value into two dimensions. IE...
x=(x2-x1)L+x1
y=(y2-y1)L+y1
(where (x1,y1) and (x2,y2) are the two points defining the line, and L is a value between 0 and 1)
I'm using the variable L for length instead of T for time.

AAaaand then, the equation for two vertical triangles...
x=a|y| where a is the slope of the triangles.

Solving for that gives two solutions for L:

L = (-x1+a*y1)/((x2-x1)-a(y2-y1))
L = (-x1-a*y1)/((x2-x1)+a(y2-y1))

I've tested it out, and it works great. When the line has a slope of a or -a, One solution for L works, and the other gives a divide by zero error. one problem is that when the slope of the line is a or -1, and the y intercept is 0 (meaning it's the same line), both tests for L give divide by zero errors.

I figure that a better way to take an iterative approach, meaning instead of solving for the two possible values of L, do something like:


So... basically, iterative is better in this case, and andrewT, thanks ALOT for the suggestion, i would have run into alot of problems trying to solve for each point individually (i'd get an infinite number of points ).

Quote: "I would hope that this is not the sort of thing Neuro does just for fun, if it is then someone should take him paintballing or something ."


Heheh, this is what i do after waterballooning cars, and before playing battlefield 2 XD

Also, something that really ticks me off is that i spent three years in school learning about curves that can be explained by two cones
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Aug 2009 00:31
The part I'm confused on is the series of intersecting points. Technically, there's an infinite number when the two objects intersect, so how do you determine a limit?

[url="http://dbcc.zimnox.com"][/url]
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 16th Aug 2009 08:36 Edited at: 16th Aug 2009 08:40
there are an infinite number of points when the two objects intersect, but there are (in this case) a max of two lines.

Well... I'm pretty sure I've solved it...
Here are what the variables are:

x1/y1/z1/x2/y2/z2/x3/y3/z3 - three vectors defining the plane. They should form three points of a square, or the end result would be skew.

a - The slope of the two cones

x/y/z - arbitrary points in space

xf/yf - the 2d points on the plane, these range from 0 to 1. <0,0> would mean the result is at point xyz2, <1,0> would result in a point at xyz1, and <0,1> would result in a point at xyz3.
First, here's the base equations I used (these are equations i came up with, so they may not be exactly standard):

equation for the cone:
x^2+z^2=a^2*y^2

parametric equation(s) for a plane:
x=(x3-x2)*xf+(x1-x2)*yf+x2
y=(y3-y2)*xf+(y1-y2)*yf+y2
z=(z3-z2)*xf+(z1-z2)*yf+z2

So... i want something in the form of f(xf)=yf. Solving for y, i inserted the parametric equations into the equation for a cone (YES i had to square three three parameter terms!), and was able to isolate the equation to a "0=ax^2+bx+c" equation (x being Yf, and of course a, b, and c being insanely long coefficients). Here is what that turned out (i'm using D, E, and F to tidy up the equation, otherwise it would be unreadable):

D = ((x1-x2)^2 + (z1-z2)^2 - a^2*(y1-y2)^2)

E = (2*xf*(x3-x2)*(x1-x2)+2*x2*(x1-x2)+2*xf*(z3-z2)(z1-z2)+2*z2*(z1-z2)-a^2*2*xf*(y3-y2)(y1-y2)-a^2*2*y2*(y1-y2))

F = ((x2)^2+(z2)^2-a^2*(y2)^2 + (xf)^2*(x3-x2)^2+(xf)^2*(z3-z2)^2-a^2*(xf)^2*(y3-y2)^2 + 2*x2*xf*(x3-x2)+2*z2*xf*(z3-z2)-a^2*y2*xf*(y3-y2)

yf = (-E +- sqrt(E^2-4*D*F))/(2*D)

So.... yeah...

It is my hope that if you define a plane parallel to the slope of the cone, you will get an equation that will simplify down to

yf=constant*xf^2

In theory, if i have done all the math right, that should be the case.

but i'm too tired to test it now... i'll get back to you laterz :S


also, this is what it looked like while i was working it out, so there may be mistakes (i triple checked each thing i did)


yf = (-(2*xf*(x3-x2)*(x1-x2)+2*x2*(x1-x2)+2*xf*(z3-z2)(z1-z2)+2*z2*(z1-z2)-a^2*2*xf*(y3-y2)(y1-y2)-a^2*2*y2*(y1-y2)) +- sqrt((2*xf*(x3-x2)*(x1-x2)+2*x2*(x1-x2)+2*xf*(z3-z2)(z1-z2)+2*z2*(z1-z2)-a^2*2*xf*(y3-y2)(y1-y2)-a^2*2*y2*(y1-y2))^2-4*((x1-x2)^2 + (z1-z2)^2 - a^2*(y1-y2)^2)*((x2)^2+(z2)^2-a^2*(y2)^2 + (xf)^2*(x3-x2)^2+(xf)^2*(z3-z2)^2-a^2*(xf)^2*(y3-y2)^2 + 2*x2*xf*(x3-x2)+2*z2*xf*(z3-z2)-a^2*y2*xf*(y3-y2))))/(2*((x1-x2)^2 + (z1-z2)^2 - a^2*(y1-y2)^2))
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 17th Aug 2009 07:23 Edited at: 17th Aug 2009 07:24
[NOTE] no more complicated math! Just a demo in this post!


Well... i think i got it right. I've coded the equation into DBPro. This is a vertical plane slicing through the cone:

(press up and down to move the plane)



As you can see... it produces odd results. I'm not sure if that's because i'm having trouble visualizing it, or it it's just flat out wrong. One wierd thing in that: When Z is at sqrt(3) or -sqrt(3), it shows as a line with a slope of A. That should only be happening at 0 though, by my prediction.

However, cutting through horizontally produced the exact results i expected. As the Y value goes to 0, a horizontal plane cutting through the origin, there is only a point. As it increases or decreases from there, it shows a larger and larger circle. Here's that code:



I think i've solved the equation, but i won't know for sure until i get a visual sim going.
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 17th Aug 2009 08:39
NOOOOOO!

Yeah, it's definitely not a cone. Try running this program:



that looks nothing like a cone. I must have mixed up two numbers somewhere! Blagh!
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 18th Aug 2009 05:19
I fixed it! I didn't copy a 2. instead of this:
F = (x2)^2+(z2)^2-a^2*(y2)^2 + (xf)^2*(x3-x2)^2+(xf)^2*(z3-z2)^2-a^2*(xf)^2*(y3-y2)^2 + 2*x2*xf*(x3-x2)+2*z2*xf*(z3-z2)-a^2*y2*xf*(y3-y2)

it should be this:

F = (x2)^2+(z2)^2-a^2*(y2)^2 + (xf)^2*(x3-x2)^2+(xf)^2*(z3-z2)^2-a^2*(xf)^2*(y3-y2)^2 + 2*x2*xf*(x3-x2)+2*z2*xf*(z3-z2)-a^2*2*y2*xf*(y3-y2)


...can you spot the mistake?

As long as the measure of angle <x1,y1,z1> <x2,y2,z2> <x3,y3,z3> is 90 degrees, and the distance from point 1 to point 2 is the same as from point 3 to point 2, the image displayed will be unwarped. Otherwise, it will be warped as if you had taken a parallelogram (or rectangle), and stretched/smushed it into the shape of a square.
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 15th Sep 2009 08:35
Sorry for the one month bump, but I've made a demo illustrating all the properties of this equation, with visual aid. Here are some screenies (scaled down loads)




You can move the plane around, and rotate the plane. Simply press x, y, or z to select that, and press the arrowkeys to change the x y or z angle. Hold shift and press the arrowkeys to move on that axis. Heres a way to get cool results immediately

1. Open the program
2. press y
3. hold shift and tap the up key
4. press x
5. hold the up key

You should be seeing the graph on the left go from circle, to ellipse, to parabola, to hyperbola, to two lines (kinda the 2d equivalent of a cone), back to hyperbola, back to parabola, back to ellipse, and finally back to circle. It really is cool to see the shapes morph into something else.

Here's the link to download the program (in a rar file)

http://www.mediafire.com/?sharekey=5ba704068f4cd5928ef1259ff1b60e81e04e75f6e8ebb871
Jeku
Moderator
20
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 15th Sep 2009 18:00
That's awesome


Senior Web Developer - Nokia
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 15th Sep 2009 20:01 Edited at: 15th Sep 2009 20:02
I don't know if you managed to completely solve drawing the curve(s), but here is one way:

I took the equation for a plane, and the equation for a double cone, and substituted one into the other.

plane: ax + by + cz + d = 0
double cone: (z^2)/(e^2) = x^2+y^2

'e' varies the slope of the double cone.

After multiplying out, I moved the (y^2) and (y) parts to one side, and factorised those parts.
I ended up with a quadratic equation to give the 'y' coordinate(s) given the 'x' coordinate:

A = (b^2-e^2)
B = (2axb+2bd)
C = (x^2)(a^2-e^2)+d^2+2axd

You can solve that easily with the quadratic formula.

To draw it to a bitmap, just iterate through every nth vertical line in the bitmap, and solve for that 'x' position. For each solution, check if that same solution existed for the previous vertical line. If it did, draw a line from the old coordinate for that solution to the new coordinate for that solution.

Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 16th Sep 2009 03:04
With what your doing there, your still working with the position in 3d space, just kinda ignoring the Z part of it. If you wanted to flatten that out, you'd have to rotate the 3d points on the plane back down to rotation 0,0,0, and then solve for it. You'd also have to come up with the values of a,b,c, and d.

These are the equations i used at the heart of it all:

x=(x1-x2)L1+(x3-x2)L2+x2
y=(y1-y2)L1+(y3-y2)L2+y2
z=(z1-z2)L1+(z3-z2)L2+z2
x^2+z^2=a^2y^2

When i worked it out in 2d (getting a line intersecting vertical triangles) i realized that with a parametric line, you input a one dimensional parameter, and you get out a two dimensional parameter. The values for x, y, and z are basically a parametric representation of a plane. As for the cone, our two equations only differ because in yours the plane is centered along the Z axis, and my slope of the cone is run/rise.

Solving for it, L1 and L2 will be the final x and y positions, so leave em alone, then solve for it so that the f(L1)=L2

The only problem with my way is that if vectors 1 and 3 aren't perpendicular (with vector 2 as the origin),then the shape will be warped like a parallelogram smushed into a square. (or a rectangle to a square if the lengths are different).

Login to post a reply

Server time is: 2024-05-08 18:29:04
Your offset time is: 2024-05-08 18:29:04