
レポートを自動化して、上部に定義されている一連の変数を変更できるようにし、更新された数値とともにドキュメントにカスケード表示できるようにしたいと考えています。
私の問題は、関数の引数が実際には別の方程式である逆三角関数を計算しようとしていることです (スクリーンショットを参照)。 (\def は、tikz に入力されると評価される単なる文字列だと思います。)
誰か私を助けてくれませんか:
- 方程式(引数)を別の変数に評価して単一の数値に解決するか、
- 逆三角関数に方程式を適切に埋め込む方法を説明します。
- 別の方法でサポートしますか?
以下の MWE を見ると、計算機パッケージの \ARCSIN を使用する必要があることがわかります。これよりよいものはありますか?
ありがとう
\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}
答え1
私はいつもpgf
計算に使用していますが、うまく機能しているようです:
コード:
\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}