Author Message
ufoace

Joined: 11 Mar 2013
Posts: 46

 Posted: Wed Mar 20, 2013 10:26 am    Post subject: how to displace a slanted cylinder? Hello everyone! i learnt alot from this forum and thanks to everyone that posts on it! I am making tunnels in a game and there there is a difficulty: what is the formula for a cylinder runnng along vector(3,1,2) and passing through point (1,1,1)? A cylinder isosurface formula is: (x)^2 + (y)^2 +1 = 0 If you want to move the cylinder 1 higher on the Y axis you would do: (x)^2 +(y+1)^2 +1 = 0 It gets very complicated with any cylinder which isn't axis aligned, a slanted cylinder: Firstly, you have a vector that the cylinders travelling along, for example vA=(3, 1, 2) To make the cylinder, you have to define a new system of axes similar to X, Y, Z , you discover 2 vectors at right angles to each other and to the 1st one, and use these 2 instead of X and Y: vB^2 + vC^2 +1 = 0 So it is very confusing to place the cylinder in space because I am using different vectors to XYZ : vA vB vC... Question: if I want this slanted cylinder to intersect point P: = (1,1,1), then how do I interpolate where that is in XYZ space using the new, rotated XYZ axes called vA vB vC? This is how I discover the new axes to make a slanted cylinder: v3A(3,1,2) .normalised= ( 0.802, 0.267, 0.534) v3B = (0.802, -0.534, 0.267) ...a right angle of Vector3A v3C = (0.516645, 0.214134, -0.883002) ... dot product of V3A and V3B THANKYOU !
Furan

Joined: 05 Oct 2010
Posts: 64
Location: Prague, Czech Republic

 Posted: Wed Mar 20, 2013 11:38 pm    Post subject: Always nice to see people interested in analytical geometry Your v3B is not orthogonal to v3A. To switch and change sign works in 2D only. In this case these vectors are orthogonal only from the top view. It gets a little bit more complicated: vector k=(0,0,1) vector vA3 = (3,1,2) vector vB3 = cross product (k; vA3) vector vC3 = cross product (vA3; vB3) normalize vectors vA3,vB3,vC3 -> va3,vb3,vc3 Axis of a cylinder X = va3_1*t + A1 Y = va3_2*t + A2 Z = va3_3*t + A3 A = [1,1,1] Cylinder shell of radius R in parametric form: X = va3_1*t + A1 + R*vb3_1*sin(phi) + R*vc3_1*cos(phi) Y = va3_2*t + A2 + R*vb3_2*sin(phi) + R*vc3_2*cos(phi) Z = va3_3*t + A3 + R*vb3_3*sin(phi) + R*vc3_3*cos(phi) Hope this works
Furan

Joined: 05 Oct 2010
Posts: 64
Location: Prague, Czech Republic

 Posted: Wed Mar 20, 2013 11:57 pm    Post subject: If you're looking for an isosurface, it gets a lot more complicated: F = distance(x,y,z) - R = 0 function distance() calculates the distance of point [x,y,z] from its closest point on the cylinder axis. To find that point, we create a plane orthogonal to the cylinder axis: (X-x)*va3_1 + (Y-y)*va3_2 + (Z-z)*va3_3 =0 for X,Y and Z we insert the cylinder axis equations and express the position on the axis t: t = (va3_1*(x-A1) + va3_2*(y-A2) + va3_3*(z-A3)) / (va3_1^2 + va3_2^2 + va3_3^2) and use it back in the axis equation to finaly get this: distance(x,y,z) = sqrt((X(t)-x)^2 + (Y(t)-y)^2 + (Z(t)-z)^2) Again, I did not tested it, hope it works
Furan

Joined: 05 Oct 2010
Posts: 64
Location: Prague, Czech Republic

 Posted: Thu Mar 21, 2013 12:02 am    Post subject: Btw, feel free to include this answer here http://math.stackexchange.com/questions/335051/arbitrary-axis-translation-how-to-translate-a-slanted-cylinder-isosurface-geom or in any other forum. Thanks.
ufoace

Joined: 11 Mar 2013
Posts: 46

 Posted: Thu Mar 21, 2013 8:26 am    Post subject: Thank you so much for posting that answer! I was so happy, if I had some beer and confetti and some musicians at my house I would have had a celebration! The idea of checking the distance from the cylinder's intended position in space is brilliant because it gives me a 1st orthogonal axis of the cylinder that is also one direct vector to translate the cylinder to the final position. i can use the distance vector in the equation and also translate the cylinder along that vector by adding a value to it. Essentially you would have apprehended where the target of the cylinder would go, and then you would predict the movement that the cylinder has to take to apprehend the target? for some reason it makes me think of my cousin's girlfriend chasing him around the table which is also cylindrical and also very funny. she is reeely nice. then the equation: x*x + y*y + r = 0 can be written as: (distance_vector + distance)^2 + (distance_tangent_vector+0)^2 +r = 0 I will see both approaches. Thank you
