目录

PgdRotation

Class/Struct Info

public struct PgdRotation : IComponent, IEquatable<PgdRotation>

预设旋转组件,继承了IComponent。

Constructor Summary

Constructor Name And Description

PgdRotation(float x, float y, float z, float w)

设置表示旋转的四元数各分量,由于四个分量和quat4共享内存,因此该设置等同于设置了quat4。

Property Summary

Name

Type

Description

quat4

Quaternion

四维向量表达的位置。

x

float

四元数的x分量。

y

float

四元数的y分量。

z

float

四元数的z分量。

w

float

四元数的w分量。

Method Summary

Qualifier and Type

Method Name and Description

string

ToString()

将旋转的四元数以字符串形式返回。

bool

operator !=(in PgdRotation rot1, in PgdRotation rot2)

不等于操作符重载,判断两个PgdRotation 是否不相等。

bool

operator ==(in PgdRotation rot1, in PgdRotation rot2)

等于操作符重载,判断两个PgdRotation 是否相等。

bool

Equals(PgdRotation rot)

判断当前PgdRotation与输入的PgdRotation是否相等。

Constructors

[h2]PgdRotation

Constructor Name And Description

void PgdRotation(float x, float y, float z, float w)

设置表示旋转的四元数各分量。

由于四个分量和quat4共享内存,因此该设置等同于设置了quat4。

Parameters

Name

Type

Description

x

float

四元数的x分量。

y

float

四元数的y分量。

z

float

四元数的z分量。

w

float

四元数的w分量。

Sample Code

// 创建PgdRotation组件
var rot1 = new PgdRotation(1, 1, 1, 1);
// 没有输入则为默认值,即x=0, y=0, z=0, w=0
var rot2 = new PgdRotation();

Methods

[h2]ToString

Method

string ToString()

将旋转的四元数以字符串形式返回。

Return

Type

Description

string

旋转的四元数。

Sample Code

// 打印PgdRotation组件信息
new PgdRotation(2, 4, 6, 8).ToString(); // "x: 2.000, y: 4.000, z: 6.000, w: 8.000"

[h2]operator !=

Method

bool operator !=(in PgdRotation rot1, in PgdRotation rot2)

不等于操作符重载,判断两个PgdRotation是否不相等。

Parameters

Name

Type

Description

rot1

PgdRotation

旋转组件1。

rot2

PgdRotation

旋转组件2。

Return

Type

Description

bool

  • true:表示两个旋转组件的值不相等。
  • false:表示两个旋转组件的值相等。

Sample Code

// 不等于比较
new PgdRotation() != new PgdRotation(1,0,0,0); // true
new PgdRotation() != new PgdRotation(0,0,0,0); // false

[h2]operator ==

Method

bool operator ==(in PgdRotation rot1, in PgdRotation rot2)

等于操作符重载,判断两个PgdRotation是否相等。

Parameters

Name

Type

Description

rot1

PgdRotation

旋转组件1。

rot2

PgdRotation

旋转组件2。

Return

Type

Description

bool

  • true:表示两个旋转组件的值相等。
  • false:表示两个旋转组件的值不相等。

Sample Code

// 等于比较
new PgdRotation() == new PgdRotation(1,0,0,0); // false
new PgdRotation() == new PgdRotation(0,0,0,0); // true

[h2]Equals

Method

bool Equals(PgdRotation rot)

判断当前PgdRotation与输入的PgdRotation是否相等。

Parameters

Name

Type

Description

rot

PgdRotation

旋转组件。

Return

Type

Description

bool

  • true:表示当前旋转组件与输入的旋转组件的值相等。
  • false:表示当前旋转组件与输入的旋转组件的值不相等。

Sample Code

// 等于比较
new PgdRotation().Equals(new PgdRotation(1,0,0,0)); // false
new PgdRotation().Equals(new PgdRotation(0,0,0,0)); // true