Author Topic: Algorithm I find useful when FREDing...  (Read 3909 times)

0 Members and 1 Guest are viewing this topic.

Offline Joey_21

  • 28
    • http://denebsystem.cjb.net/
Algorithm I find useful when FREDing...
Let's suppose I placed a ship (a Deimos) at (8.1, -100, 4016) in FRED and a waypoint for it to travel to at (-9969, -766, 819) (to keep the mission from looking flat, these points make a nice 3rd dimensional mission). Then let's say I wanted to relieve the player's wing at 7000 meters from the first point on the way toward the second point with another waypoint set at that exact distance from the start. I don't have really good judgement when it comes to placing points like that so I found an algorithm and programmed it for C++. Do you SCP guys think you can put this feature under some menu in FRED2 for these kinds of calculations?

I would do it... but I haven't gotten that far in my programming course to be capable of doing something like that. ;)

What do you guys think? Good? Bad?

Code: [Select]

#include
#include
#include

void main()
{
// declaration of variables
double x, x2, y, y2, z, z2, nd, t;

cout << setprecision(10);

// get coodinates and new distance from user
cout << "Enter x1: ";
cin >> x;
cout << "Enter x2: ";
cin >> x2;
cout << "Enter y1: ";
cin >> y;
cout << "Enter y2: ";
cin >> y2;
cout << "Enter z1: ";
cin >> z;
cout << "Enter z2: ";
cin >> z2;
cout << "Enter a new distance: ";
cin >> nd;

// subtract x's, y's, and z's like in the distance formula
x2 = x2-x;
y2 = y2-y;
z2 = z2-z;

// get ratio for new point
t = sqrt((nd*nd)/(x2*x2 + y2*y2 + z2*z2));

// calculate new x, y, and z
x += (x2*t);
y += (y2*t);
z += (z2*t);

// give user new point
cout << "New point:\n" << x << ", " << y << ", " << z << "\n";

} // end main()

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Algorithm I find useful when FREDing...
Okay, can you explain that again? :lol: That's great that you have a program to help with FRED, but I'm not exactly sure what it does. :)

 

Offline Joey_21

  • 28
    • http://denebsystem.cjb.net/
Algorithm I find useful when FREDing...
Heh... ok...

go into FRED2 and place a Deimos at (8.1, -100, 4016). Place a waypoint at (-9969, -766, 819). Give the Deimos orders to travel to the waypoint. Suppose you wanted to relieve alpha wing 7000 meters from where the Deimos started. (-9969, -766, 819) is much farther than 7000 meters. Placing a waypoint at the point which this algorithm gives us will allow us to trigger an event to say something like "alpha wing is relieved, return to base" etc. etc.

 

Offline IceFire

  • GTVI Section 3
  • 212
    • http://www.3dap.com/hlp/hosted/ce
Algorithm I find useful when FREDing...
What about doing a distance to waypoint check that is already present?  Am I missing something?
- IceFire
BlackWater Ops, Cold Element
"Burn the land, boil the sea, you can't take the sky from me..."

 

Offline diamondgeezer

Algorithm I find useful when FREDing...
So... you give the equation two points and a distance, and it works out a location at the given distance between the two points? Right?

If I have this right, then... I see no useful purpose, to be honest. We already have distance operators and guess work, which have always worked for me :)

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Algorithm I find useful when FREDing...
Well, no, this has its uses.  There could be a button that automatically puts a waypoint at X distance from a ship, facing in the ship's direction.  You can't do this easily if the ship isn't perfectly aligned on one of the axes.

Another good function could be to position a waypoint at the location that the ship will be in X seconds, according to the speed specified in ships.tbl.

 

Offline Joey_21

  • 28
    • http://denebsystem.cjb.net/
Algorithm I find useful when FREDing...
Quote
Originally posted by Goober5000
There could be a button that automatically puts a waypoint at X distance from a ship, facing in the ship's direction.  You can't do this easily if the ship isn't perfectly aligned on one of the axes.


:nod: Hence my post.

 

Offline ZylonBane

  • The Infamous
  • 29
Algorithm I find useful when FREDing...
Quote
Originally posted by Goober5000
Another good function could be to position a waypoint at the location that the ship will be in X seconds, according to the speed specified in ships.tbl.
Good for what?
ZylonBane's opinions do not represent those of the management.

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Algorithm I find useful when FREDing...
for putting a point or something x meters in front of a ship, though we do have a function that does this already
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Algorithm I find useful when FREDing...
Quote
Originally posted by ZylonBane
Good for what?


:rolleyes: Suppose we want two ships to rendezvous with each other.  There are a few missions I've thought of where this could be helpful.

Quote
Originally posted by Bobboau
for putting a point or something x meters in front of a ship, though we do have a function that does this already


We do?  In FRED?  What is it?

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Algorithm I find useful when FREDing...
I didn't mean in fred i meant in the code base it's called (I think, something like) vm_vec_scale_add, it's used a lot
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Algorithm I find useful when FREDing...
Oh, right.  But putting it in FRED would be A-1 SUPAR. :nod:

 
Algorithm I find useful when FREDing...
ok, stupid, n00bish ideae here:

what about a macro like thingie for FRED, based on some easy programming languish, wich doesn't nead compiling. so basicly, FRED runs something from a ASCII file, containing the nesecary mathemetical operations and commands for placing ships. this should make things lot's easier for FREDders who have problems like this.

however, this is probably some stupid and n00bish ideae, also since i don't have any FRED experience at all.
just another newbie without any modding, FREDding or real programming experience

you haven't learned masochism until you've tried to read a Microsoft help file.  -- Goober5000
I've got 2 drug-addict syblings and one alcoholic whore. And I'm a ****ing sociopath --an0n
You cannot defeat Windows through strength alone. Only patience, a lot of good luck, and a sledgehammer will do the job. --StratComm

 

Offline ZylonBane

  • The Infamous
  • 29
Algorithm I find useful when FREDing...
FS2 mission files are plain ASCII text. Probably be simpler to write a program to act directly on those.
ZylonBane's opinions do not represent those of the management.

 

Offline diamondgeezer

Algorithm I find useful when FREDing...
Hands up if you write missions in Wordpad instead of FREDII ;7

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Algorithm I find useful when FREDing...
Quote
Originally posted by diamondgeezer
Hands up if you write missions in Wordpad instead of FREDII ;7


Suddenly all the posts with FRED problems become clear :p
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline diamondgeezer

Algorithm I find useful when FREDing...
:nervous:

*runs*

  
Algorithm I find useful when FREDing...
Quote
Originally posted by ZylonBane
FS2 mission files are plain ASCII text. Probably be simpler to write a program to act directly on those.


perhaps it is, but it would be harder to use alongside FRED. it's just an idea tough, and i haven't got a clue how easy it would be to implement, but if it can be made. Things might get easier, since FREDders wouldn't need to do many used operations over and over again, they'd just use a macro, and get on with their mission. but since i don't use FRED nor have any programming experience aside QuickBasic and opening the Delphi editor, i geuss i'm just talking nosense here.
just another newbie without any modding, FREDding or real programming experience

you haven't learned masochism until you've tried to read a Microsoft help file.  -- Goober5000
I've got 2 drug-addict syblings and one alcoholic whore. And I'm a ****ing sociopath --an0n
You cannot defeat Windows through strength alone. Only patience, a lot of good luck, and a sledgehammer will do the job. --StratComm