Jump to content

Math whiz question - howto place objects relative


zaira

Recommended Posts

Posted

3 x i :

 

I am a looser in geometry.

 

I want to place two objects (XMarkerHeading) relative to a rectangle (Cage) in my Papyrus script:

 

post-135459-0-35061500-1462293769_thumb.png

 

I have no idea how to calculate the angles and positions

 

What I have is X,Y,Z, AngleX, AngleY, AngleZ, Width, Length and Height of the rectangle

Posted

Triangles based on the centre point of the rectangle to centre point of the objects using weird old BC era Greek technology - also now widely available on wikipedia? IGMC

Posted

Triangles based on the centre point of the rectangle to centre point of the objects using weird old BC era Greek technology - also now widely available on wikipedia? IGMC

 

XMarkerHeadings are directed rectangles - I have drawn triangles to show the direction

 

Posted

How about this? In pseudo-papyrus...

 

C: Cage

G: Green marker

O: Orange marker

 

; Position the green marker right in the middle of the cage:

G.SetPos x (C.GetPos x)

G.SetPos y (C.GetPos y)

G.SetPos z (C.GetPos z)

 

; Set G's angles identical to C:

G.SetAngle x (C.GetPos x)

G.SetAngle y (C.GetPos y)

G.SetAngle z (C.GetPos z)

 

; Position the orange marker (C.length is the length of cage):

 

O.SetPos x (C.length + G.GetPos x)

O.SetPos y (C.length + G.GetPos y)

O.SetPos z (G.GetPos z)

 

; Set O's angles identical to G, except the z axis:

O.SetAngle x (G.GetPos x)

O.SetAngle y (G.GetPos y)

O.SetAngle z (-G.GetPos z) [or O.SetAngle z (180 + G.GetPos z)]

Posted

Something in real Papyrus:

 

 

Function translate(ObjectReference toMove, ObjectReference dst, float offset, float rotation)
  float anglez = dst.GetAngleZ()
  float anglex = dst.GetAngleX() * -1
  float offsetz = offset * math.sin(anglex)
  float tempfloat = offset * math.cos(anglex)
  float offsetx = tempfloat * math.sin(anglez)
  float offsety = tempfloat * math.cos(anglez)
  float posx = dst.GetPositionX() + offsetx
  float posy = dst.GetPositionY() + offsety
  float posz = dst.GetPositionZ() + offsetz
  toMove.setAngle(dst.getAngleX(), dst.getAngleY(), dst.getAngleZ()+rotation)
  toMove.TranslateTo(posx, posy, posz, 0, 0, dst.getAngleZ()+rotation, 90.0, 25.0) 
EndFunction

 

Call it with the ObjectReference to be moved (toMove) and the target one for reference (dst), and use offset as distance, and rotation as angle (in degrees.)

 

Posted

Now making everything more complicated:

post-135459-0-64674600-1462296990_thumb.png

 

Orange is the door

Blue is the marker for the NPC who opens the door

Posted

translate(npcMarker, theDoor, 65.0, -45.0)

 

But if the "door" is the yellow sign (and not the orange marker): translate(npcMarker, theDoor, -72.0, 45.0)

Posted

Use placeAt, and remove the last two parameters.

Posted

Use placeAt, and remove the last two parameters.

 

placeAt? You mean MoveTo? I don't spawn new markers - I'll move existing markers.

Posted

 

placeAt? You mean MoveTo? I don't spawn new markers - I'll move existing markers.

 

 

Sorry, you are right. Between different games, I sometimes confuse the functions offered here and there.

The correct functions are (to be replaced in my previous code, and you need two, one for the position, one for the rotation):

 

 

toMove.MoveTo(dst, offsetx, offsety, offsetz)
toMove.SetAngle(0.0, 0.0, float dst.getAngleZ()+rotation)

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...