
Estou tentando automatizar um relatório para permitir alterar uma série de variáveis definidas na parte superior, que serão exibidas em cascata no documento com números atualizados.
Meu problema é tentar calcular funções trigonométricas inversas, onde o argumento da função é na verdade outra equação (veja a captura de tela). (Acho que \def é apenas uma string que, quando colocada no tikz, é avaliada.)
Alguém pode me ajudar também:
- Avalie a equação (argumento) para outra variável para resolver para um único número, ou
- Descrever como incorporar adequadamente a equação na função trigonométrica inversa, ou
- Ajuda com outro método?
Você verá no MWE abaixo que quero usar \ARCSIN do pacote da calculadora. Existe um melhor para usar?
Obrigado
\documentclass{article}
\usepackage{calc}
\usepackage{calculator}
\usepackage{trig}
\begin{document}
%% Defined Variables
\def\CrankAngle{170} % Angle position of the crank for piston dynamics
\def\Stroke{60} % Piston stroke, which is equivalent to crank working diameter
\def\ConRodLength{100} % Length of connecting rod
\def\PistonOffset{25} % L_o - offset of the piston cylinder from the crank centerline
%% Derived Variables (Calculated from Defined Variables)
\CalculateCos{\CrankAngle} % Need to pre-calculate the value before using
\def\StrokeXPos{\UseCos{\CrankAngle}*\Stroke/2} % Assign the value of the recently-calculated sin to a global variable MUST DO
\CalculateSin{\CrankAngle} % Need to pre-calculate the value before using
\def\StrokeYPos{\UseSin{\CrankAngle}*\Stroke/2} % Assign the value of the recently-calculated sin to a global variable MUST DO
\def\ConRodYOffset{\PistonOffset -\StrokeYPos}
\def\ConRodSinRatio{\ConRodYOffset/\ConRodLength}
%\ARCSIN{\ConRodSinRatio}{\sol} - WHAT TO USE THIS (OR SIMILAR) BUT NEED NUMBER IN RATIO; NOT EXPRESSION
\section{Sample Evaluations}
X-Position = \StrokeXPos
Y-Position = \StrokeYPos
Con Rod Y-Offset = \ConRodYOffset
Con Rod Sin Ratio = \ConRodSinRatio
\end{document}
Responder1
Sempre usei pgf
para cálculos e parece funcionar muito bem:
Código:
\documentclass{article}
\usepackage{mathtools}% For {align*}
\usepackage{pgf}
\begin{document}
%% Defined Variables
\def\CrankAngle{170} % Angle position of the crank for piston dynamics
\def\Stroke{60} % Piston stroke, which is equivalent to crank working diameter
\def\ConRodLength{100} % Length of connecting rod
\def\PistonOffset{25} % L_o - offset of the piston cylinder from the crank centerline
%% Derived Variables (Calculated from Defined Variables)
\pgfmathsetmacro\StrokeXPos{cos(\CrankAngle)*\Stroke/2} % Assign the value of the recently-calculated sin to a global variable MUST DO
\pgfmathsetmacro\StrokeYPos{sin(\CrankAngle)*\Stroke/2} % Assign the value of the recently-calculated sin to a global variable MUST DO
\pgfmathsetmacro\ConRodYOffset{\PistonOffset -\StrokeYPos}
\pgfmathsetmacro\ConRodSinRatio{\ConRodYOffset/\ConRodLength}
\pgfmathsetmacro\ArcSinValue{asin(\ConRodSinRatio)}
\section{Sample Evaluations}
\begin{align*}
\text{X-Position} &= \StrokeXPos \\
\text{Y-Position} &= \StrokeYPos \\
\text{Con Rod Y-Offset} &= \ConRodYOffset \\
\text{Con Rod Sin Ratio} &= \ConRodSinRatio \\
\text{Arc Sin Value} &= \ArcSinValue \\
\end{align*}
\end{document}