Pythagoras
Determine the hypotenuse or leg of a right triangle
Library
Modelica/Blocks/Math
Description
This block determines the hypotenuse y = sqrt(u1^2 + u2^2)
if the boolean parameter u1IsHyotenuse = false
.In this case the two inputs u1
andu2
are interpreted as the legs of a right triangleand the boolean output valid
is always equal totrue
.
If u1IsHyotenuse = true
, input u1
is interpreted as hypotenuse and u2
is one of the two legs of a right triangle.Then, the other of the two legs of the right triangle is the output, determined byy = sqrt(u1^2 - u2^2)
, if u1^2 - u2^2 ≥ 0
; in this case theboolean output valid
is equal to true
. In case of u1^2 - u2^2 < 0
, theoutput y = 0
and valid
is set to false
.
Parameters
Name | Label | Description | Data Type | Valid Values |
---|---|---|---|---|
mo_u1IsHypotenuse | u1IsHypotenuse | = true, if u1 is the hypotenuse and y is one leg | Scalar | true |
Name | Label | Description | Data Type | Valid Values |
---|---|---|---|---|
mo__nmodifiers | Number of Modifiers | Specifies the number of modifiers | Number | |
mo__modifiers | Modifiers | Add new modifier | Structure | |
mo__modifiers/varname | Variable name | Cell of strings | 'y2' | |
mo__modifiers/attribute | Attribute | Cell of strings | 'start' | |
mo__modifiers/value | Value |
Ports
Name | Type | Description | IO Type | Number |
---|---|---|---|---|
u1 | implicit | Connector of Real input signal 1 | input | 1 |
u2 | implicit | Connector of Real input signal 2 | input | 2 |
y | implicit | Connector of Real output signal | output | 1 |
valid | implicit | = true, if y is a valid result | output | 2 |