1.4 Tangent

Summary

This Tangent app is for plotting the tangent line along a curve. When using this app, Origin adds a vertical line to the graph, allowing you to move the vertical line to select a point from curve.

A Tangent Preferences dialog is available from the fly out menu. You can save tool settings to a theme file for later use.


Tutorial

Create the Tangent Line

  1. Import Exponential Decay.dat in the <Origin EXE Folder>\Samples\Curve Fitting\ folder. Select Column B, and then select Plot: Basic 2D: Line+Symbol menu to make a Scatter plot.
  2. When the graph is active, click Tangent icon Tangent icon.png from the Apps panel of Origin to open the app's dialog box. When the dialog is open, you can click F1 key open the help file for it.
    Tangent App 01.png
  3. Click OK. You will see that a red vertical line and a blue tangent line are added to the plot. The value of slope is shown at the top. The tangent point is intersected point of the two lines.
    Note: The tangent point will be a data point on the graph.
    Tangent App 02.png
  4. To select the tangent point, drag the red vertical line to select the data point on the curve. As you do this, displayed information regarding the tangent point, is updated.
    Tangent App 04.png


Modify the Smooth method

When the curve is not smooth, the tangent line may not be well-fitted to the curve. In such cases, we can use smoothing to affect the calculated derivatives. This tool supply the Smooth method, On the Derivative tab of the Tangent Preferences dialog box, choose B-Spline or Savitzky-Golay from the Smooth list.

  1. Click the Triangle button.png triangle button at the top right corner of the layer, and select Preferences... from the context menu to reopen Tangent app's settings dialog.
    Tangent App 03.png
  2. Go to the Derivative tab, choose B-Spline as smoothing method
    Tangent App 05.png
    Tangent App 06.png

Output the result

You can update output for the tangent line using the fly-out menu of the app. Also, you can customize the output data and position on the Output tab of Tangent Preferences dialog.

Tangent App 07.png

Dialog Settings

Tangent tab

Show Tool Name (toolname) Specify whether to show the tool name in the top-left corner of the layer in the graph. The tool name can be specified in Preferences.
Show on Center-Top Customize the information that is displayed at the center-top of graph.
  • Tangent Point Info
By default, the Curve and Index are listed at the center-top of graph.
  • Slope
By default, the slope is shown at the center-top of graph.
  • Angle
Angle is calculated form the slope, and its range is between 0 and 180.
If slope >0,  angle =180 * \frac{arctan(slope)}{pi}
If slope <0,  angle =180 * \frac{arctan(slope)}{pi} +180
  • Tangent Line Function
 y =y0 + slope * (x-x0)
(x0, y0) is the value of tangent point.
Color Setting
  • Vertical Line Color
Specify the intersecting vertical line color.
  • Tangent Line Color
Specify the tangent line color.

Derivative tab

Smooth
  • None
Do not use any smoothing method.
  • B-Spline
Specify the B-Spline method to get smoothed derivative. This method performs spline interpolation and calculates the derivative from the interpolation function.
  • Savitzky-Golay Smooth
Specify the Savitzky-Golay method to get smoothed derivative. This method performs a local polynomial regression around each point, to find the derivative.
B-Spline Type This drop-down list is only available when B-Spline is selected as the smoothing method.
  • Auto
This method uses the B-Spline method to interpolate. It automatically attempts to find a satisfactory value as the smoothing factor in the B-Spline interpolation.
  • Interpolating Spline
This method uses Cubic Spline interpolation to calculate the derivative. It splits the input data into a given number of pieces, and fits each segment with a cubic polynomial.
  • Fit Cubic Polynomial
This method performs cubic polynomial fitting and calculates the derivative from the cubic polynomial function.
  • Custom
This method uses the B-Spline method to interpolate. The smoothness of the cubic B-Spline is determined by the Smoothing Factor.
Smoothing Factor This parameter is only available when the B-Spline Type is Custom. Smoothness Factor should be a positive number. The factor helps the user control the balance between smoothing and fidelity to the actual data. Larger values will result in smoother curves.
Polynomial Order This parameter is only available when Savitzky-Golay is selected as the smoothing method. It specifies the polynomial order.
Points of Window This parameter is only available when Savitzky-Golay is selected as the smoothing method. It specifies the number of points in the moving window.

Output tab

Output Quantities to

Customize the output.

Script Window Output results to the Script window.
Results Log Output results to the Results Log.
Append to Worksheet Append results to a worksheet.
Add Label to Graph Output results to a label object on the graph.

Quantities

Dataset Identifier (name) Specify a dataset identifier.
Tangent Point Index (tangentpoint_i) Output the index of the Tangent Point.
Tangent Point(tangentpoint) Output the coordinates of the Tangent Point.
Slope (slope) Output the slope value.
Angle (angle) Output the angle value.
Tangent Line Function (function) Output the function of the tangent line.

Tangent Line

Outout To Output Tangent Line data to Source Sheet/Source Book New Sheet/New Book

Fly-out Menu

Click the button ROI menu.png at the upper-right corner of the layer to expand the fly-out menu.

New Output Output results to the specified worksheet (if not empty, append the results).
New Output for All Curves (N) Output the results for all curves in the current layer to the specified worksheet (if not empty, append the results).
New Output for All Layers (L) Output the results for all curves in all layers within the current graph to the specified worksheet (if not empty, append the results).
Go to Report Worksheet Activate the report worksheet, if it exists.
Go to Source Worksheet Activate the source worksheet.
Output to Clipboard Output results to clipboard.
Change Data Change the source dataset. This is applicable only when there are multiple curves on the current graph layer.
Save Theme Save dialog settings to a Theme.
Save as <default> Save current settings as the default dialog box Theme.
Load Theme Load the existing dialog box Theme and apply Theme settings.
Preferences Open the Tangent Preferences dialog box.