worldToLocal Funktionsweise

JakobT
Posts: 39
Joined: Mon May 25, 2009 4:31 pm

worldToLocal Funktionsweise

Post by JakobT »

Hallo zusammen,

dies ist eine Script- und keine Editorfrage, ein passenderes Unterforum fiel mir aber nicht ein. Bei Bedarf das Thema also bitte verschieben.

Ich wüsste gerne die Funktionsweise von worldToLocal - also nicht deren Aufbau, der ist eindeutig in Giants' Script-Doku gegeben, sondern wie sie was ausrechnet.

Mein Problem ist nämlich wie folgt. Ich möchte eine bestimmte Node - die pipeRaycastNode - eines Combines im Verhältnis zur combine.rootNode ausrechnen. In meinem Beispiel benutze ich den standard Deutz 6095. Bei ausgefahrenem Rohr müsste das Ergebnis immer (pi mal Daumen) um die 5.5 liegen:
Image
Ingame lass ich mir nun folgende Werte ausgeben:

Code: Select all

local cwX, cwY, cwZ = getWorldTranslation(combine.rootNode);
local prnToCombineX, prnToCombineY, prnToCombineZ = worldToLocal(combine.pipeRaycastNode, cwX, cwY, cwZ);
local prnwX, prnwY, prnwZ = getWorldTranslation(combine.pipeRaycastNode);
local cprnDist = Utils.vector2Length(cwX-prnwX, cwZ-prnwZ);
Als Ergebnis bekomme ich:

Code: Select all

cwX = -668.919495
cwZ = -128.467743
prnwX = -668.922913
prnwZ = -134.023926
prnToCombineX = 0.002420
prnToCombineZ = 6.830016
cprnDist = 5.556184
Während also vector2Length ein relativ akkurates Ergebnis liefert, verstehe ich prnToCombine (also die worldToLocal-Funktion) überhaupt nicht. Warum geht X gegen null anstatt 5.5? Laut Bild müsste Z auch so ziemlich 0 sein.

Edit: Im Endeffekt bringt mir worldToLocal also die einzelnen Distanzen der Achsenpunkte (X zu X, Y zu Y, Z zu Z) - die man also auch pi mal Daumen mit einfacher Subtraktion ausrechnen könnte. Was ich aber eher bräuchte wäre die Distanz jener Punkte bei einem theoretisch genordeten Drescher, so dass, um beim Beispiel zu bleiben, die PipeRaycastNode wirklich als X-Entfernung ausgegeben wird.
[Edit Ende]

Edit #2: Ich habe noch ne Grafik gemacht um zu verdeutlichen was ich bei der ganzen Geschichte eigentlich suche. Auf der Grafik wäre das die Länge der roten Linie.

Image
[Edit Ende]

Könnte mir also jemand erklären was genau worldToLocal ausgibt / wie man es sich vorstellen muss?

Danke im Voraus,
--Jakob
Courseplay für LS15
Website | GitHub | Bug Tracker
User avatar
modelleicher
Posts: 1575
Joined: Fri Jul 09, 2010 11:10 pm
Location: Hessen
Contact:

Re: worldToLocal Funktionsweise

Post by modelleicher »

hmm..

Was ist anders herum?
local cwX, cwY, cwZ = getWorldTranslation(combine.pipeRaycastNode);
local prnToCombineX, prnToCombineY, prnToCombineZ = worldToLocal(combine.rootNode, cwX, cwY, cwZ);

Zumindest so würde ich es verstehen wenn ich mir die Beschreibung der Scriptdoku ansehe..


EDIT: Wenn ich so überlege müsste das ja das selbe sein, lol.. Hm, oder?

LG
Eine Stunde oder Minute ist nur ein winziger Teil unseres gesamten Lebens. Und dennoch sind es die einzelnen Momente, die das Leben lebenswert machen.
JakobT
Posts: 39
Joined: Mon May 25, 2009 4:31 pm

Re: worldToLocal Funktionsweise

Post by JakobT »

Danke für den Hinweis. Ich habe das mit verschiedenen Combines mal getestet, umgedreht funktioniert es. Warum allerdings - das kann ich mir wahrlich nicht erklären.

Code: Select all

local cwX, cwY, cwZ = getWorldTranslation(combine.rootNode)
local prnwX, prnwY, prnwZ = getWorldTranslation(combine.pipeRaycastNode)
local prnToCombineX, prnToCombineY, prnToCombineZ = worldToLocal(combine.pipeRaycastNode, cwX, cwY, cwZ)
local combineToPrnX, combineToPrnY, combineToPrnZ = worldToLocal(combine.rootNode, prnwX, prnwY, prnwZ)
Ergebnis beim Deutz 7545 RTS (Pipe links):

Code: Select all

[Richtung: Osten (90°)]
cwX = 65.444031
cwZ = -684.632263
prnwX = 65.448349
prnwZ = -691.427429
prnToCombineX = 0.012700
prnToCombineZ = 7.780778
*** combineToPrnX = 6.750573 ***
combineToPrnZ=-0.012706

[Richtung: Westen (270°)]
cwX = -96.971596
cwZ = -690.637573
prnwX = -96.850845
prnwZ = -683.911438
prnToCombineX = 0.012704
prnToCombineZ = 7.780814
*** combineToPrnX = 6.750573 ***
combineToPrnZ = -0.012707
Ergebnis beim Grimme Tectron (Pipe rechts):

Code: Select all

[Richtung: Osten (90°)]
cwX = -448.323425
cwZ = -622.581604
prnwX = -451.317749 
prnwZ = -616.553406
prnToCombineX = 6.025985 
prnToCombineZ = 2.673634 
*** combineToPrnX = -6.025972 ***
combineToPrnZ = -2.673645

[Richtung: Westen (270°)]
cwX = -214.606873
cwZ = -613.704773
prnwX = -211.938431
prnwZ = -619.731262
prnToCombineX = 6.025943
prnToCombineZ = 2.673639
*** combineToPrnX = -6.025951 ***
combineToPrnZ = -2.673639
Woher jetzt diese Diskrepanz kommt, besonders bzgl X-Achse bei combineToPrn und Z-Achse bei prnToCombine, versteh ich wie gesagt überhaupt nicht.

Aber danke nochmal für den Denkanstoß.
Courseplay für LS15
Website | GitHub | Bug Tracker
Post Reply