How to Make Rotating Reference Frame?

All about writing scripts for Celestia in Lua and the .cel system
Topic author
rbroberts
Posts: 23
Joined: 05.11.2006
With us: 18 years
Location: Brooklyn, NY

How to Make Rotating Reference Frame?

Post #1by rbroberts » 10.04.2008, 02:37

I thought this should rotate, but...

Code: Select all

"Earth North Hover" "Sol/Earth"
{
  Class  "Invisible"
  Radius 0.001

  OrbitFrame
  {
    TwoVector
    {
      Center  "Sol/Earth"
      Primary
      {
        Axis "z"
        RelativePosition { Target "Sol/Earth" }
      }
      Secondary
      {
        Axis "y"
        RelativeVelocity { Target "Sol/Earth" }
      }
    }
  }

  BodyFrame {
    TwoVector {
      Center  "Sol/Earth"
      Primary {
        Axis "-z"
        RelativePosition { Target "Sol" }
      }
      Secondary {
        Axis "y"
        RelativeVelocity { Target "Sol/Earth" }
      }
    }
  }

  FixedPosition [ 0.0 0.0 10000.0]
}


The goal here is to have a reference frame where I face away from the sun and can show the changing constellations through the year.

roland
Roland B. Roberts, PhD
6818 Madeline Court
Brooklyn, NY 11220

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: How to Make Rotating Reference Frame?

Post #2by chris » 10.04.2008, 03:02

There's a problem with that frame. The RelativePosition and RelativeVelocity vectors are defined by a target and observer object. If you omit the observer, it defaults to the coordinate frame center, which is Earth both the body frame and orbit frame. The problem is that Earth is also the target object for all but of the vectors. You can't define a frame with zero length vectors. I think that what you probably meant was to make Sol the target object in each case. That will work and give you the rotating reference frame that you want--if you make the observer 'sync orbit' by pressing y, the observer should rotate in the way that you expect.

(The name 'sync orbit' is a leftover from the early days of Celestia. What it actually does is to put the observer in the body-fixed frame of the selected object.)

--Chris

Topic author
rbroberts
Posts: 23
Joined: 05.11.2006
With us: 18 years
Location: Brooklyn, NY

Re: How to Make Rotating Reference Frame?

Post #3by rbroberts » 12.04.2008, 19:24

First, thank you for a very lucid explanation of what was wrong with my frame. It helped me to better understand frame definitions in general.

I replaced Sol/Earth with Sol in each case, and further adjusted to make the z-axis "up" wrt to the ecliptic. When I "goto" this location, then do a "sync orbit" I don't quite get what I was expecting. Perhaps I misunderstood. If I center then Sun, then do a sync orbit, I get something that appears correct until I then do a center on Earth and discover I managed to end up on the opposite side of the Sun from it!

Both the old, badly defined frame, and the good frame work if I center the sun the lock on it.

So, while I understand what made my old frame a badly defined one, I'm still not sure I understand how to get a frame which will intrinsically behave the way I was thinking. Here's my last attempt:

Code: Select all

"Earth North Hover" "Sol/Earth"
{
  Class  "Invisible"
  Radius 0.001

  OrbitFrame {
    TwoVector {
      Center  "Sol/Earth"
      Primary {
        Axis "x"
        RelativePosition { Target "Sol" }
      }
      Secondary {
        Axis "y"
        RelativeVelocity { Target "Sol" }
      }
    }
  }

  BodyFrame {
    TwoVector {
      Center  "Sol"
      Primary {
        Axis "x"
        RelativePosition { Target "Sol" }
      }
      Secondary {
        Axis "y"
        RelativeVelocity { Target "Sol" }
      }
    }
  }

  FixedPosition [ 0.0 0.0 25000.0 ]
}

roland
Roland B. Roberts, PhD

6818 Madeline Court

Brooklyn, NY 11220


Return to “Scripting”