88 lines
2.2 KiB
GDScript3
88 lines
2.2 KiB
GDScript3
|
extends CSGCylinder
|
||
|
|
||
|
|
||
|
# Declare member variables here. Examples:
|
||
|
# var a = 2
|
||
|
# var b = "text"
|
||
|
|
||
|
|
||
|
# Called when the node enters the scene tree for the first time.
|
||
|
func _ready():
|
||
|
var orig01 = Vector3(-1, -1, 1)
|
||
|
var orig02 = Vector3(1, -1, 1)
|
||
|
var orig03 = Vector3(-1, 1, 1)
|
||
|
var orig04 = Vector3(2, -5, 1)
|
||
|
var dest01 = Vector3(-3, -7, 1)
|
||
|
var dest02 = Vector3(7, -3, 1)
|
||
|
var dest03 = Vector3(-7, 7, 1)
|
||
|
var dest04 = Vector3(4, 8, 1)
|
||
|
print(str(dest01) + "\n" + str(dest02) + "\n" + str(dest03) + "\n" + str(dest04) + "\n")
|
||
|
|
||
|
var a_ = Basis( Vector3(orig01.x, orig02.x, orig03.x),
|
||
|
Vector3(orig01.y, orig02.y, orig03.y),
|
||
|
Vector3.ONE )
|
||
|
var a_inverse = a_.inverse()
|
||
|
|
||
|
|
||
|
var a_coeff = a_inverse.xform(orig04)
|
||
|
|
||
|
|
||
|
print(orig04)
|
||
|
print(a_coeff)
|
||
|
print(str(a_.xform(a_coeff)) + "\n")
|
||
|
|
||
|
|
||
|
var A = Basis( Vector3(orig01.x * a_coeff.x, orig02.x * a_coeff.y, orig03.x * a_coeff.z),
|
||
|
Vector3(orig01.y * a_coeff.x, orig02.y * a_coeff.y, orig03.y * a_coeff.z),
|
||
|
a_coeff )
|
||
|
|
||
|
print(str(A) + "\n")
|
||
|
|
||
|
var A_inverse = A.inverse()
|
||
|
|
||
|
print(str(A_inverse))
|
||
|
|
||
|
print(str(A * A_inverse) + "\n")
|
||
|
|
||
|
var b_ = Basis( Vector3(dest01.x, dest02.x, dest03.x),
|
||
|
Vector3(dest01.y, dest02.y, dest03.y),
|
||
|
Vector3(dest01.z, dest02.z, dest03.z) )
|
||
|
var b_inverse = b_.inverse()
|
||
|
var b_coeff = b_inverse.xform(dest04)
|
||
|
var B = Basis( Vector3(dest01.x * b_coeff.x, dest02.x * b_coeff.y, dest03.x * b_coeff.z),
|
||
|
Vector3(dest01.y * b_coeff.x, dest02.y * b_coeff.y, dest03.y * b_coeff.z),
|
||
|
b_coeff )
|
||
|
|
||
|
var C = A_inverse * B
|
||
|
|
||
|
print(str(B))
|
||
|
print(str(b_coeff) + "\n")
|
||
|
print(str(C) + "\n")
|
||
|
|
||
|
var proof01 = C.xform(orig01)
|
||
|
var proof02 = C.xform(orig02)
|
||
|
var proof03 = C.xform(orig03)
|
||
|
var proof04 = C.xform(orig04)
|
||
|
|
||
|
print(str(proof01) + "\n" + str(proof02) + "\n" + str(proof03) + "\n" + str(proof04))
|
||
|
|
||
|
|
||
|
func adj(m: Basis):
|
||
|
return Basis(
|
||
|
Vector3(
|
||
|
m[1][1] * m[2][2] - m[1][2] * m[2][1],
|
||
|
m[0][2] * m[2][1] - m[0][1] * m[2][2],
|
||
|
m[0][1] * m[1][2] - m[0][2] * m[1][1]
|
||
|
),
|
||
|
Vector3(
|
||
|
m[1][2] * m[2][0] - m[1][0] * m[2][2],
|
||
|
m[0][0] * m[2][2] - m[0][2] * m[2][0],
|
||
|
m[0][2] * m[1][0] - m[0][0] * m[1][2]
|
||
|
),
|
||
|
Vector3(
|
||
|
m[1][0] * m[2][1] - m[1][1] * m[2][0],
|
||
|
m[0][1] * m[2][0] - m[0][0] * m[2][1],
|
||
|
m[0][0] * m[1][1] - m[0][1] * m[1][0]
|
||
|
)
|
||
|
)
|