玩心态

文章 评论 浏览 30

玩心态 2025-02-12 21:21:20

问题不是Maven,而是您启动应用程序的方式
在您的主要方法中,您创建游戏并开始渲染,而LibGDX功能尚未初始化。启动您应用程序的通常方法看起来有点像这样(用于桌面应用程序):

public static void main (String[] arg) {
    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.setForegroundFPS(60);
    config.setTitle("My GDX Game");
    new Lwjgl3Application(new MyGdxGame(), config);
}

这样可以创建游戏的方式,但是当LibGDX后端准备就绪时,LibGDX负责调用游戏类的渲染方法。


如果您下载libgdx设置工具(链接下载)并创建一个项目,您可以可以选择希望您的游戏的应用程序类型在(桌面,Android,iOS,HTML)上运行。该工具将在每个项目中生成一个主类,该类别可以正确启动游戏。

The problem is not Maven, but the way you start your application.
In your main method you create a game and start rendering while the libGdx features are not initialized yet. The usual way to start your application would look somewhat like this (for desktop applications):

public static void main (String[] arg) {
    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.setForegroundFPS(60);
    config.setTitle("My GDX Game");
    new Lwjgl3Application(new MyGdxGame(), config);
}

This way your game is created, but libGdx is responsible for calling the render method of you game class when the libGdx backend is ready.


If you download the libGdx setup tool (link to download) and create a project you can select the types of application you want your game to be runnable on (desktop, android, ios, html). The tool will generate a main class in each project, that starts the game correctly.

在libgdx捕捉变形者时,如何避免nullpoInterException

玩心态 2025-02-12 18:45:38

您可以简单地使用以下内容:\这是。*? \句子

You can simply use this: \This is .*? \sentence

正则匹配两个字符串之间的所有字符

玩心态 2025-02-12 17:42:33

首先,通常在Sympy中避免使用浮子更好,因此将1/2更改为Rational(1,2)s.halfs(1)/2等。

此处涉及的表达式很长且复杂。我将用普通的符号替换所有功能和衍生物,以便我们可以更好地看到它:

t1, t2, t3 = symbols('t1:4')
dt1, dt2, dt3 = symbols('tdot1:4')
ddt1, ddt2, ddt3 = symbols('tddot1:4')

rep = {
        the1:t1, the2:t2, the3:t3,
        the1_d:dt1, the2_d:dt2, the3_d:dt3,
        the1_dd:ddt1, the2_dd:ddt2, the3_dd:ddt3,
        }

eqs = [eq.subs(rep).trigsimp() for eq in [LE1, LE2, LE3]]
syms = [ddt1, ddt2, ddt3]

我还使用Trigsimp在那里使用Trig减少了Trig,这确实需要一些时间。 (如果您确切地知道您要寻找的简化类型,您可以通过各种方式加快速度。)

现在它们更简单,让我们看一下这些方程式:

In [4]: for eq in eqs: pprint(eq)
    ⎛                                                                 2                                                2                                                2                                                          ⎞
-L₁⋅⎝L₁⋅m₁⋅ẗ₁ + L₁⋅m₂⋅ẗ₁ + L₁⋅m₃⋅ẗ₁ + L₂⋅m₂⋅ẗ₂⋅cos(t₁ - t₂) + L₂⋅m₂⋅ṫ₂ ⋅sin(t₁ - t₂) + L₂⋅m₃⋅ẗ₂⋅cos(t₁ - t₂) + L₂⋅m₃⋅ṫ₂ ⋅sin(t₁ - t₂) + L₃⋅m₃⋅ẗ₃⋅cos(t₁ - t₃) + L₃⋅m₃⋅ṫ₃ ⋅sin(t₁ - t₃) + g⋅m₁⋅sin(t₁) + g⋅m₂⋅sin(t₁) + g⋅m₃⋅sin(t₁)⎠
   ⎛                                 2                                                2                                                                      2                                           ⎞
L₂⋅⎝-L₁⋅m₂⋅ẗ₁⋅cos(t₁ - t₂) + L₁⋅m₂⋅ṫ₁ ⋅sin(t₁ - t₂) - L₁⋅m₃⋅ẗ₁⋅cos(t₁ - t₂) + L₁⋅m₃⋅ṫ₁ ⋅sin(t₁ - t₂) - L₂⋅m₂⋅ẗ₂ - L₂⋅m₃⋅ẗ₂ - L₃⋅m₃⋅ẗ₃⋅cos(t₂ - t₃) - L₃⋅m₃⋅ṫ₃ ⋅sin(t₂ - t₃) - g⋅m₂⋅sin(t₂) - g⋅m₃⋅sin(t₂)⎠
      ⎛                           2                                          2                                 ⎞
L₃⋅m₃⋅⎝-L₁⋅ẗ₁⋅cos(t₁ - t₃) + L₁⋅ṫ₁ ⋅sin(t₁ - t₃) - L₂⋅ẗ₂⋅cos(t₂ - t₃) + L₂⋅ṫ₂ ⋅sin(t₂ - t₃) - L₃⋅ẗ₃ - g⋅sin(t₃)⎠

因此,我们想解决双点符号和我们可以看到这只是线性的,因此我们可以将其转换为矩阵:

In [5]: A, b = linear_eq_to_matrix(eqs, syms)

In [6]: A
Out[6]: 
⎡         -L₁⋅(L₁⋅m₁ + L₁⋅m₂ + L₁⋅m₃)           -L₁⋅(L₂⋅m₂⋅cos(t₁ - t₂) + L₂⋅m₃⋅cos(t₁ - t₂))  -L₁⋅L₃⋅m₃⋅cos(t₁ - t₃)⎤
⎢                                                                                                                    ⎥
⎢L₂⋅(-L₁⋅m₂⋅cos(t₁ - t₂) - L₁⋅m₃⋅cos(t₁ - t₂))               L₂⋅(-L₂⋅m₂ - L₂⋅m₃)               -L₂⋅L₃⋅m₃⋅cos(t₂ - t₃)⎥
⎢                                                                                                                    ⎥
⎢                                                                                                        2           ⎥
⎣           -L₁⋅L₃⋅m₃⋅cos(t₁ - t₃)                         -L₂⋅L₃⋅m₃⋅cos(t₂ - t₃)                     -L₃ ⋅m₃        ⎦

In [7]: b
Out[7]: 
⎡   ⎛        2                        2                        2                                                          ⎞⎤
⎢L₁⋅⎝L₂⋅m₂⋅ṫ₂ ⋅sin(t₁ - t₂) + L₂⋅m₃⋅ṫ₂ ⋅sin(t₁ - t₂) + L₃⋅m₃⋅ṫ₃ ⋅sin(t₁ - t₃) + g⋅m₁⋅sin(t₁) + g⋅m₂⋅sin(t₁) + g⋅m₃⋅sin(t₁)⎠⎥
⎢                                                                                                                          ⎥
⎢           ⎛        2                        2                        2                                           ⎞       ⎥
⎢       -L₂⋅⎝L₁⋅m₂⋅ṫ₁ ⋅sin(t₁ - t₂) + L₁⋅m₃⋅ṫ₁ ⋅sin(t₁ - t₂) - L₃⋅m₃⋅ṫ₃ ⋅sin(t₂ - t₃) - g⋅m₂⋅sin(t₂) - g⋅m₃⋅sin(t₂)⎠       ⎥
⎢                                                                                                                          ⎥
⎢                                     ⎛     2                     2                         ⎞                              ⎥
⎣                              -L₃⋅m₃⋅⎝L₁⋅ṫ₁ ⋅sin(t₁ - t₃) + L₂⋅ṫ₂ ⋅sin(t₂ - t₃) - g⋅sin(t₃)⎠                              ⎦

