rounds

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.1, Creation date: 2017-08-12, Last change: 2025-09-14

is just an abbreviation if rounds(x,s,'significant')

Description

At lot of trigonometric function and cross product or dot product have problems with numerical accuracy.
Double = rounds(1,12)
single = rounds(1,6)
half = rounds(1,3)

See Also: , rounddiv

Example Illustration

 missing image of rounds(x,s)

Syntax

y=rounds(x,s)

Input Parameter

x: floating point number
s: number of

Output Parameter

y: rounded x




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 rounds, is a utility from the SG-Library designed to improve numerical accuracy in calculations involving trigonometric functions and vector operations. It is an auxiliary procedure introduced in SolidGeometry 4.1 by Tim C. Lueth.

Input Parameters

Output

Function Explanation

The function rounds is a simple wrapper around the round function with the 'significant' option. It takes two inputs, x and s, and returns y, which is x rounded to s significant digits.

The function is particularly useful in scenarios where numerical precision is critical, such as in trigonometric calculations or when computing cross or dot products. The function helps mitigate issues related to numerical inaccuracies that can arise in such computations.

Examples of usage include:

The function is a straightforward implementation that leverages MATLAB's built-in round function, specifically using the 'significant' option to achieve the desired precision.

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