zigzag

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 4.0, Creation date: 2017-07-30, Last change: 2025-09-14

returns a zig zag curve in the interval [0 2*pi]

Description

corresponds to cosinus function

See Also:

Example Illustration

 missing image of zigzag(x,per)

Syntax

y=zigzag(x,[per])

Input Parameter

x: x value
per: periode; default is 2*pi

Output Parameter

y: zigzag value

Examples


zigzag(0)
zigzag(0:2*pi)
zigzag(1,4)




Copyright 2017-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, named zigzag, generates a zigzag curve based on the input parameters. It is part of the SolidGeometry library and was introduced in version 4.0. The function is designed to mimic the behavior of a cosine function.

Input Parameters

Output

Algorithm Steps

  1. Initialize the default period per to 2*pi.
  2. If a second argument is provided and is not empty, set per to this value and calculate p as per/2.
  3. Use the modulo operation to wrap the input x values within the range of the period per.
  4. Initialize the output y to be the same as x.
  5. Iterate over each element in x:
  6. If no output is requested (i.e., nargout==0), plot the zigzag function:

Example Usage

Algorithm explaination created using ChatGPT on 2025-08-18 23:33. (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