直接计算逆向恰好有点慢,但是我们可以使用atchugate

In [8]: sol = A.adjugate()*b/A.det()

In [9]: sol
Out[9]: 
⎡                                                                                              ⎛  2   2           2   2   2    2              2   2   2⎞ ⎛        2                        2                        2                                                          ⎞      ⎛          2                              2   2                        2   2                          ⎞ ⎛        2                        2                        2                
⎢                                                                                           L₁⋅⎝L₂ ⋅L₃ ⋅m₂⋅m₃ - L₂ ⋅L₃ ⋅m₃ ⋅cos (t₂ - t₃) + L₂ ⋅L₃ ⋅m₃ ⎠⋅⎝L₂⋅m₂⋅ṫ₂ ⋅sin(t₁ - t₂) + L₂⋅m₃⋅ṫ₂ ⋅sin(t₁ - t₂) + L₃⋅m₃⋅ṫ₃ ⋅sin(t₁ - t₃) + g⋅m₁⋅sin(t₁) + g⋅m₂⋅sin(t₁) + g⋅m₃⋅sin(t₁)⎠ - L₂⋅⎝- L₁⋅L₂⋅L₃ ⋅m₂⋅m₃⋅cos(t₁ - t₂) - L₁⋅L₂⋅L₃ ⋅m₃ ⋅cos(t₁ - t₂) + L₁⋅L₂⋅L₃ ⋅m₃ ⋅cos(t₁ - t₃)⋅cos(t₂ - t₃)⎠⋅⎝L₁⋅m₂⋅ṫ₁ ⋅sin(t₁ - t₂) + L₁⋅m₃⋅ṫ₁ ⋅sin(t₁ - t₂) - L₃⋅m₃⋅ṫ₃ ⋅sin(t₂ - 
⎢                                                                                           ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
⎢                                                                                                                                                   2   2   2              2   2   2      2    2              2   2   2      2     2   2   2   2       2              2   2   2   2          2   2   2      2    2                2   2   2      2                                            2   2   2      2    2              2   2   2      2    2                2   
⎢                                                                                                                                               - L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₂⋅m₃ + L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₃ ⋅cos (t₂ - t₃) - L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₃  + L₁ ⋅L₂ ⋅L₃ ⋅m₂ ⋅m₃⋅cos (t₁ - t₂) - L₁ ⋅L₂ ⋅L₃ ⋅m₂ ⋅m₃ + 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₁ - t₂) - 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃)⋅cos(t₂ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₂ - t₃) - 2⋅L₁ ⋅L₂
⎢                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
⎢                                                                      ⎛          2                              2   2                        2   2                          ⎞ ⎛        2                        2                        2                                                          ⎞      ⎛  2   2           2   2           2   2   2    2              2   2   2⎞ ⎛        2                        2                        2                        
⎢                                                                   L₁⋅⎝- L₁⋅L₂⋅L₃ ⋅m₂⋅m₃⋅cos(t₁ - t₂) - L₁⋅L₂⋅L₃ ⋅m₃ ⋅cos(t₁ - t₂) + L₁⋅L₂⋅L₃ ⋅m₃ ⋅cos(t₁ - t₃)⋅cos(t₂ - t₃)⎠⋅⎝L₂⋅m₂⋅ṫ₂ ⋅sin(t₁ - t₂) + L₂⋅m₃⋅ṫ₂ ⋅sin(t₁ - t₂) + L₃⋅m₃⋅ṫ₃ ⋅sin(t₁ - t₃) + g⋅m₁⋅sin(t₁) + g⋅m₂⋅sin(t₁) + g⋅m₃⋅sin(t₁)⎠ - L₂⋅⎝L₁ ⋅L₃ ⋅m₁⋅m₃ + L₁ ⋅L₃ ⋅m₂⋅m₃ - L₁ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₃ ⋅m₃ ⎠⋅⎝L₁⋅m₂⋅ṫ₁ ⋅sin(t₁ - t₂) + L₁⋅m₃⋅ṫ₁ ⋅sin(t₁ - t₂) - L₃⋅m₃⋅ṫ₃ ⋅sin(t₂ - t₃) - g⋅
⎢                                                                   ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
⎢                                                                                                                                                    2   2   2              2   2   2      2    2              2   2   2      2     2   2   2   2       2              2   2   2   2          2   2   2      2    2                2   2   2      2                                            2   2   2      2    2              2   2   2      2    2                2  
⎢                                                                                                                                                - L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₂⋅m₃ + L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₃ ⋅cos (t₂ - t₃) - L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₃  + L₁ ⋅L₂ ⋅L₃ ⋅m₂ ⋅m₃⋅cos (t₁ - t₂) - L₁ ⋅L₂ ⋅L₃ ⋅m₂ ⋅m₃ + 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₁ - t₂) - 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃)⋅cos(t₂ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₂ - t₃) - 2⋅L₁ ⋅L
⎢                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
⎢   ⎛     2                                           2                              2      2                                  2      2             ⎞ ⎛        2                        2                        2                                                          ⎞      ⎛        2                        2                        2                                           ⎞ ⎛    2                              2                                         
⎢L₁⋅⎝L₁⋅L₂ ⋅L₃⋅m₂⋅m₃⋅cos(t₁ - t₂)⋅cos(t₂ - t₃) - L₁⋅L₂ ⋅L₃⋅m₂⋅m₃⋅cos(t₁ - t₃) + L₁⋅L₂ ⋅L₃⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₂ - t₃) - L₁⋅L₂ ⋅L₃⋅m₃ ⋅cos(t₁ - t₃)⎠⋅⎝L₂⋅m₂⋅ṫ₂ ⋅sin(t₁ - t₂) + L₂⋅m₃⋅ṫ₂ ⋅sin(t₁ - t₂) + L₃⋅m₃⋅ṫ₃ ⋅sin(t₁ - t₃) + g⋅m₁⋅sin(t₁) + g⋅m₂⋅sin(t₁) + g⋅m₃⋅sin(t₁)⎠ - L₂⋅⎝L₁⋅m₂⋅ṫ₁ ⋅sin(t₁ - t₂) + L₁⋅m₃⋅ṫ₁ ⋅sin(t₁ - t₂) - L₃⋅m₃⋅ṫ₃ ⋅sin(t₂ - t₃) - g⋅m₂⋅sin(t₂) - g⋅m₃⋅sin(t₂)⎠⋅⎝- L₁ ⋅L₂⋅L₃⋅m₁⋅m₃⋅cos(t₂ - t₃) + L₁ ⋅L₂⋅L₃⋅m₂⋅m₃⋅cos(t₁ - t₂)⋅cos(t₁ - 
⎢─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
⎢                                                                                                                                                    2   2   2              2   2   2      2    2              2   2   2      2     2   2   2   2       2              2   2   2   2          2   2   2      2    2                2   2   2      2                                            2   2   2      2    2              2   2   2      2    2                2  
⎣                                                                                                                                                - L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₂⋅m₃ + L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₃ ⋅cos (t₂ - t₃) - L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₃  + L₁ ⋅L₂ ⋅L₃ ⋅m₂ ⋅m₃⋅cos (t₁ - t₂) - L₁ ⋅L₂ ⋅L₃ ⋅m₂ ⋅m₃ + 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₁ - t₂) - 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃)⋅cos(t₂ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₂ - t₃) - 2⋅L₁ ⋅L

                           ⎞         ⎛     2                     2                         ⎞ ⎛     2                                           2                              2      2                                  2      2             ⎞                                                                                            ⎤
