2026-10-30 20:58:22 -05:00
|
|
|
# Notes:
|
|
|
|
|
|
|
|
|
|
<img src="intuiting-pi.jpg" alt="Intuiting PI" width="400">
|
|
|
|
|
|
2026-11-15 00:29:26 -06:00
|
|
|
# Tools
|
|
|
|
|
|
|
|
|
|
-- https://www.desmos.com/calculator
|
|
|
|
|
|
|
|
|
|
# Thoughts
|
|
|
|
|
|
2026-10-30 20:58:22 -05:00
|
|
|
var target_position = jet.to_local(jet.target.global_position)
|
|
|
|
|
-- Gets us the position of a target jet relative to the jet itself.
|
|
|
|
|
-- This treats the jet as the center of the world when calculating.
|
|
|
|
|
|
|
|
|
|
var direction = jet.to_local(jet.target.global_position).normalized()
|
|
|
|
|
-- I'm uncertain; but, the above might give direction similar to the below strategy but in local space.
|
|
|
|
|
var direction = (jet.target.global_position - jet.global_position).normalized()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Steps to consider when rotating a jet by CPU mode:
|
|
|
|
|
|
|
|
|
|
-- PI is 180 degrees and 2PI is 360 degrees.
|
|
|
|
|
-- Remember pirodicity and how 0 degrees could technically mean +-360 degrees (full circle).
|
|
|
|
|
-- If rotation.z is equal to 0 or +-360 it means we're level.
|
|
|
|
|
-- Rotating along -z (Forward direction of Godot nodes) means left is -x and right is +x
|
|
|
|
|
-- Rotating left (-x) is towards <=360 degrees and +x is towards >=0 degrees rightward.
|
|
|
|
|
-- We're upside down If +-270 (or increments of that I.E +- 540, etc).
|
|
|
|
|
|
|
|
|
|
Can we normalize rotation and from that treat slices of the circle as specific command zones?
|
2026-10-30 23:08:47 -05:00
|
|
|
I.E if target a jet in front and and to the right by 45 degrees we yaw instead of roll?
|
2026-10-30 20:58:22 -05:00
|
|
|
|
2026-11-01 17:33:28 -06:00
|
|
|
Imagining the current situation is us observing our CPU controlled jet from
|
2026-10-30 20:58:22 -05:00
|
|
|
the 3rd person view from behind. The jet is level to the horizon of our world.
|
|
|
|
|
The target jet position is behind and slightly to the right corner of the screen.
|
|
|
|
|
____________________________________________
|
|
|
|
|
| |
|
|
|
|
|
| |
|
|
|
|
|
| | |
|
2026-10-30 23:08:47 -05:00
|
|
|
| -- jet -- |
|
2026-10-30 20:58:22 -05:00
|
|
|
| | |
|
|
|
|
|
| |
|
|
|
|
|
| |
|
|
|
|
|
| X |
|
|
|
|
|
____________________________________________
|
|
|
|
|
|
2026-11-01 17:33:28 -06:00
|
|
|
-- SOHCAHTOA
|
|
|
|
|
|
|
|
|
|
-- sin = Opposite/Hypotenuse
|
|
|
|
|
-- cos = Adjacent/Hypotenuse
|
|
|
|
|
-- tan = Opposite/Adjacent
|
|
|
|
|
|
|
|
|
|
Maybe aha moment, if I create a right angled triangles per plane then we can figure out radians from the aquired angles.
|
|
|
|
|
=O ^
|
|
|
|
|
|
|
|
|
|
We already have a hypotenuse value based on the 'distance'.
|
|
|
|
|
We have the target position and our position.
|
|
|
|
|
Thus, if certain target values are above or below we use one or the other to gague the 90 degree angle point
|
|
|
|
|
|
|
|
|
|
let x1 = 5;
|
|
|
|
|
let y1 = 5;
|
|
|
|
|
let rotation = 8; // in degrees
|
|
|
|
|
let magnitude = 7; // our distance
|
|
|
|
|
// got bellow from AI during 500 lines challenge; not sure what this is doing just yet
|
|
|
|
|
let radians = (rotation + 180) % 360;
|
|
|
|
|
const x2 = x1 + magnitude * Math.cos(radians);
|
|
|
|
|
const y2 = y1 + magnitude * Math.sin(radians);
|
|
|
|
|
|
2026-10-30 20:58:22 -05:00
|
|
|
We must roll the jet to +90 degrees left or -90 right and then pitch up
|
|
|
|
|
in order to turn towards target. OR yaw left or right to turn.
|
|
|
|
|
What conditions should we use to determin which to use? Distance from and to?
|
|
|
|
|
If shorter distance roll and pitch? If larger then yaw?
|
|
|
|
|
|
|
|
|
|
We are setting commands on the jet.control_frame. Over time, conditions change; so,
|
|
|
|
|
how do we confirm what set of actions to do/maintain? A queue and check over time?
|
|
|
|
|
Can we able to get the 'delta' in cpu_controller utside of '_process'/'_physics_process'?
|
|
|
|
|
|
|
|
|
|
If queue do we push "rotate towards using xyz pattern" as a command/state to check until met?
|
|
|
|
|
|
|
|
|
|
|
2026-11-05 20:47:05 -06:00
|
|
|
### Thoughts on using dot product to check the normalized target position from 'to_local':
|
|
|
|
|
|
2026-11-15 00:29:26 -06:00
|
|
|
- https://www.youtube.com/watch?v=2PrSUK1VrKA
|
2026-11-05 20:47:05 -06:00
|
|
|
- https://www.youtube.com/watch?v=-udnENzlV4U
|
|
|
|
|
|
|
|
|
|
- From, Godot docu:
|
|
|
|
|
- This (dot product) can be used to compare the angle between two vectors.
|
|
|
|
|
- When using unit (normalized) vectors, the result will always
|
|
|
|
|
- be between -1.0 (180 degree angle) when the vectors are facing opposite directions,
|
|
|
|
|
- and 1.0 (0 degree angle) when the vectors are aligned.
|
|
|
|
|
- From, GPT:
|
|
|
|
|
- forward_dot represents the dot product between two normalized direction vectors.
|
|
|
|
|
- It is neither radians nor degrees.
|
|
|
|
|
- It tells you how closely target_direction is aligned with the forward direction (Vector3.Forward).
|
|
|
|
|
|
|
|
|
|
var target_direction = jet.to_local(jet2.global_position).normalized()
|
|
|
|
|
var forward_dot: float = target_direction.dot(Vector3.Forward)
|
|
|
|
|
var angle = rad_to_deg(acos(forward_dot))
|
|
|
|
|
|
|
|
|
|
| Value | Meaning | Angle |
|
|
|
|
|
| 1.0 | Directly forward | 0° |
|
|
|
|
|
| 0.5 | Forward, but off to the side | 60° |
|
|
|
|
|
| 0.0 | Perpendicular (to the side) | 90° |
|
|
|
|
|
| -0.5 | Behind, somewhat | 120° |
|
|
|
|
|
| -1.0 | Directly behind | 180° |
|
|
|
|
|
|
|
|
|
|
I suspect Vector3.Forward is the key point to thinking about this simply. It's 0, 0, -1
|
|
|
|
|
So any calculations are kinda happening localized too thus easy right angles
|
|
|
|
|
It then seems to me that we have a relationship between 4 vectors:
|
|
|
|
|
|
|
|
|
|
jet.global_position = (100, 0, 100)
|
|
|
|
|
jet2.global_position = (146, 33, 109)
|
|
|
|
|
target_direction = (46, 33, 9) => normalized aprox (0.805, 0.577, 0.157) //vector pointing from jet toward jet2
|
|
|
|
|
Vector3.Forward = (0, 0, -1) //Jet's local forward direction vector
|
|
|
|
|
|
|
|
|
|
The dot product compares the target's local direction point against the jet's forward direction point.
|
|
|
|
|
forward direction point is NOT the jet's origin
|
|
|
|
|
|
|
|
|
|
If I add or subtract the angles derived from calculating x&-z plane and y&-z plane
|
|
|
|
|
could those derive the same dot product angle?
|
|
|
|
|
(46, 9) and (0, -1) with third point forming right angle
|
|
|
|
|
(33, 9) and (0, -1) with third point forming right angle
|
|
|
|
|
|
|
|
|
|
What if I do (46, 9) and (33, 9) with third point forming right angle?
|
|
|
|
|
Is there anything meaningfully gained from that?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##### Dot Product Formula
|