-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Phase 1 - 90% complte: Outputs an array of arrays which contain the points at each slice of the image. ToDo: Maybe get the actaul point along that y axis instead of just the last critical points, but might do this after slicing horizontally into cells, next.
- Loading branch information
1 parent
3e5fb9b
commit 6665c3e
Showing
10 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
pathdfindintake2/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source_md5="8dd9ff1eebf38898a54579d8c01b0a88" | ||
dest_md5="da70afec3c66d4e872db67f808e12edb" | ||
|
Binary file added
BIN
+3.4 KB
pathdfindintake2/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
extends Node2D | ||
|
||
export var table = [Vector2(-3, 0.86), Vector2(-2, 1.45), Vector2(-1, 1.76), Vector2(0, 1.9), Vector2(1, 1.75), Vector2(2, 1.4), Vector2(3, 0.8)] | ||
var n = table.size() | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
var sumx = 0.0 | ||
var sumy = 0.0 | ||
var sumx2 = 0.0 | ||
|
||
var sumx3 = 0.0 | ||
var sumx4 = 0.0 | ||
var sumxy = 0.0 | ||
var sumx2y = 0.0 | ||
for ob in table: | ||
sumx += ob.x | ||
sumy += ob.y | ||
sumx2 += pow(ob.x,2.0) | ||
sumx3 += pow(ob.x,3) | ||
sumx4 += pow(ob.x,4) | ||
sumxy += ob.x * ob.y | ||
sumx2y += pow(ob.x,2) * ob.y | ||
print("sumx: "+String(sumx)+" sumy: "+String(sumy)+" sumx2: "+String(sumx2)+" sumx3: "+String(sumx3)+" sumx4: "+String(sumx4)+" sumxy: "+String(sumxy)+" sumx2y: "+String(sumx2y)) | ||
var sumxx = (sumx2) - (pow(sumx,2)/n) | ||
sumxy = (sumxy) - ((sumx * sumy/n)) | ||
var sumxx2 = (sumx3) - ((sumx2*sumx)/n) | ||
sumx2y = (sumx2y) - ((sumx2 * sumy)/n) | ||
var sumx2x2 = (sumx4) - (pow(sumx2,2)/n) | ||
print("sumxx: "+String(sumxx)+" sumxy: "+String(sumxy)+" sumxx2: "+String(sumxx2)+" sumx2y: "+String(sumx2y)+" sumx2x2: "+String(sumx2x2)) | ||
|
||
var a = ((sumx2y * sumxx) - (sumxy * sumxx2)) / ((sumxx * sumx2x2) - pow(sumxx2,2) ) | ||
var b = ((sumxy*sumx2x2) - (sumx2y*sumxx2)) / ((sumxx*sumx2x2)- pow(sumxx2,2)) | ||
var c = (sumy/n) - (b*(sumx/n)) - (a*(sumx2/n)) | ||
print(a) | ||
print(b) | ||
print(c) | ||
|
||
|
||
|
||
func _draw(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[gd_resource type="Environment" load_steps=2 format=2] | ||
|
||
[sub_resource type="ProceduralSky" id=1] | ||
|
||
[resource] | ||
background_mode = 2 | ||
background_sky = SubResource( 1 ) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://icon.png" | ||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=true | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=true | ||
svg/scale=1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[gd_scene load_steps=2 format=2] | ||
|
||
[ext_resource path="res://Node2D.gd" type="Script" id=1] | ||
|
||
[node name="Node2D" type="Node2D"] | ||
script = ExtResource( 1 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
; Engine configuration file. | ||
; It's best edited using the editor UI and not directly, | ||
; since the parameters that go here are not all obvious. | ||
; | ||
; Format: | ||
; [section] ; section goes between [] | ||
; param=value ; assign values to parameters | ||
|
||
config_version=4 | ||
|
||
_global_script_classes=[ ] | ||
_global_script_class_icons={ | ||
|
||
} | ||
|
||
[application] | ||
|
||
config/name="pathdfindintake2" | ||
config/icon="res://icon.png" | ||
|
||
[rendering] | ||
|
||
environment/default_environment="res://default_env.tres" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
extends Node2D | ||
|
||
#storage of shapes with neirbours, might be a bad way to store shapes, | ||
#I don'know and don't care, might look into it in the future. | ||
var nodes = { | ||
#big shape | ||
Vector2(900,0) : [Vector2(1000,150), Vector2(100,0)], | ||
Vector2(100,0) : [Vector2(900, 0), Vector2(0,300)], | ||
Vector2(0,300) : [Vector2(100,0), Vector2(100,600)], | ||
Vector2(100,600) : [Vector2(0,300), Vector2(900,600)], | ||
Vector2(900,600) : [Vector2(100,600), Vector2(1000,450)], | ||
Vector2(1000,450) : [Vector2(900,600), Vector2(900,300)], | ||
Vector2(900,300) : [Vector2(1000,450), Vector2(1000, 150)], | ||
Vector2(1000,150) : [Vector2(900,300), Vector2(900,0)], | ||
#small shape | ||
Vector2(300,300) : [Vector2(400,200), Vector2(400,400)], | ||
Vector2(400,400) : [Vector2(300,300), Vector2(700,400)], | ||
Vector2(700,400) : [Vector2(400,400), Vector2(600,300)], | ||
Vector2(600,300) : [Vector2(700,400), Vector2(700,200)], | ||
Vector2(700,200) : [Vector2(600,300), Vector2(400,200)], | ||
Vector2(400,200) : [Vector2(700,200), Vector2(300,300)] | ||
} | ||
|
||
var keys = nodes.keys() | ||
var points_at_point = [] | ||
|
||
|
||
func _ready(): | ||
_points_at_slice(nodes) | ||
|
||
|
||
|
||
func _points_at_slice(nodes): | ||
#drawing stuff | ||
set_process(true) | ||
|
||
|
||
keys.sort_custom(self, "custom_sort") | ||
print_debug(keys) | ||
|
||
#will rename variables in the furture | ||
var num = 0 | ||
var temp = [] #the current slice | ||
var temp_2 = [] # an array of current slices | ||
|
||
while num < keys.size(): | ||
var index = null | ||
temp_2 = temp_2.duplicate(true) | ||
|
||
if nodes[keys[num]][0].x >= keys[num].x and nodes[keys[num]][1].x >= keys[num].x: | ||
index = (_increase_in_conn(temp, keys, nodes, num)) | ||
if index == null: index = 0 | ||
temp.insert(index, keys[num]) | ||
temp.insert(index, keys[num]) | ||
temp_2.append(temp) | ||
# print(temp_2[temp_2.size()-1]) | ||
|
||
|
||
|
||
# this just doesn't work it outputs a blank array, why, why | ||
elif nodes[keys[num]][0].x <= keys[num].x and nodes[keys[num]][1].x <= keys[num].x: | ||
var temp_3 = temp.duplicate(true) | ||
# print("decrease") | ||
|
||
index = _decrease_in_conn(temp, keys, nodes, num, 0) | ||
if index != null: | ||
temp[index] = keys[num] | ||
temp_3.remove(index) | ||
|
||
index = _decrease_in_conn(temp, keys, nodes, num, 1) | ||
if index != null: | ||
temp[index] = keys[num] | ||
temp_3.remove(index) | ||
|
||
temp_2.append(temp) | ||
temp = temp_3.duplicate(true) | ||
# print(temp_2[temp_2.size()-1]) | ||
|
||
else: | ||
index = _not_increase_in_conn(temp, keys, nodes, num) | ||
if index != null: | ||
temp[index] = keys[num] | ||
temp_2.append(temp) | ||
# print(temp_2[temp_2.size()-1]) | ||
num += 1 | ||
|
||
|
||
for ob in temp_2: | ||
print(ob) | ||
|
||
|
||
|
||
#needed for drawing | ||
func _process(delta): | ||
update() | ||
|
||
#debugging mouse poisition | ||
if Input.is_action_just_pressed("ui_accept"): | ||
print(get_global_mouse_position()) | ||
|
||
|
||
#draw the outline of the big shape. | ||
func _draw(): | ||
for ob in nodes: | ||
var temp_2 = ob | ||
var temp = nodes[ob] | ||
for ob in temp: | ||
draw_line(ob, temp_2, Color.white, 10.0) | ||
|
||
|
||
|
||
#sort based on x value if there the same y value | ||
func custom_sort(a, b): | ||
if a.x < b.x: | ||
return true | ||
if a.x == b.x: | ||
if a.y < b.y: | ||
return true | ||
return false | ||
|
||
|
||
#find inbetween what it is and shove it in there. | ||
func _increase_in_conn(temp, keys, nodes, num): | ||
if !(temp.empty()): | ||
var i = 0 | ||
for ob in temp: | ||
if keys[num].y <= ob.y: | ||
return i | ||
i += 1 | ||
return temp.size() | ||
else: | ||
return 0 | ||
|
||
|
||
func _decrease_in_conn(temp, keys, nodes, num, fuck): | ||
var index = temp.find(nodes[keys[num]][fuck]) | ||
if index >= 0 : return index | ||
|
||
|
||
#find brother and replace it | ||
func _not_increase_in_conn(temp, keys, nodes, num): | ||
var index = temp.find(nodes[keys[num]][0]) | ||
if index >= 0 : return index | ||
else: | ||
index = temp.find(nodes[keys[num]][1]) | ||
if index >= 0: return index | ||
else: return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[gd_scene load_steps=2 format=2] | ||
|
||
[ext_resource path="res://test_1.gd" type="Script" id=1] | ||
|
||
[node name="main" type="Node2D"] | ||
script = ExtResource( 1 ) |