adde compound command calling for multi input control; added notes on dot product; testing stuff in skunk works folder
This commit is contained in:
@@ -71,5 +71,102 @@ Can we able to get the 'delta' in cpu_controller utside of '_process'/'_physics_
|
||||
If queue do we push "rotate towards using xyz pattern" as a command/state to check until met?
|
||||
|
||||
|
||||
### Thoughts on using dot product to check the normalized target position from 'to_local':
|
||||
|
||||
- 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
|
||||
|
||||
- From, GPT:
|
||||
The formula is: A⋅B=∣A∣∣B∣cos(θ)
|
||||
|
||||
Where:
|
||||
|
||||
- `A` = Your target direction vector.
|
||||
- `B` = Your forward direction vector.
|
||||
- `θ` = Angle between the two vectors.
|
||||
- `|A|` and `|B|` = Magnitudes (lengths) of the vectors.
|
||||
|
||||
Since both vectors are normalized (length = 1), the formula simplifies to:
|
||||
|
||||
A⋅B=cos(θ)
|
||||
|
||||
You have:
|
||||
A=(0,0,1)
|
||||
B=(46,33,9)
|
||||
|
||||
1. Multiply corresponding components
|
||||
|
||||
The dot product formula is:
|
||||
A⋅B=(AxBx)+(AyBy)+(AzBz)
|
||||
|
||||
Substitute your values:
|
||||
=(0×46)+(0×33)+(1×9)
|
||||
=9
|
||||
|
||||
2. Normalize by vector lengths
|
||||
|
||||
Remember, the full formula also divides by the magnitudes when finding cosine:
|
||||
cos(θ)=A⋅B/(∣A∣∣B∣)
|
||||
|
||||
Calculate the lengths/magnitudes:
|
||||
∣A∣=sqrt(0^2+0^2+1^2)=1
|
||||
∣B∣=sqrt(46^2+33^2+9^2)
|
||||
∣B∣=sqrt(3266)≈57.15
|
||||
∣B∣=3266≈57.15
|
||||
|
||||
3. Calculate cosine
|
||||
cos(θ)=9/(1x57.15)
|
||||
cos(θ)≈0.1575
|
||||
|
||||
-- Note: 0.1575 is not radians or degrees.
|
||||
-- It's a dimensionless number representing the cosine of the angle.
|
||||
-- Think of it as an intermediate result.
|
||||
|
||||
4. Calculate the angle
|
||||
θ=cosec(0.1575) = ≈1.412 radians
|
||||
θ≈80.94degrees
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user