Syntax
h=triangleheight(v1,v2,v3)
Input Parameter
v1 : | | vertex 1 or Vertex list |
v2 : | | vertex 2 |
v3 : | | vertex 3 |
Output Parameter
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
- v1: The first vertex of the triangle or a list of vertices.
- v2: The second vertex of the triangle.
- v3: The third vertex of the triangle.
Output Results
- h: A vector containing the heights from each vertex to the opposite side, represented as [h1, h2, h3].
- cp: The closest points on the opposite sides for each vertex.
Algorithm Steps
- 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.
- 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.
- The heights are stored in the vector
h
, and the closest points are stored in cp
.
- 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