t₃) - g⋅m₂⋅sin(t₂) - g⋅m₃⋅sin(t₂)⎠ - L₃⋅m₃⋅⎝L₁⋅ṫ₁ ⋅sin(t₁ - t₃) + L₂⋅ṫ₂ ⋅sin(t₂ - t₃) - g⋅sin(t₃)⎠⋅⎝L₁⋅L₂ ⋅L₃⋅m₂⋅m₃⋅cos(t₁ - t₂)⋅cos(t₂ - t₃) - L₁⋅L₂ ⋅L₃⋅m₂⋅m₃⋅cos(t₁ - t₃) + L₁⋅L₂ ⋅L₃⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₂ - t₃) - L₁⋅L₂ ⋅L₃⋅m₃ ⋅cos(t₁ - t₃)⎠                                                                                            ⎥
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────                                                                                            ⎥
2   2      2     2   2   2   3    2                2   2   2   3                                            2   2   2   3    2              2   2   2   3    2              2   2   2   3                                                                                                                                                 ⎥
 ⋅L₃ ⋅m₂⋅m₃  + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₂) - 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃)⋅cos(t₂ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₂ - t₃) - L₁ ⋅L₂ ⋅L₃ ⋅m₃                                                                                                                                                  ⎥
                                                                                                                                                                                                                                                                                                                                          ⎥
                   ⎞         ⎛     2                     2                         ⎞ ⎛    2                              2                                           2                              2         2                               2         2             ⎞                                                                   ⎥
m₂⋅sin(t₂) - g⋅m₃⋅sin(t₂)⎠ - L₃⋅m₃⋅⎝L₁⋅ṫ₁ ⋅sin(t₁ - t₃) + L₂⋅ṫ₂ ⋅sin(t₂ - t₃) - g⋅sin(t₃)⎠⋅⎝- L₁ ⋅L₂⋅L₃⋅m₁⋅m₃⋅cos(t₂ - t₃) + L₁ ⋅L₂⋅L₃⋅m₂⋅m₃⋅cos(t₁ - t₂)⋅cos(t₁ - t₃) - L₁ ⋅L₂⋅L₃⋅m₂⋅m₃⋅cos(t₂ - t₃) + L₁ ⋅L₂⋅L₃⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃) - L₁ ⋅L₂⋅L₃⋅m₃ ⋅cos(t₂ - t₃)⎠                                                                   ⎥
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────                                                                   ⎥
 2   2      2     2   2   2   3    2                2   2   2   3                                            2   2   2   3    2              2   2   2   3    2              2   2   2   3                                                                                                                                                ⎥
₂ ⋅L₃ ⋅m₂⋅m₃  + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₂) - 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃)⋅cos(t₂ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₂ - t₃) - L₁ ⋅L₂ ⋅L₃ ⋅m₃                                                                                                                                                 ⎥
                                                                                                                                                                                                                                                                                                                                          ⎥
  2                              2         2                               2         2             ⎞         ⎛     2                     2                         ⎞ ⎛  2   2           2   2           2   2   2    2              2   2   2       2   2          2                2   2           2   2   2    2              2   2   2⎞⎥
t₃) - L₁ ⋅L₂⋅L₃⋅m₂⋅m₃⋅cos(t₂ - t₃) + L₁ ⋅L₂⋅L₃⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃) - L₁ ⋅L₂⋅L₃⋅m₃ ⋅cos(t₂ - t₃)⎠ - L₃⋅m₃⋅⎝L₁⋅ṫ₁ ⋅sin(t₁ - t₃) + L₂⋅ṫ₂ ⋅sin(t₂ - t₃) - g⋅sin(t₃)⎠⋅⎝L₁ ⋅L₂ ⋅m₁⋅m₂ + L₁ ⋅L₂ ⋅m₁⋅m₃ - L₁ ⋅L₂ ⋅m₂ ⋅cos (t₁ - t₂) + L₁ ⋅L₂ ⋅m₂  - 2⋅L₁ ⋅L₂ ⋅m₂⋅m₃⋅cos (t₁ - t₂) + 2⋅L₁ ⋅L₂ ⋅m₂⋅m₃ - L₁ ⋅L₂ ⋅m₃ ⋅cos (t₁ - t₂) + L₁ ⋅L₂ ⋅m₃ ⎠⎥
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────⎥
 2   2      2     2   2   2   3    2                2   2   2   3                                            2   2   2   3    2              2   2   2   3    2              2   2   2   3                                                                                                                                                ⎥
₂ ⋅L₃ ⋅m₂⋅m₃  + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₂) - 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃)⋅cos(t₂ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₂ - t₃) - L₁ ⋅L₂ ⋅L₃ ⋅m₃                                                                                                                                                 ⎦

需要一段时间才能简化这一点。但实际上并没有变得更简单。 SO字符限制使我无法粘贴以下简化(SOL)的结果。

Firstly it is generally better in SymPy to avoid the use of floats so change 1/2 to Rational(1, 2) or S.Half or S(1)/2 etc.

The expressions involved here are quite long and complicated. I'm going to replace all the functions and derivatives with plain symbols so that we can see it a bit better:

t1, t2, t3 = symbols('t1:4')
dt1, dt2, dt3 = symbols('tdot1:4')
ddt1, ddt2, ddt3 = symbols('tddot1:4')

rep = {
        the1:t1, the2:t2, the3:t3,
        the1_d:dt1, the2_d:dt2, the3_d:dt3,
        the1_dd:ddt1, the2_dd:ddt2, the3_dd:ddt3,
        }

eqs = [eq.subs(rep).trigsimp() for eq in [LE1, LE2, LE3]]
syms = [ddt1, ddt2, ddt3]

I also used trigsimp there to reduce using trig which does take some time. (There are various ways you can speed that up if you know exactly what type of simplification you are looking for.)

Now that they are a bit simpler let's take a look at these equations:

In [4]: for eq in eqs: pprint(eq)
    ⎛                                                                 2                                                2                                                2                                                          ⎞
-L₁⋅⎝L₁⋅m₁⋅ẗ₁ + L₁⋅m₂⋅ẗ₁ + L₁⋅m₃⋅ẗ₁ + L₂⋅m₂⋅ẗ₂⋅cos(t₁ - t₂) + L₂⋅m₂⋅ṫ₂ ⋅sin(t₁ - t₂) + L₂⋅m₃⋅ẗ₂⋅cos(t₁ - t₂) + L₂⋅m₃⋅ṫ₂ ⋅sin(t₁ - t₂) + L₃⋅m₃⋅ẗ₃⋅cos(t₁ - t₃) + L₃⋅m₃⋅ṫ₃ ⋅sin(t₁ - t₃) + g⋅m₁⋅sin(t₁) + g⋅m₂⋅sin(t₁) + g⋅m₃⋅sin(t₁)⎠
   ⎛                                 2                                                2                                                                      2                                           ⎞
