janhardo

695 Reputation

12 Badges

11 years, 37 days

MaplePrimes Activity


These are replies submitted by janhardo

Thanks, I did not know this plot command. 
There is also a 3d version of it, but let's see how to use it.
The idea of the procedure is to use a plane in various positions to create a intersection with solids.
Started with a cylinder.

@Carl Love 
Can determine from an existing procedure its "level", but what it's relation to a printlevel? 

 

myProcedure := proc()
    local currentDepth,  innerProcedure;
    currentDepth := kernelopts(level);
    printf("Current evaluation depth: %d\n", currentDepth);
    
    # Nested procedure to demonstrate depth change
    innerProcedure := proc()
        local innerDepth;
        innerDepth := kernelopts(level);
        printf("Inner procedure evaluation depth: %d\n", innerDepth);
    end proc;
    
    innerProcedure(); # Call the nested procedure
end proc:

# Call the main procedure
myProcedure();

Current evaluation depth: 23
Inner procedure evaluation depth: 44

 

Simple debugging handling for a procedure
trace ? for this example. 

printlevel:= 1;

1

(1)

printlevel:= 10;

10

(2)

check_printlevel = kernelopts('printlevel');

check_printlevel = 10

(3)

printlevel:= 1;

1

(4)

 

 

restart

max_eigenwaarde := proc(a::matrix)
  local eigenwaarden, max_eigenw, i;
  eigenwaarden := linalg[eigenvals](a);
  max_eigenw := eigenwaarden[1];
  for i from 2 to nops(eigenwaarden) do
     if max_eigenw < eigenwaarden[i] then
     max_eigenw := eigenwaarden[i];
     end if;
  end do ;
max_eigenw;
end proc:

 

A:=linalg[matrix](2,2,[[1,2],[0,3]]);

array( 1 .. 2, 1 .. 2, [( 2, 1 ) = (0), ( 2, 2 ) = (3), ( 1, 1 ) = (1), ( 1, 2 ) = (2)  ] )

(5)

max_eigenwaarde(A);

Error, (in max_eigenwaarde) invalid input: nops expects 1 argument, but received 2

 

 

trace

(6)

tracelast; #### see line number 3, detected error

 max_eigenwaarde called with arguments: A
 #(max_eigenwaarde,3): for i from 2 to nops(eigenwaarden) do ... end do;

 

Error, (in max_eigenwaarde) invalid input: nops expects 1 argument, but received 2

 

 locals defined as: eigenwaarden = (1, 3), max_eigenw = 1, i = i

 

showstat(max_eigenwaarde);


max_eigenwaarde := proc(a::matrix)
local eigenwaarden, max_eigenw, i;
   1   eigenwaarden := linalg[eigenvals](a);
   2   max_eigenw := eigenwaarden[1];
   3   for i from 2 to nops(eigenwaarden) do
   4       if max_eigenw < eigenwaarden[i] then
   5           max_eigenw := eigenwaarden[i]
           end if
       end do;
   6   max_eigenw
end proc
 

 

other approach

debug(max_eigenwaarde): max_eigenwaarde(A);

{--> enter max_eigenwaarde, args = A

 

1, 3

 

1

 

<-- ERROR in max_eigenwaarde (now at top level) = invalid input: %1 expects %2 argument, but received %3, nops, 1, 2}

 

Error, (in max_eigenwaarde) invalid input: nops expects 1 argument, but received 2

 

undebug(max_eigenwaarde):

Information by a higher value of printlevel: 10

printlevel:= 10:

max_eigenwaarde(A);

