Skip to content

Commit e41d380

Browse files
author
Hamish
committed
0.5 final commit
1 parent 258cddd commit e41d380

32 files changed

+1792
-21
lines changed

src/koside.sln

-12
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ VisualStudioVersion = 14.0.23107.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "koside", "koside\koside.csproj", "{F251A1CF-AFB1-4BF6-8FCA-2122C3AC6B9D}"
77
EndProject
8-
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Installer", "Installer\Installer.wixproj", "{B014AAA1-4EEF-48CE-8ECB-FDFF40A0127D}"
9-
EndProject
108
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "kOSMinimiser", "kOSMinimiser\kOSMinimiser.csproj", "{4B417E9B-11D8-46B5-9D47-F36D4008B128}"
119
EndProject
1210
Global
@@ -37,16 +35,6 @@ Global
3735
{F251A1CF-AFB1-4BF6-8FCA-2122C3AC6B9D}.Release|x64.Build.0 = Release|Any CPU
3836
{F251A1CF-AFB1-4BF6-8FCA-2122C3AC6B9D}.Release|x86.ActiveCfg = Release|Any CPU
3937
{F251A1CF-AFB1-4BF6-8FCA-2122C3AC6B9D}.Release|x86.Build.0 = Release|Any CPU
40-
{B014AAA1-4EEF-48CE-8ECB-FDFF40A0127D}.Debug|Any CPU.ActiveCfg = Debug|x86
41-
{B014AAA1-4EEF-48CE-8ECB-FDFF40A0127D}.Debug|ARM.ActiveCfg = Debug|x86
42-
{B014AAA1-4EEF-48CE-8ECB-FDFF40A0127D}.Debug|x64.ActiveCfg = Debug|x86
43-
{B014AAA1-4EEF-48CE-8ECB-FDFF40A0127D}.Debug|x86.ActiveCfg = Debug|x86
44-
{B014AAA1-4EEF-48CE-8ECB-FDFF40A0127D}.Debug|x86.Build.0 = Debug|x86
45-
{B014AAA1-4EEF-48CE-8ECB-FDFF40A0127D}.Release|Any CPU.ActiveCfg = Release|x86
46-
{B014AAA1-4EEF-48CE-8ECB-FDFF40A0127D}.Release|ARM.ActiveCfg = Release|x86
47-
{B014AAA1-4EEF-48CE-8ECB-FDFF40A0127D}.Release|x64.ActiveCfg = Release|x86
48-
{B014AAA1-4EEF-48CE-8ECB-FDFF40A0127D}.Release|x86.ActiveCfg = Release|x86
49-
{B014AAA1-4EEF-48CE-8ECB-FDFF40A0127D}.Release|x86.Build.0 = Release|x86
5038
{4B417E9B-11D8-46B5-9D47-F36D4008B128}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5139
{4B417E9B-11D8-46B5-9D47-F36D4008B128}.Debug|Any CPU.Build.0 = Debug|Any CPU
5240
{4B417E9B-11D8-46B5-9D47-F36D4008B128}.Debug|ARM.ActiveCfg = Debug|Any CPU

