Ask Your Question
1

Path rendering on a Surface

asked 2020-11-18 12:59:27 -0600

Abbas Jaffary gravatar image

updated 2020-11-18 13:02:25 -0600

I am having a discrepancy with the z-coordinates of a path on a surface.

The blue path shown below is correctly embedded in the red surface.

The z-coordinates for the green path are "almost" correct. I have gone over the math dozens of times. I need to compute rational powers of cosine and sine. Wondering if it could be a rounding issue?

The surface is parametrized in polar coordinates.

The path is parametrized in rectangular coordinates. (This is because on the full surface this portion is shifted along the x-axis. I reparametrized it polar and it seems less accurate).

What I've done is:

  1. Specify the path as $(x(u), y(u))$
  2. Compute the radial distance to the point $r(u) = \sqrt{x^2 + y^2}$
  3. The path is then given by $(x(u), y(u), z(r(u))$

(I've used the parameter $v$ to give the paths some "thickness")

This works fine for blue, not for green.

The surface height grows linearly with the radius.

The blue path's radius decays linearly.

The green path's radius decays non-linearly. But, I don't think that should matter, as I'm simply getting a list of points and plugging them into the height function.

u, v = var('u, v')
right_curve_u = 8+(14/pi)*(u+pi/2) #8+(14/pi)*(phi+pi/2)
f_x(u, v) = v*cos(u)
f_y(u, v) = v*sin(u)
f_z(u, v) = (((v-16)/12)*(12*cos((pi/11)*(right_curve_u - 17)) + 39.5))/12
T=parametric_plot3d([f_x, f_y, f_z], (u, -pi/2, 0), (v, 16, 28), color="red", opacity=0.5, axes=True, mesh=False)
#c=parametric_plot3d([f_x, f_y, f_z], (u, -pi/2, pi/2), (v, 21.9, 22.1), color="black", mesh=True)
#c is the curve in the first example with constant radius

#Path Equation;  Note, "u" is the parameter for the path, "v" is to give it a bit of "thickness"
right_curve_u = 8+(14/pi)*(u+pi/2) #8+(14/pi)*(phi+pi/2)
right_curve_x(u,v) = v*(16*(cos(u))^(5/6))
right_curve_y(u,v) = v*(-28*(sin(-u))^(5/6))
#right_curve_path_radius(u,v) = v*(16*28)/(((28*cos(u))^(2.4)+(16*sin(-u))^2.4)^(5/12))
right_curve_path_radius(u,v) = sqrt((right_curve_x)^2+(right_curve_y)^2)
right_curve_path_radius_2(u,v) = v*sqrt((16^2)*(cos(u))^(5/3)+(28^2)*(sin(-u))^(5/3))

right_curve_z(u,v) = ( ( (right_curve_path_radius - 16)/12 ) * ( 12*cos( (pi/11)*(right_curve_u - 17) ) + 39.5 ) )/12
right_curve_z_2(u,v) = ( ( (right_curve_path_radius_2 - 16)/12 ) * ( 12*cos( (pi/11)*(right_curve_u - 17) ) + 39.5 ) )/12

right_curve = parametric_plot3d([right_curve_x, right_curve_y, right_curve_z], (u, -pi/2, -0.01), (v, 0.99, 1.01), color="black")
right_curve_2 = parametric_plot3d([right_curve_x, right_curve_y, right_curve_z_2], (u, -pi/2, -0.01), (v, 0.99, 1.01), color="green")

g_x(u, v) = v*(16-(12*(u-pi/2)/pi))*cos(u)
g_y(u, v) = v*(16-(12*(u-pi/2)/pi))*sin(u)
h(u) = v*(16 - (12/pi)*(u-pi/2))
g_z(u,v) = ( ( (h - 16)/12 ) * ( 12*cos( (pi/11)*(right_curve_u - 17) ) + 39.5 ) )/12
c_xy=parametric_plot3d([g_x, g_y, g_z], (u, -pi/2, 0), (v, 0.99, 1.01), color="blue")
T+c_xy+right_curve+right_curve_2
edit retag flag offensive close merge delete

Comments

1

rational quotients of python integers are not rational numbers. Beware of your "rational" powers

FrédéricC gravatar imageFrédéricC ( 2020-11-19 03:32:37 -0600 )edit

Thank you for pointing this out. I read https://stackoverflow.com/questions/6401167/how-do-i-pass-a-fraction-to-python-as-an-exponent-in-order-to-calculate-the-nth/6401264 (https://stackoverflow.com/questions/6...) and https://doc.sagemath.org/html/en/reference/rings_standard/sage/rings/rational.html (https://doc.sagemath.org/html/en/refe...), changed the exponents to floating point, but I get the same result.

Abbas Jaffary gravatar imageAbbas Jaffary ( 2020-11-19 16:25:00 -0600 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2020-11-19 04:57:28 -0600

FrédéricC gravatar image

You should be more careful about "expressions" and "functions".

An expression is something like this

var('u,v')
ex = u*cos(v)

A function is something like this

cool(u,v) = u+v

One possible way to go : use only functions, and call them with arguments always :

good(u, v) = cool(u, v) + u - v

Your "right_curve_u" is an expression. Make it a function.

edit flag offensive delete link more

Comments

Thank you -- fixed that (and above), still getting the same result. I reparametrized the path in polar coordinates as well, but I'm getting different values for r based on the rectangular --> polar conversion and the direct polar definition, for the same theta values. Curiously, the rectangular --> polar produces the closer z-coordinates.

Abbas Jaffary gravatar imageAbbas Jaffary ( 2020-11-19 22:37:35 -0600 )edit
1

Did you change all the definitions of functions that contain another function so that the inner function is called with its arguments ? This means : use f(x,y) = g(x,y) + x + y and not f(x,y) = g + x + y.

FrédéricC gravatar imageFrédéricC ( 2020-11-20 01:14:06 -0600 )edit

Yes, same result.

Abbas Jaffary gravatar imageAbbas Jaffary ( 2020-11-20 09:50:39 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-11-18 12:59:27 -0600

Seen: 61 times

Last updated: Nov 19