{--> enter \`type/matrix\`, args = A

 

[1 .. 2, 1 .. 2]

 

<-- exit \`type/matrix\` (now at top level) = true}

 

{--> enter max_eigenwaarde, args = A

 

{--> enter linalg:-eigenvals, args = A

 

2

 

array( 1 .. 2, 1 .. 2, [( 2, 1 ) = (0), ( 2, 2 ) = (-3+lambda), ( 1, 1 ) = (-1+lambda), ( 1, 2 ) = (-2)  ] )

 

(-1+lambda)*(-3+lambda)

 

[1, 3]

 

1, 3

 

<-- exit linalg:-eigenvals (now in max_eigenwaarde) = 1, 3}

 

1, 3

 

1

 

<-- ERROR in max_eigenwaarde (now at top level) = invalid input: %1 expects %2 argument, but received %3, nops, 1, 2}

 

 max_eigenwaarde called with arguments: A
 #(max_eigenwaarde,3): for i from 2 to nops(eigenwaarden) do ... end do;

 

Error, (in max_eigenwaarde) invalid input: nops expects 1 argument, but received 2

 

 locals defined as: eigenwaarden = (1, 3), max_eigenw = 1, i = i

 

printlevel:= 1 ;

1

(7)

trace ?

restart;

max_eigenwaarde := proc(a::matrix)
#option trace;  
local eigenwaarden, max_eigenw, i;
  eigenwaarden := linalg[eigenvals](a);
  max_eigenw := eigenwaarden[1];
  for i from 2 to nops(eigenwaarden) do
     if max_eigenw < eigenwaarden[i] then
     max_eigenw := eigenwaarden[i];
     end if;
  end do ;
max_eigenw;
end proc:

 

A:=linalg[matrix](2,2,[[1,2],[0,3]]);

array( 1 .. 2, 1 .. 2, [( 2, 1 ) = (0), ( 2, 2 ) = (3), ( 1, 1 ) = (1), ( 1, 2 ) = (2)  ] )

(8)

max_eigenwaarde(A);

Error, (in max_eigenwaarde) invalid input: nops expects 1 argument, but received 2

 

trace(max_eigenwaarde);#printlevel : 1

max_eigenwaarde

(9)

 

restart;

check_printlevel = kernelopts('printlevel');

check_printlevel = 1

(10)

printlevel:= 3;

3

(11)

max_eigenwaarde := proc(a::matrix)
#option trace;  
local eigenwaarden, max_eigenw, i;
  eigenwaarden := linalg[eigenvals](a);
  max_eigenw := eigenwaarden[1];
  for i from 2 to nops(eigenwaarden) do
     if max_eigenw < eigenwaarden[i] then
     max_eigenw := eigenwaarden[i];
     end if;
  end do ;
max_eigenw;
end proc:

 

A:=linalg[matrix](2,2,[[1,2],[0,3]]);

array( 1 .. 2, 1 .. 2, [( 2, 2 ) = (3), ( 2, 1 ) = (0), ( 1, 2 ) = (2), ( 1, 1 ) = (1)  ] )

(12)

max_eigenwaarde(A);

 max_eigenwaarde called with arguments: A
 #(max_eigenwaarde,3): for i from 2 to nops(eigenwaarden) do ... end do;

 

Error, (in max_eigenwaarde) invalid input: nops expects 1 argument, but received 2

 

 locals defined as: eigenwaarden = (1, 3), max_eigenw = 1, i = i

 

trace(max_eigenwaarde);# ?

max_eigenwaarde

(13)
 

 

Download vooorbeeld_voor_mapleprimes_post_debuhgging.mw

procedure 

@mmcdara 
Thanks, if the procedure contains : loop or if statement : printlevel : +1
For each procedure call : printlevel : +5, that is for recursion programming, so each iteration for that requires a procedure call. 

@janhardo 

The printlevel depends on the complexity of the procedure. 

@mmcdara 

Thanks, saw it today the kernel opts with printlevel.

Seemed convenient if a procedure has a printlevel as input and after executing the procedure sets the printlevel back to a default value.

Yes, trace and tracelast with printlevel would be the simplest tools for error detection. 
Tracelast shows the last result of the procedure, but stops when an error is detected and trace also shows this error by the looks of it.
To use tracelast effectively the printlevel must be set to 3

@dharr 
Thanks, that's how it was : the error message gave enough information, but didn't do anything with it.  

@dharr 

Thanks, am relieved that is solved as did not get there properly.
Forgot that the last statement in the procedure shows an outcome.
Should have studied better the structure of input variables of complexplot3d command compared to plot3d command.
Did get some procedures for a complex3dplot working quickly, but that just didn't include further plot options .

Had gotten a plot, I could have concluded ( in retrospect) that 
view=plotview.. tricky ..is it documented?

 

restart;

complex_surface := proc(f, z_range::range(complex))
    
    printf("Complex function f(z) defined.\n");
    printf("Range of z values: %a\n", z_range);
    
    # Plot de complexe functie met complexplot3d
    printf("Plotting complex function...\n");
    print(plots:-complexplot3d(f, z_range, view=[-50..50, -5..5, 0..5], grid=[50,50]));
    
    printf("Plot generated.\n");
    
end proc:

# Definieer de complexe functie f(z) = ln(z)
f := z -> ln(z);

# Definieer het bereik van z-waarden voor de plot
z_range := -50-5*I .. 50+5*I;

# Roep de procedure aan om de plot te genereren
complex_surface(f, z_range);

 

Trying to make this procedure: complex_surface for complex3dplot input suitable for view, orientatation and grid plot options , but do not succeed me yet.
Also showing the plot via print seems strange?
What is going wrong here?

restart;

complex_surface := proc(f, z_range::range(complex), view::list)
    
    printf("Complex function f(z) defined.\n");
    printf("Range of z values: %a\n", z_range);
    
    # Plot de complexe functie met complexplot3d
    printf("Plotting complex function...\n");
    display(plots:-complexplot3d(f, z_range, view = view, grid = [50, 50]));
    
    printf("Plot generated.\n");
    
end proc:

# Definieer de complexe functie f(z) = ln(z)
f := z -> ln(z);

# Definieer het bereik van z-waarden voor de plot
z_range := -50-5*I .. 50+5*I;

# Roep de procedure aan om de plot te genereren
complex_surface(f, z_range, [-50..50, -5..5, 0..5]);

     f := proc (z) options operator, arrow; ln(z) end proc

                z_range := -50 - 5 I .. 50 + 5 I

Complex function f(z) defined.
Range of z values: -50-5*I .. 50+5*I
Plotting complex function...

Error, (in plot3d) unexpected option: [-50 .. 50, -5 .. 5, 0 .. 5] = [-50 .. 50, -5 .. 5, 0 .. 5]

 

@dharr 
Thanks, looks much better your plot

@janhardo 

Both procedures give the same result.
Procedure 2 is not yet as solid as procedure 1 and ease of use, so some adjustments to be made.



ImplicitPlot3D_withCurveProjection(x^2 + y^2 - z, 0, -1.5..1.5, -1.5..1.5, -2..2, t -> cos(t), t -> sin(t), t ->0, 0..2*Pi, 30);



More convenient is to leave the current procedure 1 and start with a new procedure 2 for implicitplot3D surfaces

this new second procedure :
The procedure still lacks
- a size and orientation in the input
- control on procedure input of x,y,z via equation
- control on special function value output 
- the line integral notation with its value 
- the equation of the space curve 
- the output value of the procedure ( length of the projection curve )
 

restart;

ImplicitPlot3D_withCurveProjection := proc(f, n, x_range, y_range, z_range, x_t, y_t, z_t, t_range, num_vertical_lines)
    local implicit_function, plot_result, space_curve, projection_curve, combined_plot, is_closed, projection_curve_length, space_curve_length, solve_z, t_values, t_increment, points, i, t, t_increment_vert, vertical_lines, x_val, y_val, z_val_space, z_val_projection;
    uses plots, plottools, Student[Calculus1];

    # Basic check on the correct number of arguments and their types
    if nargs <> 10 or not type(f, algebraic) or not type(n, numeric) or
       not type(x_range, range) or not type(y_range, range) or not type(z_range, range) or
       not type(x_t, procedure) or not type(y_t, procedure) or not type(z_t, procedure) or
       not type(t_range, range) or not type(num_vertical_lines, posint) then
        error "Error: Incorrect input. Ensure all parameters are correctly typed and provided in the following order: ImplicitPlot3D_withCurveProjection_withPoints(f, n, x_range, y_range, z_range, x_t, y_t, z_t, t_range, num_vertical_lines). Each parameter must match its expected type and range.";
    end if;

    # Create the implicit expression
    implicit_function := f = n;

    # Generate the 3D plot of the implicit surface
    plot_result := implicitplot3d(implicit_function, x = x_range, y = y_range, z = z_range, axes = boxed, grid = [30,30,30], style = surface, title = sprintf("Implicit plot of %a = %a with space curve and its vertical projection", f, n));

    # Define the parametric space curve
    space_curve := spacecurve([x_t(t), y_t(t), z_t(t)], t = t_range, color = "red", thickness = 2);

    # Solve the surface equation for z if possible
    solve_z := solve(f = n, z);

    # Define the projection curve on the surface, vertical projection to z solved from surface equation
    projection_curve := spacecurve([x_t(t), y_t(t), eval(solve_z, {x = x_t(t), y = y_t(t)})], t = t_range, color = "blue", thickness = 2, linestyle = 2);

    # Check if the curve is closed
    is_closed := evalb(x_t(op(1, t_range)) = x_t(op(2, t_range)) and y_t(op(1, t_range)) = y_t(op(2, t_range)));

    # Calculate the length of the projection curve
    projection_curve_length := evalf(Int(sqrt(diff(x_t(t), t)^2 + diff(y_t(t), t)^2 + (diff(eval(solve_z, {x = x_t(t), y = y_t(t)}), t))^2), t = t_range));

    # Calculate the length of the space curve
    space_curve_length := evalf(Int(sqrt(diff(x_t(t), t)^2 + diff(y_t(t), t)^2 + diff(z_t(t), t)^2), t = t_range));

    # Calculate t values for points
    t_values := [seq(op(1, t_range) + i * (op(2, t_range) - op(1, t_range)) / num_vertical_lines, i = 0 .. num_vertical_lines)];

    # Calculate the increment for t values
    t_increment := (op(2, t_range) - op(1, t_range)) / num_vertical_lines;

    # Calculate points on the space curve
    points := [seq([eval(x_t(t_values[i])), eval(y_t(t_values[i])), eval(z_t(t_values[i]))], i = 1..num_vertical_lines)];

    # Calculate the increment for vertical t values
    t_increment_vert := (op(2, t_range) - op(1, t_range)) / num_vertical_lines;

    # Plot vertical lines from space curve to projection curve
    vertical_lines := [];
    for i from 0 to num_vertical_lines-1 do
        x_val := eval(x_t(op(1, t_range) + i * t_increment_vert));
        y_val := eval(y_t(op(1, t_range) + i * t_increment_vert));
        z_val_space := eval(z_t(op(1, t_range) + i * t_increment_vert));
        z_val_projection := eval(solve_z, {x = x_val, y = y_val});
        vertical_lines := [op(vertical_lines), plottools:-line([x_val, y_val, z_val_space], [x_val, y_val, z_val_projection], color = "green")];
    end do;

    # Combine both plots, space curve, projection curve, and vertical lines
      combined_plot := display({plot_result, space_curve, projection_curve, seq(vertical_lines[i], i = 1..num_vertical_lines)}, axes = boxed);



    # Print the combined plot
    print(combined_plot);

    # Print whether the curve is closed or not
    if is_closed then
        printf("The space curve is closed.\n");
    else
        printf("The space curve is not closed.\n");
    end if;

    # Print the length of the projection curve
    printf("Length of the projection curve (vertical green lines from spacecurve): %a\n", projection_curve_length);

    # Print the length of the space curve
    printf("Length of the space curve: %a\n", space_curve_length);

    # Provide detailed information on how to use the procedure correctly after execution
    printf("Procedure successfully executed. To correctly use this procedure, provide parameters in the following order and format:\n\n");
    printf("f: Algebraic expression for the implicit equation. Example: x^2 + y^2 - 1\n");
    printf("n: Numeric value that the implicit equation equals to. Example: 0\n");
    printf("x_range, y_range, z_range: Valid ranges for x, y, and z coordinates. Example for x and y: -1.5..1.5, and for z: -2..2\n");
    printf("x_t, y_t, z_t: Parametric expressions for the space curve as functions of t. Example: x_t: t -> cos(t), y_t: t -> sin(t), z_t: t -> 0\n");
    printf("t_range: Range for the parameter t. Example: 0..2*Pi\n");
    printf("num_vertical_lines: Number of vertical lines to be plotted.\n");
    printf("Complete example call: ImplicitPlot3D_withCurveProjection_withPoints(x^2 + y^2 - 1, 0, -1.5..1.5, -1.5..1.5, -2..2, t -> cos(t), t -> sin(t), t -> 0, 0..2*Pi, 5)\n");
end proc:

# Voorbeeldaanroep
ImplicitPlot3D_withCurveProjection(x + y + z, 0, -10.5..10.5, -10.5..10.5, -20..20, t -> t, t -> 3*cos(t), t -> 3*sin(t), 0..1*Pi, 5);

 

The space curve is not closed.
Length of the projection curve (vertical green lines from spacecurve): 7.907090108
Length of the space curve: 9.934588266
Procedure successfully executed. To correctly use this procedure, provide parameters in the following order and format:

f: Algebraic expression for the implicit equation. Example: x^2 + y^2 - 1
n: Numeric value that the implicit equation equals to. Example: 0
x_range, y_range, z_range: Valid ranges for x, y, and z coordinates. Example for x and y: -1.5..1.5, and for z: -2..2
x_t, y_t, z_t: Parametric expressions for the space curve as functions of t. Example: x_t: t -> cos(t), y_t: t -> sin(t), z_t: t -> 0
t_range: Range for the parameter t. Example: 0..2*Pi
num_vertical_lines: Number of vertical lines to be plotted.
Complete example call: ImplicitPlot3D_withCurveProjection_withPoints(x^2 + y^2 - 1, 0, -1.5..1.5, -1.5..1.5, -2..2, t -> cos(t), t -> sin(t), t -> 0, 0..2*Pi, 5)

 

ImplicitPlot3D_withCurveProjection(x + y + z, 0, -10.5..10.5, -10.5..10.5, -20..20, t -> cos(t), t -> sin(t), t -> 0, 0..2*Pi,8);

 

The space curve is closed.
Length of the projection curve (vertical green lines from spacecurve): 8.737752571
Length of the space curve: 6.283185307
Procedure successfully executed. To correctly use this procedure, provide parameters in the following order and format:

f: Algebraic expression for the implicit equation. Example: x^2 + y^2 - 1
n: Numeric value that the implicit equation equals to. Example: 0
x_range, y_range, z_range: Valid ranges for x, y, and z coordinates. Example for x and y: -1.5..1.5, and for z: -2..2
x_t, y_t, z_t: Parametric expressions for the space curve as functions of t. Example: x_t: t -> cos(t), y_t: t -> sin(t), z_t: t -> 0
t_range: Range for the parameter t. Example: 0..2*Pi
num_vertical_lines: Number of vertical lines to be plotted.
Complete example call: ImplicitPlot3D_withCurveProjection_withPoints(x^2 + y^2 - 1, 0, -1.5..1.5, -1.5..1.5, -2..2, t -> cos(t), t -> sin(t), t -> 0, 0..2*Pi, 5)

 

 

ImplicitPlot3D_withCurveProjection(x + y +z, 0, -1.5..1.5, -1.5..1.5, -2..2, t -> cos(t), t -> sin(t), t -> 0, 0..2*Pi,10)

 

The space curve is closed.
Length of the projection curve (vertical green lines from spacecurve): 8.737752571
Length of the space curve: 6.283185307
Procedure successfully executed. To correctly use this procedure, provide parameters in the following order and format:

f: Algebraic expression for the implicit equation. Example: x^2 + y^2 - 1
n: Numeric value that the implicit equation equals to. Example: 0
x_range, y_range, z_range: Valid ranges for x, y, and z coordinates. Example for x and y: -1.5..1.5, and for z: -2..2
x_t, y_t, z_t: Parametric expressions for the space curve as functions of t. Example: x_t: t -> cos(t), y_t: t -> sin(t), z_t: t -> 0
t_range: Range for the parameter t. Example: 0..2*Pi
num_vertical_lines: Number of vertical lines to be plotted.
Complete example call: ImplicitPlot3D_withCurveProjection_withPoints(x^2 + y^2 - 1, 0, -1.5..1.5, -1.5..1.5, -2..2, t -> cos(t), t -> sin(t), t -> 0, 0..2*Pi, 5)

 

ImplicitPlot3D_withCurveProjection(2*x+y^2-z, 0, -1.5..1.5, -1.5..1.5, -2..2, t -> 2*cos(t), t -> sin(t)+1, t -> 0, 0..1/2*Pi,10);
=============================================================
this example is from procedure 1 en its not the same plot 
===============================================================

 

 

The space curve is not closed.
Length of the projection curve (vertical green lines from spacecurve): 3.653877920
Length of the space curve: 2.422112055
Procedure successfully executed. To correctly use this procedure, provide parameters in the following order and format:

f: Algebraic expression for the implicit equation. Example: x^2 + y^2 - 1
n: Numeric value that the implicit equation equals to. Example: 0
x_range, y_range, z_range: Valid ranges for x, y, and z coordinates. Example for x and y: -1.5..1.5, and for z: -2..2
x_t, y_t, z_t: Parametric expressions for the space curve as functions of t. Example: x_t: t -> cos(t), y_t: t -> sin(t), z_t: t -> 0
t_range: Range for the parameter t. Example: 0..2*Pi
num_vertical_lines: Number of vertical lines to be plotted.
Complete example call: ImplicitPlot3D_withCurveProjection_withPoints(x^2 + y^2 - 1, 0, -1.5..1.5, -1.5..1.5, -2..2, t -> cos(t), t -> sin(t), t -> 0, 0..2*Pi, 5)

 

 

The idea to take the examples of procedure 1 and input them in procedure 2:  to compare plots 
f(x,y) = implicitplot3d ?

Download ImplicitPlot3D_withCurveProjection_-maple_primes_.mw

Used another example from the fist procedure in this second procedure ,but don't get the same plots
( the axes orientation is not the same)

ImplicitPlot3D_withCurveProjection(2*x+y^2-z, 0, -1.5..1.5, -1.5..1.5, -2..2, t -> 2*cos(t), t -> sin(t)+1, t -> 0, 0..1/2*Pi,10);





The procedure still lacks
- a size and orientation in the input
- control on procedure input of x,y,z via equation
- control on special function value output 
- the line integral notation with its value 
- the equation of the space curve 
- the output value of the procedure ( length of the projection curve )

restart;

ImplicitPlot3D_withCurveProjection := proc(f, n, x_range, y_range, z_range, x_t, y_t, z_t, t_range, num_vertical_lines)
    local implicit_function, plot_result, space_curve, projection_curve, combined_plot, is_closed, projection_curve_length, space_curve_length, solve_z, t_values, t_increment, points, i, t, t_increment_vert, vertical_lines, x_val, y_val, z_val_space, z_val_projection;
    uses plots, plottools, Student[Calculus1];

    # Basic check on the correct number of arguments and their types
    if nargs <> 10 or not type(f, algebraic) or not type(n, numeric) or
       not type(x_range, range) or not type(y_range, range) or not type(z_range, range) or
       not type(x_t, procedure) or not type(y_t, procedure) or not type(z_t, procedure) or
       not type(t_range, range) or not type(num_vertical_lines, posint) then
        error "Error: Incorrect input. Ensure all parameters are correctly typed and provided in the following order: ImplicitPlot3D_withCurveProjection_withPoints(f, n, x_range, y_range, z_range, x_t, y_t, z_t, t_range, num_vertical_lines). Each parameter must match its expected type and range.";
    end if;

    # Create the implicit expression
    implicit_function := f = n;

    # Generate the 3D plot of the implicit surface
    plot_result := implicitplot3d(implicit_function, x = x_range, y = y_range, z = z_range, axes = boxed, grid = [30,30,30], style = surface, title = sprintf("Implicit plot of %a = %a with space curve and its vertical projection", f, n));

    # Define the parametric space curve
    space_curve := spacecurve([x_t(t), y_t(t), z_t(t)], t = t_range, color = "red", thickness = 2);

    # Solve the surface equation for z if possible
    solve_z := solve(f = n, z);

    # Define the projection curve on the surface, vertical projection to z solved from surface equation
    projection_curve := spacecurve([x_t(t), y_t(t), eval(solve_z, {x = x_t(t), y = y_t(t)})], t = t_range, color = "blue", thickness = 2, linestyle = 2);

    # Check if the curve is closed
    is_closed := evalb(x_t(op(1, t_range)) = x_t(op(2, t_range)) and y_t(op(1, t_range)) = y_t(op(2, t_range)));

    # Calculate the length of the projection curve
    projection_curve_length := evalf(Int(sqrt(diff(x_t(t), t)^2 + diff(y_t(t), t)^2 + (diff(eval(solve_z, {x = x_t(t), y = y_t(t)}), t))^2), t = t_range));

    # Calculate the length of the space curve
    space_curve_length := evalf(Int(sqrt(diff(x_t(t), t)^2 + diff(y_t(t), t)^2 + diff(z_t(t), t)^2), t = t_range));

    # Calculate t values for points
    t_values := [seq(op(1, t_range) + i * (op(2, t_range) - op(1, t_range)) / num_vertical_lines, i = 0 .. num_vertical_lines)];

    # Calculate the increment for t values
    t_increment := (op(2, t_range) - op(1, t_range)) / num_vertical_lines;

    # Calculate points on the space curve
    points := [seq([eval(x_t(t_values[i])), eval(y_t(t_values[i])), eval(z_t(t_values[i]))], i = 1..num_vertical_lines)];

    # Calculate the increment for vertical t values
    t_increment_vert := (op(2, t_range) - op(1, t_range)) / num_vertical_lines;

    # Plot vertical lines from space curve to projection curve
    vertical_lines := [];
    for i from 0 to num_vertical_lines-1 do
        x_val := eval(x_t(op(1, t_range) + i * t_increment_vert));
        y_val := eval(y_t(op(1, t_range) + i * t_increment_vert));
        z_val_space := eval(z_t(op(1, t_range) + i * t_increment_vert));
        z_val_projection := eval(solve_z, {x = x_val, y = y_val});
        vertical_lines := [op(vertical_lines), plottools:-line([x_val, y_val, z_val_space], [x_val, y_val, z_val_projection], color = "green")];
    end do;

    # Combine both plots, space curve, projection curve, and vertical lines
      combined_plot := display({plot_result, space_curve, projection_curve, seq(vertical_lines[i], i = 1..num_vertical_lines)}, axes = boxed);



    # Print the combined plot
    print(combined_plot);

    # Print whether the curve is closed or not
    if is_closed then
        printf("The space curve is closed.\n");
    else
        printf("The space curve is not closed.\n");
    end if;

    # Print the length of the projection curve
    printf("Length of the projection curve (vertical green lines from spacecurve): %a\n", projection_curve_length);

    # Print the length of the space curve
    printf("Length of the space curve: %a\n", space_curve_length);

    # Provide detailed information on how to use the procedure correctly after execution
    printf("Procedure successfully executed. To correctly use this procedure, provide parameters in the following order and format:\n\n");
    printf("f: Algebraic expression for the implicit equation. Example: x^2 + y^2 - 1\n");
    printf("n: Numeric value that the implicit equation equals to. Example: 0\n");
    printf("x_range, y_range, z_range: Valid ranges for x, y, and z coordinates. Example for x and y: -1.5..1.5, and for z: -2..2\n");
    printf("x_t, y_t, z_t: Parametric expressions for the space curve as functions of t. Example: x_t: t -> cos(t), y_t: t -> sin(t), z_t: t -> 0\n");
    printf("t_range: Range for the parameter t. Example: 0..2*Pi\n");
    printf("num_vertical_lines: Number of vertical lines to be plotted.\n");
    printf("Complete example call: ImplicitPlot3D_withCurveProjection_withPoints(x^2 + y^2 - 1, 0, -1.5..1.5, -1.5..1.5, -2..2, t -> cos(t), t -> sin(t), t -> 0, 0..2*Pi, 5)\n");
end proc:

# Voorbeeldaanroep
ImplicitPlot3D_withCurveProjection(x + y + z, 0, -10.5..10.5, -10.5..10.5, -20..20, t -> t, t -> 3*cos(t), t -> 3*sin(t), 0..1*Pi, 5);

 

The space curve is not closed.
Length of the projection curve (vertical green lines from spacecurve): 7.907090108
Length of the space curve: 9.934588266
Procedure successfully executed. To correctly use this procedure, provide parameters in the following order and format:

f: Algebraic expression for the implicit equation. Example: x^2 + y^2 - 1
n: Numeric value that the implicit equation equals to. Example: 0
x_range, y_range, z_range: Valid ranges for x, y, and z coordinates. Example for x and y: -1.5..1.5, and for z: -2..2
x_t, y_t, z_t: Parametric expressions for the space curve as functions of t. Example: x_t: t -> cos(t), y_t: t -> sin(t), z_t: t -> 0
t_range: Range for the parameter t. Example: 0..2*Pi
num_vertical_lines: Number of vertical lines to be plotted.
Complete example call: ImplicitPlot3D_withCurveProjection_withPoints(x^2 + y^2 - 1, 0, -1.5..1.5, -1.5..1.5, -2..2, t -> cos(t), t -> sin(t), t -> 0, 0..2*Pi, 5)

 

ImplicitPlot3D_withCurveProjection(x + y + z, 0, -10.5..10.5, -10.5..10.5, -20..20, t -> cos(t), t -> sin(t), t -> 0, 0..2*Pi,8);

 

The space curve is closed.
Length of the projection curve (vertical green lines from spacecurve): 8.737752571
Length of the space curve: 6.283185307
Procedure successfully executed. To correctly use this procedure, provide parameters in the following order and format:

f: Algebraic expression for the implicit equation. Example: x^2 + y^2 - 1
n: Numeric value that the implicit equation equals to. Example: 0
x_range, y_range, z_range: Valid ranges for x, y, and z coordinates. Example for x and y: -1.5..1.5, and for z: -2..2
x_t, y_t, z_t: Parametric expressions for the space curve as functions of t. Example: x_t: t -> cos(t), y_t: t -> sin(t), z_t: t -> 0
t_range: Range for the parameter t. Example: 0..2*Pi
num_vertical_lines: Number of vertical lines to be plotted.
Complete example call: ImplicitPlot3D_withCurveProjection_withPoints(x^2 + y^2 - 1, 0, -1.5..1.5, -1.5..1.5, -2..2, t -> cos(t), t -> sin(t), t -> 0, 0..2*Pi, 5)

 

 

 


 

Download ImplicitPlot3D_withCurveProjection_-maple_primes_.mw

 

@acer 
Thanks, yes this is a 3D space curve and this is the effect and I see that the earlier created procedure has been modified for this.
I also added a small adjustment : 4 vertical green lines from the projection curve to the curve projected on the surface.
Surfaces in f(x,y,z) are even more complicated in shape 
The intention is to obtain an equation of the interpolation curve on the surface, just that's a bonus 
Am afraid that possibly mission impossible becomes obtaining these equations and then especially if the surfaces become more erratic.

booglengte_geenberekenin_plus_plot_vraag_maple_primes_engels_ac3d_kopie1-def.mw

First 30 31 32 33 34 35 36 Last Page 32 of 73