Variable Distance Orbit Transformation

## VDOT

　"Variable Distance Orbit Transformation" is a movement when an object orbits a pivot in a variable distance away.

　A normal Orbit Transformation can only orbit with a fixed distance, while as more requirements grow, a system that could make an object to orbit a pivot in a variable distance is very needed. And that's all VDOT is about.

## Basics of "Orbit Transformation"

　Usually, OT is about an object orbiting a set pivot or point. While Besiege doesn't allow us to do it with one logic only, we need to come up with a new logic pattern to accomplish so.

　There are 3 steps in total: "**Centering**, **Rotating**, and **Returning**".

### Centering

　To move the object towards the pivot. In this step, we need to know how much the distance and the direction are while centering the object, two values must be an actual number.

### Rotating

　Literally meaning Rotating the object.

　Since OT is instantaneous, the larger the rotation angle is, the faster the object orbits.

### Returning

　Returns the object to the original distance away from the pivot, with the direction based on how much "Rotating" has turned.

　To be more specific: After Rotating, the direction the object faces has changed, then we undo the "Centering" so that the object will be moved back to the orbit route, then the whole process will appear to be just like "orbiting the pivot".

## The Difference of "Variable Distance"

Basically OT but the distance is no longer fixed.

### Variable Distances

　The way VDOT works is just like the normal OT, but the default logics of Besiege doesn't allow the user to move an object based on a variable, so how much an object moves will always be a fixed number.

　Because of that, to move an object with a variable, it must be combined with a system called "SetGet", which allows users to output a variable instantaneously and constantly. These "output variables" will be the distances we need in step "Centering" and "Returning".

### Direction Determining

　The "Rotating" process must be done within "Centering" and "Returning", but SetGet is an instantaneous system, from the first line of logic to the last has no delays, which makes VDOT's rotation impossible to be controlled manually. Thus we'll need another system to determine which direction the object should be rotating soon as the process "Centering" is done.

　This new system is called "Control Unit", CU for short. After "Centering" is done, CU will rotate the object based on the pre-inputted value which is inputted before the whole VDOT was started. Everything about the CU will be done within "Centering" and "Returning" while still keeping VDOT running instantaneously.

### Steps conclusion

　Now all the steps of VDOT became:

* Centering *(with variable)*,
* Rotating *(direction determining)*,
* Returning *(with variable)*.

## Controls and Inputs

To master VDOT, you'll need to know how to input the variables, setup, and activate the system. *(Here let me thank Algae for perfecting this sentence <3)*

### Variable Inputs

　VDOT uses variable as the distance for OT, and this variable can only be changed by logic:

```
   Variable “SG ±1" (Input maximum at once: ±37.)
   Transform "Local: (x/ y/ z)axis =1" (The value goes vary according to need.)

```

　The variable "SG" represents the distance between the object and the pivot, as the value of SG grows, the "Transform" logic moves the object away from the pivot at the same time, that way the mathematical and the actual distance between the two goes vary.

### Activating

　Before activating the system, you'll need to give a "Rotation variable" to CU, it doesn't matter which direction it is, but during the input, the VDOT must be in Deactivate Mode.

　This is because if we input the rotation variable to the CU while VDOT is in "activate mode", the system will bypass the "Centering" process and goes directly to the "Rotating" process, which will 100% cause the route of OT inaccurate and makes the object goes crazy.

　To avoid so, we will place "Deactivate" and "Activate" logic before and after the rotation variable input. That way during the input the CU will be in "deactivate mode", and after the input, the System will go back to "activate mode".

　Thus the whole logic of "Activating" is:

```
       Deactivate select "VDOT"
           Variable “CU =1(or 2)”
       Activate select "VDOT"
   Variable “DG1 +0”

```

　The first 3 lines are the rotation variable input, and the fourth is the actual one that starts the SetGet, which is also how VDOT should be activated.

### Setup

