问题列表 - 第318020页

如何使用路径过渡方法使节点绕圆旋转?

我正在尝试重新创建玻尔原子模型,此时我已经设法使电子相对于轨道中的电子总数具有足够的位置,但现在我正在努力使它们旋转围绕所述轨道。 我遇到的问题是路径过渡使它们从所述位置朝向轨道中心,而不是使它们围绕轨道旋转。

好吧,我有这个节点:

 @FXML
private Circle orbital;
@FXML
private Circle Electron;
@FXML
private Circle Electron2;
@FXML
private Circle Electron3;
Run Code Online (Sandbox Code Playgroud)

这是让它们旋转的方法:

  private void animate(Circle electron, Circle orbital, double angulo, int duration) {
    Path path = new Path();
    double anguloRadianes = Math.toRadians(angulo);//pass the angle to radians
    double X = orbital.getCenterX() + orbital.getRadius() * Math.cos(anguloRadianes);//calculate the x coordinate of the position of the electron
    double Y = orbital.getCenterY() + orbital.getRadius() * Math.sin(anguloRadianes);//calculate the y coordinate of the position of the electron
    path.getElements().add(new javafx.scene.shape.MoveTo(X, …
Run Code Online (Sandbox Code Playgroud)

java animation geometry javafx

4
推荐指数
1
解决办法
90
查看次数

在 C++ 编译期间提供链接库路径的 linux 命令是什么?

我记得看到过一些像这样工作的命令:

g++ main.cpp `some_forgotten_command --some_forgotten_options some_library`
Run Code Online (Sandbox Code Playgroud)

当命令运行时,它将用-I/path/to/some_library/includeand替换 `` 括起来的部分-L/path/to/some_library/lib/(或者类似的东西,我不太记得了)。但我不记得是什么some_forgotten_command了。

c++ linux linker dynamic-linking static-linking

1
推荐指数
1
解决办法
104
查看次数

Nodejs RangeError:指定的时区无效

我有测试示例:

console.log("test");

const t = new Date().toLocaleString("en-US", {
  timeZone: "+0000"
});

console.log(t);
Run Code Online (Sandbox Code Playgroud)

Google Chrome 122.0.6182.0(官方版本)开发版(64 位) Chrome浏览器

或者尝试: https: //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#try_it

在浏览器控制台中 - 好的,但在 Nodejs 中 - 错误

test

/home/jdoodle.js:3
const t = new Date().toLocaleString("en-US", {
                     ^

RangeError: Invalid time zone specified: +0000
    at Date.toLocaleString (<anonymous>)
    at Object.<anonymous> (/home/jdoodle.js:3:22)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v21.2.0
Run Code Online (Sandbox Code Playgroud)

示例: https: //www.jdoodle.com/ia/T3V

谁能向我解释为什么它不起作用以及如何使它起作用?

javascript node.js typescript

5
推荐指数
1
解决办法
123
查看次数

TypeScript 函数有两种类型推断错误

我打算changeSelectedItem成为其参数具有不同类型的两个函数之一。

type Props = {
  changeSelectedItem:
    | ((value: string) => void)
    | ((item: { displayValue: ReactNode; value: string }) => void);
}

function Component({ changeSelectedItem }: Props) {
  const onChange = (
    event: SelectChangeEvent<
      string | { displayValue: ReactNode; value: string }
    >
  ) => {
    const selectedValue = event.target.value;
    changeSelectedItem(selectedValue);
  };
  
  // ...
}
Run Code Online (Sandbox Code Playgroud)

但当使用它时,它的类型就变成了交集。

// TS inferred type of `changeSelectedItem`.

(parameter) changeSelectedItem: (arg0: string & {
  displayValue: ReactNode;
  value: string;
}) => void
Run Code Online (Sandbox Code Playgroud)

这导致了这个错误。

// Error …
Run Code Online (Sandbox Code Playgroud)

typescript

5
推荐指数
1
解决办法
110
查看次数

从程序集中捕获/禁用 SIGFPE 异常

在使用 .x86 程序集除以 0 时,出现 SIGFPE 异常idiv。我如何从汇编中禁用它?我需要系统调用还是可以直接在 x86 中完成?

再生产:

测试.asm

default rel
global WinMain

section .data 

section .text
WinMain:
    mov rcx, 0
    mov rdx, 0
    idiv rcx
Run Code Online (Sandbox Code Playgroud)

命令:

nasm -f win64 test.asm
gcc test.obj
gdb a
运行

x86 assembly x86-64 integer-division

1
推荐指数
1
解决办法
92
查看次数

如何使用 pidgeon-maps 在 Reactjs 中对地图上的点之间的线进行动画处理?

在我的reactjs应用程序中,我使用了一个名为pidegon-maps的轻量级地图库来显示船只位置。在不尝试使用更大的库(传单、谷歌地图反应)的情况下,我尝试为船只所走的路线制作动画。

从这个问题中汲取灵感,我尝试创建一个类似的实现。

useEffect(() => {

let start = [0.108266, 52.202758];
let end = [0.11556, 52.201733];

const speedFactor = 500;

let diffX = parseFloat(end[0]) - parseFloat(start[0]);
let diffY = parseFloat(end[1]) - parseFloat(start[1]);
let sfX = diffX / speedFactor;
let sfY = diffY / speedFactor;

let i = 0;
let j = 0;

let lineCoordinates = [];

while (i < diffX || Math.abs(j) < Math.abs(diffY)) {
  lineCoordinates.push([start[0] + i, start[0] + j]);

  if (i < diffX) {
    i += …
Run Code Online (Sandbox Code Playgroud)

requestanimationframe reactjs maptiler

6
推荐指数
1
解决办法
124
查看次数

C++ 中是否存在相当于 C# 中变量丢弃'_'的 C++ 等效项?

_在 C# 中,当想要显式忽略操作结果时,有一个方便的功能,即使用下划线作为丢弃变量。

我目前正在 C++ 中寻找等效的功能或解决方法,它允许我在从函数检索多个值时丢弃特定值或节省内存分配。

例子:

假设我有一个这样的函数:

void readValues(float& temperature, float& humidity, float& dewpoint, float& tempTrend, float& humTrend) {
    // Some operation to retrieve values
}
Run Code Online (Sandbox Code Playgroud)

如果我只需要知道温度,并且没有特定于温度的函数,如何以最节省内存的方式丢弃其他值?

或者任何其他方法可以在忽略 Arduino/ESP32 环境中函数的某些返回值时帮助节省内存空间?

我现在在做什么:

float temperature;
float discard;

readValues(temperature, discard, discard, discard, discard);
Run Code Online (Sandbox Code Playgroud)

我尝试过的:

float temperature;
readValeus(temperature, null_ptr, null_ptr, null_ptr, null_ptr);
Run Code Online (Sandbox Code Playgroud)
float temperature;
readValues(temperature, 0, 0, 0, 0);
Run Code Online (Sandbox Code Playgroud)

感谢您的任何见解或建议!

c# c++ memory-management equivalent arduino-c++

2
推荐指数
1
解决办法
107
查看次数

为什么系统不能正确释放 C 和 Rust 程序的内存?但是C++程序好像没有问题

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

void *thread_function(void *arg) {
    char **records = malloc(1000000 * sizeof(char *));
    if (records == NULL) {
        perror("Memory allocation failed");
        exit(EXIT_FAILURE);
    }

    for (int i = 0; i < 1000000; ++i) {
        records[i] = malloc(16);
        if (records[i] == NULL) {
            perror("Memory allocation failed");
            exit(EXIT_FAILURE);
        }
        sprintf(records[i], "%d", i);
    }

    printf("done\n");

    for (int i = 0; i < 1000000; ++i) {
        free(records[i]);
    }
    free(records);

    pthread_exit(NULL);
}

int main() {
    pthread_t threads[400];

    for (int i = 0; …
Run Code Online (Sandbox Code Playgroud)

c c++ memory memory-leaks rust

5
推荐指数
1
解决办法
216
查看次数

直接从算法中获取第 n 个唯一排列,而不生成前一个排列

初始值的第 n 个唯一的、视觉上唯一的排列(即使按字母顺序排序)是否可以通过算法获得?

\n

如果我们有一个初始值,例如0101,唯一的排列将是0011、0110、1100、0101、1010、1001,通过算法,如果我输入数字3,我应该直接得到唯一的排列例如,1100,无需计算上述排列。直接生成它很重要,因为如果我们有一个初始值 0101011010101010110110010101010101010 并且我们想要获得唯一的排列 82873648234,如果我们生成所有以前的排列,将花费太多时间。有什么方法吗?我在这个论坛上搜索了多个类似的问题,但我无法获得这个具体案例的答案。我们需要直接处理独特的排列,而不生成以前的排列。

\n

我尝试了几种代码选项。例如,这段代码不仅生成一次唯一的排列,而且重复它们并且不起作用。

\n
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click\n        Dim str As String = "0011"\n        Dim target As Integer = 4 ' La permutaci\xc3\xb3n que quieres generar\n        Dim arr() As Char = str.ToCharArray()\n        Array.Sort(arr)\n        str = New String(arr)\n\n        For i = 0 To 5\n            Dim result As String = FactoradicPermutation(str, i)\n            MsgBox(result)\n        Next\n\n    End Sub\n    Function FactoradicPermutation(ByVal str As String, ByVal index As Integer) As String\n        Dim factoradic() …
Run Code Online (Sandbox Code Playgroud)

algorithm math permutation

3
推荐指数
1
解决办法
71
查看次数

如何从 RakuAST 中提取数据

config从a 的部分中提取哈希值如何最好RakuAST::Doc::Block?这是程序:

use v6.d;
use experimental :rakuast;

my $ast = Q:to/CONF/.AST;
=for rakudoc :category("Language") :kind<sub> :subkind<operator>
Stuff
CONF
my $block = $ast.rakudoc[0];
my %config = $block.config.pairs.map( { .key  =>  .value.DEPARSE } );
say %config.raku
Run Code Online (Sandbox Code Playgroud)

这是结果。

{:category("(\"Language\")"), :kind("<sub>"), :subkind("<operator>")}

Run Code Online (Sandbox Code Playgroud)

但.DEPARSE正在生成引号,即("...")和<...>。我怎样才能提取字符串?

raku

5
推荐指数
1
解决办法
137
查看次数