L₂⋅⎝-L₁⋅m₂⋅ẗ₁⋅cos(t₁ - t₂) + L₁⋅m₂⋅ṫ₁ ⋅sin(t₁ - t₂) - L₁⋅m₃⋅ẗ₁⋅cos(t₁ - t₂) + L₁⋅m₃⋅ṫ₁ ⋅sin(t₁ - t₂) - L₂⋅m₂⋅ẗ₂ - L₂⋅m₃⋅ẗ₂ - L₃⋅m₃⋅ẗ₃⋅cos(t₂ - t₃) - L₃⋅m₃⋅ṫ₃ ⋅sin(t₂ - t₃) - g⋅m₂⋅sin(t₂) - g⋅m₃⋅sin(t₂)⎠
      ⎛                           2                                          2                                 ⎞
L₃⋅m₃⋅⎝-L₁⋅ẗ₁⋅cos(t₁ - t₃) + L₁⋅ṫ₁ ⋅sin(t₁ - t₃) - L₂⋅ẗ₂⋅cos(t₂ - t₃) + L₂⋅ṫ₂ ⋅sin(t₂ - t₃) - L₃⋅ẗ₃ - g⋅sin(t₃)⎠

So we want to solve for the double dot symbols and we can see that it's all just linear so we can convert this into matrices:

In [5]: A, b = linear_eq_to_matrix(eqs, syms)

In [6]: A
Out[6]: 
⎡         -L₁⋅(L₁⋅m₁ + L₁⋅m₂ + L₁⋅m₃)           -L₁⋅(L₂⋅m₂⋅cos(t₁ - t₂) + L₂⋅m₃⋅cos(t₁ - t₂))  -L₁⋅L₃⋅m₃⋅cos(t₁ - t₃)⎤
⎢                                                                                                                    ⎥
⎢L₂⋅(-L₁⋅m₂⋅cos(t₁ - t₂) - L₁⋅m₃⋅cos(t₁ - t₂))               L₂⋅(-L₂⋅m₂ - L₂⋅m₃)               -L₂⋅L₃⋅m₃⋅cos(t₂ - t₃)⎥
⎢                                                                                                                    ⎥
⎢                                                                                                        2           ⎥
⎣           -L₁⋅L₃⋅m₃⋅cos(t₁ - t₃)                         -L₂⋅L₃⋅m₃⋅cos(t₂ - t₃)                     -L₃ ⋅m₃        ⎦

In [7]: b
Out[7]: 
⎡   ⎛        2                        2                        2                                                          ⎞⎤
⎢L₁⋅⎝L₂⋅m₂⋅ṫ₂ ⋅sin(t₁ - t₂) + L₂⋅m₃⋅ṫ₂ ⋅sin(t₁ - t₂) + L₃⋅m₃⋅ṫ₃ ⋅sin(t₁ - t₃) + g⋅m₁⋅sin(t₁) + g⋅m₂⋅sin(t₁) + g⋅m₃⋅sin(t₁)⎠⎥
⎢                                                                                                                          ⎥
⎢           ⎛        2                        2                        2                                           ⎞       ⎥
⎢       -L₂⋅⎝L₁⋅m₂⋅ṫ₁ ⋅sin(t₁ - t₂) + L₁⋅m₃⋅ṫ₁ ⋅sin(t₁ - t₂) - L₃⋅m₃⋅ṫ₃ ⋅sin(t₂ - t₃) - g⋅m₂⋅sin(t₂) - g⋅m₃⋅sin(t₂)⎠       ⎥
⎢                                                                                                                          ⎥
⎢                                     ⎛     2                     2                         ⎞                              ⎥
⎣                              -L₃⋅m₃⋅⎝L₁⋅ṫ₁ ⋅sin(t₁ - t₃) + L₂⋅ṫ₂ ⋅sin(t₂ - t₃) - g⋅sin(t₃)⎠                              ⎦

Directly computing the inverse here happens to be a bit slow but we can do it faster using adjugate:

In [8]: sol = A.adjugate()*b/A.det()