src/koside/Forms/Form1.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,10 @@ private void Open()
11051105
//Open a file
11061106
OpenFileDialog theDialog = new OpenFileDialog();
11071107
theDialog.Title = "Open Script";
1108-
theDialog.Filter = "kOS Scripts|*.ks|Kode Project Files|*.ksproj";
1108+
if(Properties.Settings.Default.mode == true)
1109+
theDialog.Filter = "Kode Project Files|*.ksproj|kOS Scripts|*.ks";
1110+
else
1111+
theDialog.Filter = "kOS Scripts|*.ks|Kode Project Files|*.ksproj";
11091112
theDialog.InitialDirectory = Path.Combine(CurrentInstall, "Ships", "Script");
11101113
if (theDialog.ShowDialog() == DialogResult.OK)
11111114
{
@@ -1140,7 +1143,10 @@ private void Open()
11401143
//Open a file
11411144
OpenFileDialog theDialogi = new OpenFileDialog();
11421145
theDialogi.Title = "Open Script";
1143-
theDialogi.Filter = "kOS Scripts|*.ks|Kode Project Files|*.ksproj";
1146+
if (Properties.Settings.Default.mode == true)
1147+
theDialogi.Filter = "Kode Project Files|*.ksproj|kOS Scripts|*.ks";
1148+
else
1149+
theDialogi.Filter = "kOS Scripts|*.ks|Kode Project Files|*.ksproj";
11441150
theDialogi.InitialDirectory = Path.Combine(CurrentInstall, "Ships", "Script");
11451151
if (theDialogi.ShowDialog() == DialogResult.OK)
11461152
{

src/koside/KSFile.ico

1.12 KB
Binary file not shown.

src/koside/Libraries/LICENCE

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
ascent.ks docking.ks maneuver.ks rendezvous.ks:
2+
Copyright (c) 2015 Kevin Gisi
3+
4+
Permission is hereby granted, free of charge, to any person obtaining
5+
a copy of this software and associated documentation files (the
6+
"Software"), to deal in the Software without restriction, including
7+
without limitation the rights to use, copy, modify, merge, publish,
8+
distribute, sublicense, and/or sell copies of the Software, and to
9+
permit persons to whom the Software is furnished to do so, subject to
10+
the following conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
23+
24+
KSLib:
25+
The MIT License (MIT)
26+
27+
Copyright (c) 2015
28+
29+
Permission is hereby granted, free of charge, to any person obtaining a copy
30+
of this software and associated documentation files (the "Software"), to deal
31+
in the Software without restriction, including without limitation the rights
32+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33+
copies of the Software, and to permit persons to whom the Software is
34+
furnished to do so, subject to the following conditions:
35+
36+
The above copyright notice and this permission notice shall be included in all
37+
copies or substantial portions of the Software.
38+
39+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45+
SOFTWARE.
46+

src/koside/Libraries/ascent.ks

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Execute Ascent Profile v1.0.0
2+
// Kevin Gisi
3+
// http://youtube.com/gisikw
4+
5+
FUNCTION EXECUTE_ASCENT_STEP {
6+
PARAMETER direction.
7+
PARAMETER minAlt.
8+
PARAMETER newAngle.
9+
PARAMETER newThrust.
10+
11+
SET prevThrust TO MAXTHRUST.
12+
13+
UNTIL FALSE {
14+
15+
IF MAXTHRUST < (prevThrust - 10) {
16+
SET currentThrottle TO THROTTLE.
17+
LOCK THROTTLE TO 0.
18+
WAIT 1. STAGE. WAIT 1.
19+
LOCK THROTTLE TO currentThrottle.
20+
SET prevThrust TO MAXTHRUST.
21+
}
22+
23+
IF ALTITUDE > minAlt {
24+
LOCK STEERING TO HEADING(direction, newAngle).
25+
LOCK THROTTLE TO newThrust.
26+
BREAK.
27+
}
28+
29+
WAIT 0.1.
30+
}
31+
}
32+
33+
FUNCTION EXECUTE_ASCENT_PROFILE {
34+
PARAMETER direction.
35+
PARAMETER profile.
36+
37+
SET step TO 0.
38+
UNTIL step >= profile:length - 1 {
39+
EXECUTE_ASCENT_STEP(
40+
direction,
41+
profile[step],
42+
profile[step+1],
43+
profile[step+2]
44+
).
45+
SET step TO step + 3.
46+
}
47+
}

src/koside/Libraries/docking.ks

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
// Docking Library v1.0.0
2+
// Kevin Gisi
3+
// http://youtube.com/gisikw
4+
5+
FUNCTION dok_translate {
6+
PARAMETER vector.
7+
IF vector:MAG > 1 SET vector TO vector:normalized.
8+
9+
SET SHIP:CONTROL:STARBOARD TO vector * SHIP:FACING:STARVECTOR.
10+
SET SHIP:CONTROL:FORE TO vector * SHIP:FACING:FOREVECTOR.
11+
SET SHIP:CONTROL:TOP TO vector * SHIP:FACING:TOPVECTOR.
12+
}
13+
14+
FUNCTION dok_get_port {
15+
PARAMETER name.
16+
LIST TARGETS IN targets.
17+
targets:add(SHIP).
18+
FOR target IN targets {
19+
IF target:DOCKINGPORTS:LENGTH <> 0 {
20+
FOR port IN target:DOCKINGPORTS {
21+
IF port:TAG = name RETURN port.
22+
}
23+
}
24+
}
25+
}
26+
27+
FUNCTION dok_approach_port {
28+
PARAMETER targetPort, dockingPort, distance, speed.
29+
30+
dockingPort:CONTROLFROM().
31+
32+
LOCK distanceOffset TO targetPort:PORTFACING:VECTOR * distance.
33+
LOCK approachVector TO targetPort:NODEPOSITION - dockingPort:NODEPOSITION + distanceOffset.
34+
LOCK relativeVelocity TO SHIP:VELOCITY:ORBIT - targetPort:SHIP:VELOCITY:ORBIT.
35+
LOCK STEERING TO LOOKDIRUP(-targetPort:PORTFACING:VECTOR, targetPort:PORTFACING:UPVECTOR).
36+
37+
UNTIL dockingPort:STATE <> "Ready" {
38+
dok_translate((approachVector:normalized * speed) - relativeVelocity).
39+
LOCAL distanceVector IS (targetPort:NODEPOSITION - dockingPort:NODEPOSITION).
40+
IF VANG(dockingPort:PORTFACING:VECTOR, distanceVector) < 2 AND abs(distance - distanceVector:MAG) < 0.1 {
41+
BREAK.
42+
}
43+
WAIT 0.01.
44+
}
45+
46+
dok_translate(V(0,0,0)).
47+
}
48+
49+
FUNCTION dok_ensure_range {
50+
PARAMETER targetVessel, dockingPort, distance, speed.
51+
52+
LOCK relativePosition TO SHIP:POSITION - targetVessel:POSITION.
53+
LOCK departVector TO (relativePosition:normalized * distance) - relativePosition.
54+
LOCK relativeVelocity TO SHIP:VELOCITY:ORBIT - targetVessel:VELOCITY:ORBIT.
55+
LOCK STEERING TO HEADING(0,0).
56+
57+
UNTIL FALSE {
58+
dok_translate((departVector:normalized * speed) - relativeVelocity).
59+
IF departVector:MAG < 0.1 BREAK.
60+
WAIT 0.01.
61+
}
62+
63+
dok_translate(V(0,0,0)).
64+
}
65+
66+
FUNCTION dok_sideswipe_port {
67+
PARAMETER targetPort, dockingPort, distance, speed.
68+
69+
dockingPort:CONTROLFROM().
70+
71+
// Get a direction perpendicular to the docking port
72+
LOCK sideDirection TO targetPort:SHIP:FACING:STARVECTOR.
73+
IF abs(sideDirection * targetPort:PORTFACING:VECTOR) = 1 {
74+
LOCK sideDirection TO targetPort:SHIP:FACING:TOPVECTOR.
75+
}
76+
77+
LOCK distanceOffset TO sideDirection * distance.
78+
// Flip the offset if we're on the other side of the ship
79+
IF (targetPort:NODEPOSITION - dockingPort:NODEPOSITION + distanceOffset):MAG <
80+
(targetPort:NODEPOSITION - dockingPort:NODEPOSITION - distanceOffset):MAG {
81+
LOCK distanceOffset TO (-sideDirection) * distance.
82+
}
83+
84+
LOCK approachVector TO targetPort:NODEPOSITION - dockingPort:NODEPOSITION + distanceOffset.
85+
LOCK relativeVelocity TO SHIP:VELOCITY:ORBIT - targetPort:SHIP:VELOCITY:ORBIT.
86+
LOCK STEERING TO -1 * targetPort:PORTFACING:VECTOR.
87+
88+
UNTIL FALSE {
89+
dok_translate((approachVector:normalized * speed) - relativeVelocity).
90+
IF approachVector:MAG < 0.1 BREAK.
91+
WAIT 0.01.
92+
}
93+
94+
dok_translate(V(0,0,0)).
95+
}
96+
97+
FUNCTION dok_kill_relative_velocity {
98+
PARAMETER targetPort.
99+
100+
LOCK relativeVelocity TO SHIP:VELOCITY:ORBIT - targetPort:SHIP:VELOCITY:ORBIT.
101+
UNTIL relativeVelocity:MAG < 0.1 {
102+
dok_translate(-relativeVelocity).
103+
}
104+
dok_translate(V(0,0,0)).
105+
}
106+
107+
FUNCTION dok_dock {
108+
PARAMETER dockingPortTag, targetName, targetPortTag.
109+
SET dockingPort TO dok_get_port(dockingPortTag).
110+
SET targetVessel TO VESSEL(targetName).
111+
dockingPort:controlfrom.
112+
113+
RCS ON.
114+
dok_ensure_range(targetVessel, dockingPort, 100, 1).
115+
116+
SET targetPort TO dok_get_port(targetPortTag).
117+
dok_kill_relative_velocity(targetPort).
118+
dok_sideswipe_port(targetPort, dockingPort, 100, 1).
119+
dok_approach_port(targetPort, dockingPort, 100, 1).
120+
dok_approach_port(targetPort, dockingPort, 50, 1).
121+
dok_approach_port(targetPort, dockingPort, 20, 1).
122+
dok_approach_port(targetPort, dockingPort, 10, 0.5).
123+
dok_approach_port(targetPort, dockingPort, 0, 0.5).
124+
RCS OFF.
125+
}
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// This file is distributed under the terms of the MIT license, (c) the KSLib team
2+
3+
4+
@LAZYGLOBAL OFF.
5+
6+
//use to find the initial bearing for the shortest path around a sphere from...
7+
function circle_bearing {
8+
parameter
9+
p1, //...this point...
10+
p2. //...to this point.
11+
12+
return mod(360+arctan2(sin(p2:lng-p1:lng)*cos(p2:lat),cos(p1:lat)*sin(p2:lat)-sin(p1:lat)*cos(p2:lat)*cos(p2:lng-p1:lng)),360).
13+
}.
14+
15+
//use to find where you will end up if you travel from...
16+
function circle_destination {
17+
parameter
18+
p1, //...this point...
19+
b, // ...with this as your intitial bearing...
20+
d, // ...for this distance...
21+
radius. // ...around a sphere of this radious.
22+
23+
local lat is arcsin(sin(p1:lat)*cos((d*180)/(radius*constant():pi))+cos(p1:lat)*sin((d*180)/(radius*constant():pi))*cos(b)).
24+
local lng is 0.
25+
if abs(Lat) <> 90 {
26+
set lng to p1:lng+arctan2(sin(b)*sin((d*180)/(radius*constant():pi))*cos(p1:lat),cos((d*180)/(radius*constant():pi))-sin(p1:lat)*sin(lat)).
27+
}.
28+
29+
return latlng(lat,lng).
30+
}.
31+
32+
//use to find the distance from...
33+
function circle_distance {
34+
parameter
35+
p1, //...this point...
36+
p2, //...to this point...
37+
radius. //...around a body of this radius. (note: if you are flying you may want to use ship:body:radius + altitude).
38+
local A is sin((p1:lat-p2:lat)/2)^2 + cos(p1:lat)*cos(p2:lat)*sin((p1:lng-p2:lng)/2)^2.
39+
40+
return radius*constant():PI*arctan2(sqrt(A),sqrt(1-A))/90.
41+
}.
42+
43+
//use to find the mid point on the outside of a sphere between...
44+
function circle_midpoint {
45+
parameter
46+
p1, //...this point...
47+
p2. //...and this point.
48+
local A is cos(p2:lat)*cos(p2:lng-p1:lng).
49+
local B is cos(p2:lat)*sin(p2:lng-P1:lng).
50+
51+
return latlng(arctan2(sin(p1:lat)+sin(p2:lat),sqrt((cos(p1:lat)+resultA)^2+resultB^2)),p1:lng+arctan2(resultB,cos(p1:lat)+resultA)).
52+
}.

0 commit comments

Comments
 (0)