abdelhamid belaid

Joined: 13 Aug 2009
Posts: 170

Posted: Sun Mar 31, 2013 8:50 pm    Post subject:

Hi all,
Next to Furan's beautiful work, for an isosurface, this is my attempt:
for v=(vx ,vy, vz) and M(a, b ,c) we have this equation for a slanted cylinder which is running along the vector v with a radius R:
 Code: (z*cos(T)-(x*cos(P)+y*sin(P))*sin(T))^2+(y*cos(P)-x*sin(P))^2-R^2 =0 such that T=atan2(vy , vx)   and  P=atan2(vz , sqrt(vx^2+vy^2))

to get one contains the point M we would write:
 Code: (z*cos(T)-(x*cos(P)+y*sin(P))*sin(T))^2+(y*cos(P)-x*sin(P))^2-( (c*cos(T)-(a*cos(P)+b*sin(P))*sin(T))^2+(b*cos(P)-a*sin(P))^2 ) =0

I mean R^2=( (c*cos(T)-(a*cos(P)+b*sin(P))*sin(T))^2+(b*cos(P)-a*sin(P))^2 ) ( M coordinates satisfy our slanted cylinder equation )

for example, a slanted cylinder pass through the point M(2,1,1) and let's say T=pi/3 and P=pi/5 :
 Code: (z*cos(pi/3)-(x*cos(pi/5)+y*sin(pi/5))*sin(pi/3))^2+(y*cos(pi/5)-x*sin(pi/5))^2- ( (1*cos(pi/3)-(2*cos(pi/5)+1*sin(pi/5))*sin(pi/3))^2+(1*cos(pi/5)-2*sin(pi/5))^2 )

_________________
My YouTube channel
ufoace

Joined: 11 Mar 2013
Posts: 46

Posted: Sun Apr 07, 2013 12:38 pm    Post subject:

abdelhamid belaid wrote:
Hi all,

to get one contains the point M we would write:
 Code: (z*cos(T)-(x*cos(P)+y*sin(P))*sin(T))^2+(y*cos(P)-x*sin(P))^2-( (c*cos(T)-(a*cos(P)+b*sin(P))*sin(T))^2+(b*cos(P)-a*sin(P))^2 ) =0

I mean R^2=( (c*cos(T)-(a*cos(P)+b*sin(P))*sin(T))^2+(b*cos(P)-a*sin(P))^2 ) ( M coordinates satisfy our slanted cylinder equation )

Oh Wow thankyou that is a very versatile formula i will see what i can find with it. tubes are a cool building block for many forms, it's cool to join then into shapes. i was making some tunnel networks with them and walking around!
ufoace

Joined: 11 Mar 2013
Posts: 46

Posted: Sun Apr 07, 2013 12:39 pm    Post subject:

abdelhamid belaid wrote:
Hi all,

to get one contains the point M we would write:
 Code: (z*cos(T)-(x*cos(P)+y*sin(P))*sin(T))^2+(y*cos(P)-x*sin(P))^2-( (c*cos(T)-(a*cos(P)+b*sin(P))*sin(T))^2+(b*cos(P)-a*sin(P))^2 ) =0

I mean R^2=( (c*cos(T)-(a*cos(P)+b*sin(P))*sin(T))^2+(b*cos(P)-a*sin(P))^2 ) ( M coordinates satisfy our slanted cylinder equation )

Oh Wow thankyou that is a very versatile formula i will see what i can find with it. tubes are a cool building block for many forms, it's cool to join then into shapes. i was making some tunnel networks hopefully for a game!
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT Page 1 of 1

 Jump to: Select a forum MathMod----------------MathMod Progress & featuresMathematical Models CollectionHow toBugsMathMod for WindowsMathMod for Linux/UnixMathMod For MACOSXMathMod TutorialsOther Mathematical ToolsOpen Discussion K3DSurf----------------K3DSurf Discuss/DiscussionsHow toK3DSurf math related questionsK3DSurf for WindowsK3DSurf for MacOSK3DSurf for LinuxOnline K3DSurf: J3DSurfNewsBugsOnline DocumentationAccount Activation Issue ?/ Problème d'activation de votre compte ?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

2005 Powered by phpBB © 2001, 2005 phpBB Group

Start Your Own Video Sharing Site

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com