In [9]: sol
Out[9]: 
⎡                                                                                              ⎛  2   2           2   2   2    2              2   2   2⎞ ⎛        2                        2                        2                                                          ⎞      ⎛          2                              2   2                        2   2                          ⎞ ⎛        2                        2                        2                
⎢                                                                                           L₁⋅⎝L₂ ⋅L₃ ⋅m₂⋅m₃ - L₂ ⋅L₃ ⋅m₃ ⋅cos (t₂ - t₃) + L₂ ⋅L₃ ⋅m₃ ⎠⋅⎝L₂⋅m₂⋅ṫ₂ ⋅sin(t₁ - t₂) + L₂⋅m₃⋅ṫ₂ ⋅sin(t₁ - t₂) + L₃⋅m₃⋅ṫ₃ ⋅sin(t₁ - t₃) + g⋅m₁⋅sin(t₁) + g⋅m₂⋅sin(t₁) + g⋅m₃⋅sin(t₁)⎠ - L₂⋅⎝- L₁⋅L₂⋅L₃ ⋅m₂⋅m₃⋅cos(t₁ - t₂) - L₁⋅L₂⋅L₃ ⋅m₃ ⋅cos(t₁ - t₂) + L₁⋅L₂⋅L₃ ⋅m₃ ⋅cos(t₁ - t₃)⋅cos(t₂ - t₃)⎠⋅⎝L₁⋅m₂⋅ṫ₁ ⋅sin(t₁ - t₂) + L₁⋅m₃⋅ṫ₁ ⋅sin(t₁ - t₂) - L₃⋅m₃⋅ṫ₃ ⋅sin(t₂ - 
⎢                                                                                           ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
⎢                                                                                                                                                   2   2   2              2   2   2      2    2              2   2   2      2     2   2   2   2       2              2   2   2   2          2   2   2      2    2                2   2   2      2                                            2   2   2      2    2              2   2   2      2    2                2   
⎢                                                                                                                                               - L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₂⋅m₃ + L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₃ ⋅cos (t₂ - t₃) - L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₃  + L₁ ⋅L₂ ⋅L₃ ⋅m₂ ⋅m₃⋅cos (t₁ - t₂) - L₁ ⋅L₂ ⋅L₃ ⋅m₂ ⋅m₃ + 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₁ - t₂) - 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃)⋅cos(t₂ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₂ - t₃) - 2⋅L₁ ⋅L₂
⎢                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
⎢                                                                      ⎛          2                              2   2                        2   2                          ⎞ ⎛        2                        2                        2                                                          ⎞      ⎛  2   2           2   2           2   2   2    2              2   2   2⎞ ⎛        2                        2                        2                        
⎢                                                                   L₁⋅⎝- L₁⋅L₂⋅L₃ ⋅m₂⋅m₃⋅cos(t₁ - t₂) - L₁⋅L₂⋅L₃ ⋅m₃ ⋅cos(t₁ - t₂) + L₁⋅L₂⋅L₃ ⋅m₃ ⋅cos(t₁ - t₃)⋅cos(t₂ - t₃)⎠⋅⎝L₂⋅m₂⋅ṫ₂ ⋅sin(t₁ - t₂) + L₂⋅m₃⋅ṫ₂ ⋅sin(t₁ - t₂) + L₃⋅m₃⋅ṫ₃ ⋅sin(t₁ - t₃) + g⋅m₁⋅sin(t₁) + g⋅m₂⋅sin(t₁) + g⋅m₃⋅sin(t₁)⎠ - L₂⋅⎝L₁ ⋅L₃ ⋅m₁⋅m₃ + L₁ ⋅L₃ ⋅m₂⋅m₃ - L₁ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₃ ⋅m₃ ⎠⋅⎝L₁⋅m₂⋅ṫ₁ ⋅sin(t₁ - t₂) + L₁⋅m₃⋅ṫ₁ ⋅sin(t₁ - t₂) - L₃⋅m₃⋅ṫ₃ ⋅sin(t₂ - t₃) - g⋅
⎢                                                                   ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
⎢                                                                                                                                                    2   2   2              2   2   2      2    2              2   2   2      2     2   2   2   2       2              2   2   2   2          2   2   2      2    2                2   2   2      2                                            2   2   2      2    2              2   2   2      2    2                2  
⎢                                                                                                                                                - L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₂⋅m₃ + L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₃ ⋅cos (t₂ - t₃) - L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₃  + L₁ ⋅L₂ ⋅L₃ ⋅m₂ ⋅m₃⋅cos (t₁ - t₂) - L₁ ⋅L₂ ⋅L₃ ⋅m₂ ⋅m₃ + 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₁ - t₂) - 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃)⋅cos(t₂ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₂ - t₃) - 2⋅L₁ ⋅L
⎢                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
⎢   ⎛     2                                           2                              2      2                                  2      2             ⎞ ⎛        2                        2                        2                                                          ⎞      ⎛        2                        2                        2                                           ⎞ ⎛    2                              2                                         
⎢L₁⋅⎝L₁⋅L₂ ⋅L₃⋅m₂⋅m₃⋅cos(t₁ - t₂)⋅cos(t₂ - t₃) - L₁⋅L₂ ⋅L₃⋅m₂⋅m₃⋅cos(t₁ - t₃) + L₁⋅L₂ ⋅L₃⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₂ - t₃) - L₁⋅L₂ ⋅L₃⋅m₃ ⋅cos(t₁ - t₃)⎠⋅⎝L₂⋅m₂⋅ṫ₂ ⋅sin(t₁ - t₂) + L₂⋅m₃⋅ṫ₂ ⋅sin(t₁ - t₂) + L₃⋅m₃⋅ṫ₃ ⋅sin(t₁ - t₃) + g⋅m₁⋅sin(t₁) + g⋅m₂⋅sin(t₁) + g⋅m₃⋅sin(t₁)⎠ - L₂⋅⎝L₁⋅m₂⋅ṫ₁ ⋅sin(t₁ - t₂) + L₁⋅m₃⋅ṫ₁ ⋅sin(t₁ - t₂) - L₃⋅m₃⋅ṫ₃ ⋅sin(t₂ - t₃) - g⋅m₂⋅sin(t₂) - g⋅m₃⋅sin(t₂)⎠⋅⎝- L₁ ⋅L₂⋅L₃⋅m₁⋅m₃⋅cos(t₂ - t₃) + L₁ ⋅L₂⋅L₃⋅m₂⋅m₃⋅cos(t₁ - t₂)⋅cos(t₁ - 
⎢─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
⎢                                                                                                                                                    2   2   2              2   2   2      2    2              2   2   2      2     2   2   2   2       2              2   2   2   2          2   2   2      2    2                2   2   2      2                                            2   2   2      2    2              2   2   2      2    2                2  
⎣                                                                                                                                                - L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₂⋅m₃ + L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₃ ⋅cos (t₂ - t₃) - L₁ ⋅L₂ ⋅L₃ ⋅m₁⋅m₃  + L₁ ⋅L₂ ⋅L₃ ⋅m₂ ⋅m₃⋅cos (t₁ - t₂) - L₁ ⋅L₂ ⋅L₃ ⋅m₂ ⋅m₃ + 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₁ - t₂) - 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃)⋅cos(t₂ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₂⋅m₃ ⋅cos (t₂ - t₃) - 2⋅L₁ ⋅L

                           ⎞         ⎛     2                     2                         ⎞ ⎛     2                                           2                              2      2                                  2      2             ⎞                                                                                            ⎤
t₃) - g⋅m₂⋅sin(t₂) - g⋅m₃⋅sin(t₂)⎠ - L₃⋅m₃⋅⎝L₁⋅ṫ₁ ⋅sin(t₁ - t₃) + L₂⋅ṫ₂ ⋅sin(t₂ - t₃) - g⋅sin(t₃)⎠⋅⎝L₁⋅L₂ ⋅L₃⋅m₂⋅m₃⋅cos(t₁ - t₂)⋅cos(t₂ - t₃) - L₁⋅L₂ ⋅L₃⋅m₂⋅m₃⋅cos(t₁ - t₃) + L₁⋅L₂ ⋅L₃⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₂ - t₃) - L₁⋅L₂ ⋅L₃⋅m₃ ⋅cos(t₁ - t₃)⎠                                                                                            ⎥
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────                                                                                            ⎥
2   2      2     2   2   2   3    2                2   2   2   3                                            2   2   2   3    2              2   2   2   3    2              2   2   2   3                                                                                                                                                 ⎥
 ⋅L₃ ⋅m₂⋅m₃  + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₂) - 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃)⋅cos(t₂ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₂ - t₃) - L₁ ⋅L₂ ⋅L₃ ⋅m₃                                                                                                                                                  ⎥
                                                                                                                                                                                                                                                                                                                                          ⎥
                   ⎞         ⎛     2                     2                         ⎞ ⎛    2                              2                                           2                              2         2                               2         2             ⎞                                                                   ⎥
m₂⋅sin(t₂) - g⋅m₃⋅sin(t₂)⎠ - L₃⋅m₃⋅⎝L₁⋅ṫ₁ ⋅sin(t₁ - t₃) + L₂⋅ṫ₂ ⋅sin(t₂ - t₃) - g⋅sin(t₃)⎠⋅⎝- L₁ ⋅L₂⋅L₃⋅m₁⋅m₃⋅cos(t₂ - t₃) + L₁ ⋅L₂⋅L₃⋅m₂⋅m₃⋅cos(t₁ - t₂)⋅cos(t₁ - t₃) - L₁ ⋅L₂⋅L₃⋅m₂⋅m₃⋅cos(t₂ - t₃) + L₁ ⋅L₂⋅L₃⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃) - L₁ ⋅L₂⋅L₃⋅m₃ ⋅cos(t₂ - t₃)⎠                                                                   ⎥
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────                                                                   ⎥
 2   2      2     2   2   2   3    2                2   2   2   3                                            2   2   2   3    2              2   2   2   3    2              2   2   2   3                                                                                                                                                ⎥
