plotrulerline

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Visualization
Introduced first in SolidGeometry 5.2, Creation date: 2022-05-14, Last change: 2025-09-15

draws an simple ruler between two points in 2D



See Also: tplotruler

Example Illustration

 missing image of plotrulerline(P1,P2,nam)

Syntax

plotrulerline(P1,P2,[nam])

Input Parameter

P1: Start Point or [P1;P2]
P2: End Point
nam: Name, for instace "D="




Copyright 2022-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, plotrulerline, is designed to draw a simple ruler line between two points in 2D space. It is part of the SolidGeometry library and was introduced in version 5.2.

Input Parameters

Algorithm Steps

  1. Extract P2 from varargin if not directly provided. If P2 is empty, assume P1 contains both points.
  2. Ensure both P1 and P2 are 3D by adding a zero z-coordinate if they are 2D.
  3. Calculate the center point CP as the midpoint between P1 and P2.
  4. Determine the scale factor s based on the current axis scaling.
  5. Compute the direction vector dv and its magnitude d. Normalize dv to get the unit vector ev.
  6. Calculate the orthogonal vector ov using a transformation matrix T.
  7. Set the line length ll to the minimum of d and 0.7.
  8. Determine extended points OP1 and OP2 for drawing purposes.
  9. Round the distance d to the nearest 0.05 for display.
  10. Format the distance as a string txt, appending nam if provided.
  11. Check the ratio s/d to decide the drawing method:
  12. Calculate the angle w for text rotation based on the direction vector.
  13. Set the rotation of the text to align with the line.
Algorithm explaination created using ChatGPT on 2025-08-19 07:15. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21