triangleheight

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Geometric Queries
Introduced first in SolidGeometry 4.9, Creation date: 2020-02-28, Last change: 2025-09-14

returns the heights of a triangle - slow but correct



See Also: mirroringatline3D

Example Illustration

 missing image of triangleheight(v1,v2,v3)

Syntax

h=triangleheight(v1,v2,v3)

Input Parameter

v1: vertex 1 or Vertex list
v2: vertex 2
v3: vertex 3

Output Parameter

h: [h1 h2 h3]

Examples


VLsampletriangles(25); VL=ans;
triangleheight(VL); view(-10,0)




Copyright 2020-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 calculates the heights of a triangle given its vertices. It is designed to be precise, though it may not be the fastest method available.

Input Parameters

Output Results

Algorithm Steps

  1. If only one input argument is provided, it assumes that v1 is a list of vertices and extracts v1, v2, and v3 from this list.
  2. For each vertex, the function calculates the height by calling mirroringatline3D:
    • For vertex v1, it calculates the height to the line formed by v2 and v3.
    • For vertex v2, it calculates the height to the line formed by v1 and v3.
    • For vertex v3, it calculates the height to the line formed by v1 and v2.
  3. The heights are stored in the vector h, and the closest points are stored in cp.
  4. If no output arguments are specified, the function visualizes the triangle and its heights:
    • It plots the triangle using CVLplot.
    • It annotates the vertices and the heights on the plot.
Algorithm explaination created using ChatGPT on 2025-08-19 06:46. (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