₂ ⋅L₃ ⋅m₂⋅m₃  + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₂) - 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃)⋅cos(t₂ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₂ - t₃) - L₁ ⋅L₂ ⋅L₃ ⋅m₃                                                                                                                                                 ⎥
                                                                                                                                                                                                                                                                                                                                          ⎥
  2                              2         2                               2         2             ⎞         ⎛     2                     2                         ⎞ ⎛  2   2           2   2           2   2   2    2              2   2   2       2   2          2                2   2           2   2   2    2              2   2   2⎞⎥
t₃) - L₁ ⋅L₂⋅L₃⋅m₂⋅m₃⋅cos(t₂ - t₃) + L₁ ⋅L₂⋅L₃⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃) - L₁ ⋅L₂⋅L₃⋅m₃ ⋅cos(t₂ - t₃)⎠ - L₃⋅m₃⋅⎝L₁⋅ṫ₁ ⋅sin(t₁ - t₃) + L₂⋅ṫ₂ ⋅sin(t₂ - t₃) - g⋅sin(t₃)⎠⋅⎝L₁ ⋅L₂ ⋅m₁⋅m₂ + L₁ ⋅L₂ ⋅m₁⋅m₃ - L₁ ⋅L₂ ⋅m₂ ⋅cos (t₁ - t₂) + L₁ ⋅L₂ ⋅m₂  - 2⋅L₁ ⋅L₂ ⋅m₂⋅m₃⋅cos (t₁ - t₂) + 2⋅L₁ ⋅L₂ ⋅m₂⋅m₃ - L₁ ⋅L₂ ⋅m₃ ⋅cos (t₁ - t₂) + L₁ ⋅L₂ ⋅m₃ ⎠⎥
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────⎥
 2   2      2     2   2   2   3    2                2   2   2   3                                            2   2   2   3    2              2   2   2   3    2              2   2   2   3                                                                                                                                                ⎥
₂ ⋅L₃ ⋅m₂⋅m₃  + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₂) - 2⋅L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos(t₁ - t₂)⋅cos(t₁ - t₃)⋅cos(t₂ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₁ - t₃) + L₁ ⋅L₂ ⋅L₃ ⋅m₃ ⋅cos (t₂ - t₃) - L₁ ⋅L₂ ⋅L₃ ⋅m₃                                                                                                                                                 ⎦

It takes a while to simplify this but doesn't really get much simpler. The SO character limit prevents me from pasting the result of simplify(sol) below though.

Sympy解决了保持运行,不停止

玩心态 2025-02-12 14:43:48

使用调试提供商,并在Firebase中添加调试令牌。

请参阅使用flutter flutter 的Depug proffors使用应用程序检查。

这样的iOS的东西:

@objc class AppDelegate: FlutterAppDelegate {
    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        let providerFactory = AppCheckDebugProviderFactory()
        AppCheck.setAppCheckProviderFactory(providerFactory)

        FirebaseApp.configure()
...

Use the debug provider and add a debug token to Firebase.

See Use App Check with the debug provider with Flutter.

Something like this for iOS:

@objc class AppDelegate: FlutterAppDelegate {
    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        let providerFactory = AppCheckDebugProviderFactory()
        AppCheck.setAppCheckProviderFactory(providerFactory)

        FirebaseApp.configure()
...

将AppCheck与Flutter一起使用,被限制在Firestore身上

玩心态 2025-02-12 13:18:43

尝试以下内容:

       const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(FILENAME);
            XElement img = doc.Descendants("img").First();
            string style = "width: 250px";
            string align = "middle";
            string alt = "E-Fatura Logo";
            string src = "data:image/jpeg";
            string base64Text = "the text here";
            img.Add(new object[] {
                new XAttribute("style", style),
                new XAttribute("align", align),
                new XAttribute("alt", alt),
                new XAttribute("src", src),
                base64Text
            });
        }

Try following :

       const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(FILENAME);
            XElement img = doc.Descendants("img").First();
            string style = "width: 250px";
            string align = "middle";
            string alt = "E-Fatura Logo";
            string src = "data:image/jpeg";
            string base64Text = "the text here";
            img.Add(new object[] {
                new XAttribute("style", style),
                new XAttribute("align", align),
                new XAttribute("alt", alt),
                new XAttribute("src", src),
                base64Text
            });
        }

检索数据并使用C#从XML文件更新数据

玩心态 2025-02-12 08:36:38

字段定界符类型是char(积分类型),因此+ s_fielddelimiterint+符号是指出数字是正面的就像在数学中一样),最后可以用来进行指针算术,因为字符串字面类型是“ const char char*”。

The field delimiter type is char (integral type), so + s_fieldDelimiter is an int (the + sign is to signal that the number is positive just like in maths) and this last can be used to do pointer arithmetic since the string literal type is a "const char*".

加上新行开头的签名和代码编译

玩心态 2025-02-12 05:08:58

Y是一个系列,您可以尝试以下内容选择第二个(1243885949697888263)值

print(y.array[0])

y is a series, you can try as follow to pick second (1243885949697888263) value

print(y.array[0])

仅从熊猫数据框行保存值

玩心态 2025-02-12 03:07:00

在您的onCreate()方法中,进行以下更改

添加

cname = findViewById(R.id.CName);
cAdd = findViewById(R.id.cAdd);

而不是

cname.findViewById(R.id.CName);
cAdd.findViewById(R.id.cAdd);

in your onCreate() method, make the below changes

add

cname = findViewById(R.id.CName);
cAdd = findViewById(R.id.cAdd);

instead of

cname.findViewById(R.id.CName);
cAdd.findViewById(R.id.cAdd);

嗨,我是Android Studio的新手。我正在尝试转到下一个窗口,但是当我单击按钮时,应用程序崩溃了。这是我的代码

玩心态 2025-02-11 23:22:57

1。对于其他许多人来说,这是第一个绊脚石

,我与异步电话的相遇起初令人困惑。
我不记得细节,但我可能尝试了类似的事情:

let result;

$.ajax({
  url: 'https://jsonplaceholder.typicode.com/todos/1',
  success: function (response) {
    console.log('\nInside $.ajax:');
    console.log(response);
    result = response;
  },
});

