当前位置:网站首页>Halcon principle: one dimensional function_ 1D type [1]

Halcon principle: one dimensional function_ 1D type [1]

2022-06-23 11:59:00 Mr anhydrous

         We know , Tuples are one-dimensional , But it's not a function . One dimensional functions are special data generated by tuples , For functions , There is a special set of operators to operate .

One 、 How to generate

1.1 Generate by tuple function_1d function

  •  create_funct_1d_array: Create a discrete one-dimensional function from a one-dimensional array

  •  create_funct_1d_pairs: Create a discrete one-dimensional function through a double one-dimensional array

Be careful : Argument tuple XValue Must be sorted ( From small to large ).

1.2 1d Inverse operation on function

1)funct_1d_to_pairs Get one-dimensional discrete function x and y Value corresponding tuple  

funct_1d_to_pairs( flow, XValues1, YValues1)

From the input function flow Get two tuples :XValues1, YValues1

2)get_y_value_funct_1d Get one-dimensional discrete function y value ( No more details )

Two 、1d One dimensional operations on functions

1)abs_funct_1d  Calculate the absolute value of a one-dimensional function

Prototype :abs_funct_1d( : : Function : FunctionAbsolute)

 2)compose_funct_1 Compound two discrete one-dimensional functions into one function

This is a composite function , such as : sin(x^2)

3、 ... and 、 Comprehensive sample code  

Understand the above operations , You can understand the following code :

* This example program shows how to use compose_funct_1d.  It computes
* two functions, atan(x) and cos(x), and composes them, which results in the
* function cos(atan(x)).  This function is, of course, identical to 1/sqrt(1+x*x),
* so this function is also calculated.  The program displays all four functions.
* By comparing the last two plots, we can check whether compose_funct_1d
* works correctly.
dev_update_off ()
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'white', WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_color ('black')
dev_set_line_width (2)
X := []
for J := -125 to 125 by 1
    X := [X,J / 40.0]
endfor
stop()
create_funct_1d_pairs (X, cos(X), Cos)
X := []
for J := -100 to 100 by 1
    X := [X,J / 10.0]
endfor
stop()
create_funct_1d_pairs (X, atan(X), ATan)
create_funct_1d_pairs (X, 1 / sqrt(1 + X * X), InvSqrt1pSqX)
compose_funct_1d (ATan, Cos, 'constant', CosATan)
plot_funct_1d (WindowHandle, ATan, 'x', 'atan(x)', 'red', ['axes_color','origin_x','origin_y'], ['black',0,0])
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
dev_clear_window ()
plot_funct_1d (WindowHandle, Cos, 'x', 'cos(x)', 'red', ['axes_color','origin_x','origin_y'], ['black',0,0])
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
dev_clear_window ()
plot_funct_1d (WindowHandle, CosATan, 'x', 'cos(atan(x))', 'red', ['axes_color','origin_x','origin_y','start_y'], ['black',0,0,0])
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
dev_clear_window ()
plot_funct_1d (WindowHandle, InvSqrt1pSqX, 'x', '1/sqrt(1+x*x)', 'red', ['axes_color','origin_x','origin_y','start_y'], ['black',0,0,0])
* 

( To be continued )

原网站

版权声明
本文为[Mr anhydrous]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231152017667.html