　There are 2 sections that requires manual inputs: "Distance Outputs" and "Control Unit (CU)".

#### Distance Outputs

　The places you can program the distance outputs are located in two memory sections "DG" and "dg" (SetGet v6), at the top of each section's logic gates are where you can program the outputs.

Example:

```
   On Variable “DG1 >0”
       (This is where you place the distance output !)
           Deactivate
               Variable “dg1 +1”
           Activate
       Variable “DG1 -1”

```

　These "outputs" are exactly what we needed during the process "Centering" and "Returning", its usually the logic "Transform".

#### Control Unit

　The way you control CU's value is:

```
   Deactivate select "VDOT"
       Variable “CU =1(or 2)”
   Activate select "VDOT"

```

　The maximum value of CU can be determined by how many directions there are, and all directions are required to be programmed with its own trigger event.

　In each CU's trigger event *(note\*1)*, the topside is where you can place "Rotation logics". Take "CU =1" as an example:

```
   On Variable "CU =1"
       *(Rotation Logics)*
       Variable "CU =0"

```

/////
*Note\*1: Although I said "each CU's trigger event", it doesn't mean all, "CU =0" is not counted, don't put rotation logics here.*
/////

## Process/Logic Overview

### Overview of the whole process:

1. Memory Section #1 moves the object towards the pivot, the distance will be based on the variable.

2. As the object is on the pivot, The CU will turn the object left or right depends on the current state of CU.

3. Memory Section #2 will move the object away from the pivot with the same distance but with a new direction which is angled by CU.

### Logic:

Image

```
  On Variable “SG >0”
       Variable “limit +1”
           Deactivate
               Variable “DG1 +1”
           Activate
       Variable “SG1 +1”
       Variable “SG -1”

   On Variable “SG <0”
       Variable “limit -1”
           Deactivate
               Variable “DG1 -1”
           Activate
       Variable “SG1 -1”
       Variable “SG +1”

   On Variable “SG1 >37”
           Deactivate
               Variable “DG2 +1”
               Variable “DG1 -37”
           Activate
       Variable “SG2 +1”
       Variable “SG1 -37”

   On Variable “SG1 <-37”
           Deactivate
               Variable “DG2 -1"
               Variable “DG1 +37”
           Activate
       Variable “SG2 -1”
       Variable “SG1 +37”

   On Variable “limit >1406”
       Variable “SG -1”

   On Variable “limit <-1406”
       Variable “SG +1”

   On Variable “DG1 > 0”
       *(Add logic here: One action)*
           Deactivate
               Variable “dg1 + 1”
           Activate
       Variable “DG1 - 1”

   On Variable “DG1 < 0”
       *(Add logic here: One action)*
           Deactivate
               Variable “dg1 - 1”
           Activate
       Variable “DG1 + 1”

   On Variable “DG1 = 0”
       Variable “DG2 + 0”

   On Variable “DG2 > 0”
       *(Add logic here: 37 actions)*
           Deactivate
               Variable “dg2 + 1”
           Activate
       Variable “DG2 - 1”

   On Variable “DG2 < 0"
       *(Add logic here: 37 actions)*
           Deactivate
               Variable “dg2 - 1”
           Activate
       Variable “DG2 + 1”

   On Variable “DG2 = 0”
       Variable “dg1 + 0”

   On Variable “dg1 >0”
           Deactivate
               Variable “DG1 +1”
           Activate
       Variable “dg1 -1”

   On Variable “dg1 <0”
           Deactivate
               Variable “DG1 -1”
           Activate
       Variable “dg1 +1”

   On Variable “dg1 =0”
       Variable “dg2 +0”

   On Variable “dg2 >0”
           Deactivate
               Variable “DG2 +1”
           Activate
       Variable “dg2 -1”

   On Variable “dg2 <0”
           Deactivate
               Variable “DG2 -1”
           Activate
       Variable “dg2 +1”

   On Variable “dg2 =0”
       *(End logic)*

```