console.log('Finally, the result: ' + result);
.as-console-wrapper { max-height: 100% !important; top: 0; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

whops!
线的输出
console.log('最后,结果:' +结果);
我认为将在另一个输出之前打印出上次
- 并且它不包含结果:它只是打印未定义的1
怎么会?

一个有用的见解,

我清楚地记得我的第一个 aha

1. A first stumbling step

As for many others, my encounter with asynchronous calls was puzzling at first.
I don't remember the details, but I may have tried something like:

let result;

$.ajax({
  url: 'https://jsonplaceholder.typicode.com/todos/1',
  success: function (response) {
    console.log('\nInside $.ajax:');
    console.log(response);
    result = response;
  },
});

console.log('Finally, the result: ' + result);
.as-console-wrapper { max-height: 100% !important; top: 0; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

Whoops!
The output of the line
console.log('Finally, the result: ' + result);
which I thought would be printed last, is printed before the other output!
– And it doesn't contain the result: it just prints undefined. 1
How come?

A helpful insight

I distinctly remember my first aha (????) moment about asynchronous calls.
It was :

you actually don't want to get the data out of a callback; you want to get your data-needing action into the callback!
2

This is true in the example above.

2. Plain JavaScript and a callback function

Luckily, it is possible to write code after the asynchronous call that deals with the response once it has completed.

One alternative is the use of a callback function in a continuation-passing style :
3

const url = 'https://jsonplaceholder.typicode.com/todos/2';

function asynchronousFunc(callback) {
  const request = new XMLHttpRequest();
  request.open('GET', url);
  request.send();
  request.onload = function () {
    if (request.readyState === request.DONE) {
      console.log('The request is done. Now calling back.');
      callback(request.responseText);
    }
  };
}

asynchronousFunc(function (result) {
  console.log('This is the start of the callback function. Result:');
  console.log(result);
  console.log('The callback function finishes on this line. THE END!');
});

console.log('LAST in the code, but executed FIRST!');
.as-console-wrapper { max-height: 100% !important; top: 0; }

Note how the function asynchronousFunc is void. It returns nothing.
asynchronousFunc is called with an anonymous callback function,
(asynchronousFunc(function (result) {...});).
This executes the desired actions on the result after the request has completed – when the responseText is available.

Running the above snippet shows how I will probably not want to write any code after the asynchronous call (such as the line
LAST in the code, but executed FIRST!).
Why? – Because such code will run before the asynchronous call delivers any response data.
Doing so is bound to cause confusion when comparing the code with the output.

3. Promise with .then()

The .then() construct was introduced in the ECMA-262 6th Edition in June 2015.
The code below is plain JavaScript, replacing the old-school XMLHttpRequest with Fetch. 4

fetch('https://api.chucknorris.io/jokes/random')
  .then((response) => response.json())
  .then((responseBody) => {
    console.log('Using .then() :');
    console.log(responseBody.value + '\n');
  });
.as-console-wrapper { max-height: 100% !important; top: 0; }

4. Promise with async/await

The async/await construct was introduced in the ECMA-262 8th Edition in June 2017.

async function awaitAndReceivePromise() {
  const responseBody = (
    await fetch('https://api.quotable.io/quotes/random')
  ).json();
  console.log('Using async/await:');
  const obj = (await responseBody)[0];
  console.log('"' + obj.content + '" – ' + obj.author + '\n');
}

awaitAndReceivePromise();
.as-console-wrapper { max-height: 100% !important; top: 0; }

A word of warning is warranted if you decide to go with the async/await construct.
Note in the above snippet how await is needed in two places.
If forgotten in the first place, there will be no output at all.
If forgotten in the second place, the only output will be Using async/await: – nothing else gets printed.
Forgetting the async prefix of the function is maybe the worst of all – you'll get a "SyntaxError" – and likely no hint about the missing async keyword.


All the above examples succinctly convey how asynchronous calls may be used on toyish APIs. 5

References


1
Expressed by the asker of the question as they all return undefined.

2
Here is more on how asynchronous calls may be confusing at first.

3
Like the X in AJAX, the name XMLHttpRequest is misleading – it can be used to retrieve any type of data, not just XML.
These days, the data format of Web APIs is ubiquitously JSON, not XML.

4
Fetch returns a Promise.
I was surprised to learn that neither XMLHttpRequest nor Fetch are part of the ECMAScript standard.
The reason JavaScript can access them here is that the web browser provides them.
The Fetch Standard and the XMLHttpRequest Standard are both upheld by the Web Hypertext Application Technology Working Group which was formed in June 2004. \

5
You might also be interested in
How can I fetch an array of URLs with Promise.all?.

如何从异步电话中返回响应?

玩心态 2025-02-10 20:58:37

您需要构建自己的RestTemplate类,该类扩展了现有RESTTEMPLATE类,该类提供了返回预期响应类型的方法的方法。

之后,我提供了一个小示例,显示了您可以实现它的方法:

public class FooRestTemplate extends RestTemplate {
    public <T> Optional<T> getForObjectAsOptional(final URI url, Class<T> responseType) throws RestClientException {
        try {
            return Optional.ofNullable(super.getForObject(url, responseType));
        } catch (HttpClientErrorException ex) {
            logger.error("Error: ", ex);
            return Optional.empty();
        }
    }
}

这只是一个简单的示例。
您也可以扩展捕获块。例如,返回可选。

public class FooOptionalEmptyNotFoundRestTemplate extends RestTemplate {
    public <T> Optional<T> getForObjectAsOptional(final URI url, Class<T> responseType) throws RestClientException {
        try {
            return Optional.ofNullable(super.getForObject(url, responseType));
        } catch (HttpClientErrorException ex) {                
            if(ex.getStatusCode().equals(HttpStatus.NOT_FOUND)) {
                return Optional.empty();
            }
            
            logger.error("Error: ", ex);
            throw ex;
        }
    }
}

You need to build your own RestTemplate class extending the existing RestTemplate class which provides a method returning an optional of the expected response type.

Following I've provided a small example showing a way you could implement it:

public class FooRestTemplate extends RestTemplate {
    public <T> Optional<T> getForObjectAsOptional(final URI url, Class<T> responseType) throws RestClientException {
        try {
            return Optional.ofNullable(super.getForObject(url, responseType));
        } catch (HttpClientErrorException ex) {
            logger.error("Error: ", ex);
            return Optional.empty();
        }
    }
}

This is just a simple example.
You could also extend the catch block. For example return Optional.empty() only if the status code equals 404 not found:

public class FooOptionalEmptyNotFoundRestTemplate extends RestTemplate {
    public <T> Optional<T> getForObjectAsOptional(final URI url, Class<T> responseType) throws RestClientException {
        try {
            return Optional.ofNullable(super.getForObject(url, responseType));
        } catch (HttpClientErrorException ex) {                
            if(ex.getStatusCode().equals(HttpStatus.NOT_FOUND)) {
                return Optional.empty();
            }
            
            logger.error("Error: ", ex);
            throw ex;
        }
    }
}

如何获得可选类型作为RESTTEMPLATE的响应

玩心态 2025-02-10 17:01:33

您需要在您声明的ResourceDictionary内部放置DataTemplate,ControlEtemplate和样式定义,而不仅仅是USERCONTROL内部。Resources标签:

<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Inspectieprogramma;component/Styles/RadDatetimePickerStyle.xaml" />
        </ResourceDictionary.MergedDictionaries>

        ...
        DataTemplate, ControleTemplate and Style definitions
        ...
    </ResourceDictionary>
</UserControl.Resources>

you need to place DataTemplate, ControleTemplate and Style definitions inside ResourceDictionary you declare, not just inside UserControl.Resources tag:

<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Inspectieprogramma;component/Styles/RadDatetimePickerStyle.xaml" />
        </ResourceDictionary.MergedDictionaries>

        ...
        DataTemplate, ControleTemplate and Style definitions
        ...
    </ResourceDictionary>
</UserControl.Resources>

Silverlight 5&#x2B;的转换RIA到WPF问题

玩心态 2025-02-10 16:20:58

从HighCharts 11(2023)开始,您现在可以使用他们称为“助手”的“助手”以像抛光符号的格式添加逻辑。因此,您可以做类似的事情:

"tooltip":{
      "pointFormat":"{add point.y 1}"
   }

如果您需要进行其他格式(例如添加一千个分隔符),则可以通过将其包裹在类似的括号中来将其数学逻辑放在子表达中:

"tooltip":{
      "pointFormat":"{(add point.y 1):,f}"
   }

您可以做很多很酷的事情有了它,就像编写自己的自定义助手一样。更多信息在此处: https://www.highcharts.com/docs/docs/docs/docs/docs/chart-conepts/模板

我更喜欢它,而不是回调方法,因为它允许我以JSON格式存储HighCharts配置,但这对您来说可能并不重要。

As of Highcharts 11 (2023), you can now add logic into formatting strings, using what they call "helpers" in a format that's like Polish Notation. So you could do something like this:

"tooltip":{
      "pointFormat":"{add point.y 1}"
   }

and if you needed to do additional formatting (like adding a thousands separator), you could put your math logic into a subexpression by wrapping it in parentheses like this:

"tooltip":{
      "pointFormat":"{(add point.y 1):,f}"
   }

There's a lot of cool stuff you can do with it, like writing your own custom helpers. More info here: https://www.highcharts.com/docs/chart-concepts/templating

I prefer this over the callback method because it allows me to store the highcharts config in JSON format, but this may not matter for you.

HighCharts用特定数字总结工具提示{point.y}

玩心态 2025-02-10 11:27:43

如果您查看main方法的Javadoc:

  /**
   * Expects the following parameters: 
   * <ul>
   *   <li>-classifier "classifier incl. parameters"</li>
   *   <li>-exptype "classification|regression"</li>
   *   <li>-splittype "crossvalidation|randomsplit"</li>
   *   <li>-runs "# of runs"</li>
   *   <li>-folds "# of cross-validation folds"</li>
   *   <li>-percentage "percentage for randomsplit"</li>
   *   <li>-result "arff file for storing the results"</li>
   *   <li>-t "dataset" (can be supplied multiple times)</li>
   * </ul>
   * 
   * @param args    the commandline arguments
   * @throws Exception  if something goes wrong
   */

这些是您在执行主方法时必须提供的参数(如java.lang.string array) 。此示例类旨在从带有参数的命令行调用。

这是命令行的一个示例:

java -cp weka.jar:. ExperimentDemo -classifier "weka.classifiers.trees.J48 -M 2" -exptype classification -splittype crossvalidation -runs 10 -folds 10 -result results.arff -t dataset.arff

nb:此命令假定Linux(使用;作为Windows下的路径分离器),并且weka.jar.jar 文件,上述示例类的类文件和数据集dataset.arff都在当前目录中。

或者,如果您想自己调用MAIN方法,请相应地构造字符串数组:

String[] options = new String[]{
  "-classifier",
  "weka.classifiers.trees.J48 -M 2",
  "-exptype",
  "classification",
  "-splittype",
  "crossvalidation",
  "-runs",
  "10",
  "-folds",
  "10",
  "-result",
  "results.arff",
  "-t",
  "dataset.arff"
};

If you take a look at the Javadoc of the main method:

  /**
   * Expects the following parameters: 
   * <ul>
   *   <li>-classifier "classifier incl. parameters"</li>
   *   <li>-exptype "classification|regression"</li>
   *   <li>-splittype "crossvalidation|randomsplit"</li>
   *   <li>-runs "# of runs"</li>
   *   <li>-folds "# of cross-validation folds"</li>
   *   <li>-percentage "percentage for randomsplit"</li>
   *   <li>-result "arff file for storing the results"</li>
   *   <li>-t "dataset" (can be supplied multiple times)</li>
   * </ul>
   * 
   * @param args    the commandline arguments
   * @throws Exception  if something goes wrong
   */

These are the parameters (as java.lang.String array) that you have to supply when executing the main method. This example class is designed to be called from the command-line with parameters.

Here is an example for a command-line:

java -cp weka.jar:. ExperimentDemo -classifier "weka.classifiers.trees.J48 -M 2" -exptype classification -splittype crossvalidation -runs 10 -folds 10 -result results.arff -t dataset.arff

NB: This command assumes Linux (use ; as path separator under Windows) and that the weka.jar file, the class file of the aforementioned example class and the dataset dataset.arff are all in the current directory.

Or if you want to call the main method yourself, construct a String array accordingly:

String[] options = new String[]{
  "-classifier",
  "weka.classifiers.trees.J48 -M 2",
  "-exptype",
  "classification",
  "-splittype",
  "crossvalidation",
  "-runs",
  "10",
  "-folds",
  "10",
  "-result",
  "results.arff",
  "-t",
  "dataset.arff"
};

WEKA对API的实验“ Exptype”

玩心态 2025-02-10 07:39:35

sha1($ _ post ['l_pass'])是一个函数调用,而不是变量。您不能通过参考通过其结果。只需事先调用该函数,然后将其结果分配给变量 - 然后,您可以将其传递给bind_param():

$query = $con->prepare("SELECT id FROM librarian WHERE username = ? AND password = ?;");
$pass_hashed = sha1($_POST['l_pass'])
$query->bind_param("ss", $_POST['l_user'], $pass_hashed);
$query->execute();

nb sha-1 is 众所周知的被密码损坏和不安全 - 多年来(在撰写本文时)是这种情况。建议您停止使用它,然后切换到更新的最新情况,请使用算法来放置密码。您可以了解php的内置,最新,安全,安全 passwort验证功能而不是。另请参阅验证密码

sha1($_POST['l_pass']) is a function call, not a variable. You can't pass its result by reference. Simply call the function beforehand and assign its result to a variable - you can then pass this to bind_param():

$query = $con->prepare("SELECT id FROM librarian WHERE username = ? AND password = ?;");
$pass_hashed = sha1($_POST['l_pass'])
$query->bind_param("ss", $_POST['l_user'], $pass_hashed);
$query->execute();

N.B. SHA-1 is widely known to be cryptographically broken and insecure - this has been the case for some years now (at the time of writing). You would be stronly advised to stop using it and switch to a more up to date, secure algorithm for hashing your passwords. You can learn about PHP's built-in, up-to-date, secure password hashing and verification functions instead. See also How to use PHP's password_hash to hash and verify passwords

仅应在第44行上的参考文献传递变量

玩心态 2025-02-10 07:07:03

我建议您使用 ccxt库对于您要做的事情。

要检索Kucoin 现场市场订单:

import ccxt

exchange = ccxt.kucoin()

symbol = 'BTC/USDT'
order_book = exchange.fetchOrderBook(symbol)
print(order_book)

检索Kucoin 期货市场订单:

import ccxt

exchange = ccxt.kucoinfutures()

symbol = 'BTC/USDT:USDT'
order_book = exchange.fetchOrderBook(symbol)
print(order_book)

I recommend you use the CCXT library as it will make your life easier for what you are trying to do.

To retrieve Kucoin spot market order book:

import ccxt

exchange = ccxt.kucoin()

symbol = 'BTC/USDT'
order_book = exchange.fetchOrderBook(symbol)
print(order_book)

To retrieve Kucoin futures market order book:

import ccxt

exchange = ccxt.kucoinfutures()

symbol = 'BTC/USDT:USDT'
order_book = exchange.fetchOrderBook(symbol)
print(order_book)

Kucoin如何从API获取Futures的订单书?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文