跳到主要内容

IDP.Math.KGeomLib.slerpFlatQuaternion() method

不同于KQuaternion的slerp函数,这个函数直接基于展平的数组做球面线性插值。

这里我们没有像Math2的Quaternion.slerpFlat函数那样把destination array当作参数传入,让slerp结果直接写到 destination array当中,这是因为如果经过了quickjs虚拟机,那样写入并不能同时改变插件侧的数组对象,修改的 仅仅是math-apaas-impl所在的应用程序侧的数组对象。反过来应用程序“传递”给插件的数组对象,插件可以修改成功, 但是再传回应用程序时,则还是那个没有被改动过的应用程序侧的数组对象。quickjs不能监听对数组的修改去同步两边对应 的数组数据。

Do a slerp operates directly on flat arrays of numbers.

Signature:

slerpFlatQuaternion(q1: number[], offset1: number, q2: number[], offset2: number, t: number): number[];

Parameters

Parameter

Type

Description

q1

number[]

输入第一个四元数数组。

The array representation of the first quaternion.

offset1

number

输入第一个四元数数组的起始索引。

The offset index in the array where the first quanternion starts.

q2

number[]

输入第二个四元数数组。

The array representation of the second quaternion.

offset2

number

输入第二个四元数数组的起始索引。

The offset index in the array where the second quanternion starts.

t

number

输入插值比例。

Normalized interpolation factor (between 0 and 1).

Returns:

number[]

返回数组,存储插值后的四元数[x, y, z, w]。

The array representation of the result quaternion.