Author Topic: sin(x) and cos(x) SEXPs in FRED  (Read 4557 times)

0 Members and 1 Guest are viewing this topic.

Offline Shivan Hunter

  • 210
  • FRED needs lambdas!
sin(x) and cos(x) SEXPs in FRED
I was amazed they weren't in there already, and I think they'd be incredibly useful. It's not essential (I'm implementing a Taylor series now), but it would be nice.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: sin(x) and cos(x) SEXPs in FRED
yay! trig functions!

really just call a script eval and run math.cos(x)
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Re: sin(x) and cos(x) SEXPs in FRED
What would you use them for?
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
Re: sin(x) and cos(x) SEXPs in FRED
You can use them to simplify calculations checking whether an object is facing another object (though there's a simpler way to do it).  IIRC, only the player has a check to see if it's pointing at something, and you can try to use trig functions to evaluate angles and stuff.

It would probably be better if you added either Sin or Cos since there are so many ways to transfer between them.  Tan (x) and one of the others would probably be more useful than having both Sin and Cos.

EDIT: clarifications.
« Last Edit: November 03, 2011, 10:25:29 am by Cyborg17 »

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: sin(x) and cos(x) SEXPs in FRED
I thought we had the "facing" sexp (in the "training" category) for that.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
Re: sin(x) and cos(x) SEXPs in FRED
Last time I tried it, it worked only for the player. But I wasn't thorough.  I'll test it again tonight.

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: sin(x) and cos(x) SEXPs in FRED
Ah, sorry. Yes, "facing" only checks from the player perspective. "is-facing" (found under ship status) however can be used to check arbitrary objects.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
Re: sin(x) and cos(x) SEXPs in FRED
I missed it when I was looking for one then.  Scratch one possible use.  I can't think of any others unless you want to measure angles between ships, and that probably is only useful in scripting a Capital ship battle.  There's probably ways to work around it, too.

 

Offline Qent

  • 29
Re: sin(x) and cos(x) SEXPs in FRED
Use a SEXP to spawn a weapon pointing in a particular direction.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: sin(x) and cos(x) SEXPs in FRED
The problem is that sexps can only work with integers.  So this would have to be either a discrete function cycling between 0, -1, and 1, or a modified function like sin(x)*1000.

EDIT:
Use a SEXP to spawn a weapon pointing in a particular direction.
You can already do this by specifying target coordinates.

 

Offline Qent

  • 29
Re: sin(x) and cos(x) SEXPs in FRED
Er, I worded that wrong. I meant to spawn a weapon at some position, but pointing at an arbitrary ship somewhere else. Is that already possible? But I guess you'd want inverse trig functions for that anyway.

 

Offline Shivan Hunter

  • 210
  • FRED needs lambdas!
Re: sin(x) and cos(x) SEXPs in FRED
really just call a script eval and run math.cos(x)

ಠ_ಠ

The problem is that sexps can only work with integers.  So this would have to be either a discrete function cycling between 0, -1, and 1, or a modified function like sin(x)*1000.

:(

Oh well. What I was working on didn't turn out all that well anyway, in part for this exact reason.

 

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
Re: sin(x) and cos(x) SEXPs in FRED
I've been able to hack decimals before.  If you want to represent .389 for example just use:

Code: [Select]
/
389
1000

I haven't tried it for every sexp, but it seemed to work with no problem when I wanted it to place cameras for cut scenes.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: sin(x) and cos(x) SEXPs in FRED
really just call a script eval and run math.cos(x)

ಠ_ಠ

dont give me that i cant script crap its only one line of code!
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: sin(x) and cos(x) SEXPs in FRED
Er, I worded that wrong. I meant to spawn a weapon at some position, but pointing at an arbitrary ship somewhere else. Is that already possible? But I guess you'd want inverse trig functions for that anyway.
Definitely possible -- and you can even point it at nothing in particular.  For one example, take a look at the second version of DEM: Interlude.


I've been able to hack decimals before.  If you want to represent .389 for example just use:

Code: [Select]
/
389
1000

I haven't tried it for every sexp, but it seemed to work with no problem when I wanted it to place cameras for cut scenes.
Do enlighten us with an example mission.

 

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
Re: sin(x) and cos(x) SEXPs in FRED
Ok.  It's really rather simple.....

 I was making an example mission, and then I discovered that it's not good to put parentheses in Event names, especially when they are referenced by is-event-true-delay.  Let me just correct a few mistakes and I'll have it up.

 

Offline Shivan Hunter

  • 210
  • FRED needs lambdas!
Re: sin(x) and cos(x) SEXPs in FRED
Cyborg17: That would certainly be useful!

really just call a script eval and run math.cos(x)

ಠ_ಠ

dont give me that i cant script crap its only one line of code!

yes, I should make a script to execute a single line of code

hmm

 

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
Re: sin(x) and cos(x) SEXPs in FRED
Nevermind.  I was completely wrong.  I thought it seemed too obvious for you guys to miss.  Camera skips forward one unit instead of half a unit.  Time also rounds up and down.

 

Offline Qent

  • 29
Re: sin(x) and cos(x) SEXPs in FRED
Er, I worded that wrong. I meant to spawn a weapon at some position, but pointing at an arbitrary ship somewhere else. Is that already possible? But I guess you'd want inverse trig functions for that anyway.
Definitely possible -- and you can even point it at nothing in particular.  For one example, take a look at the second version of DEM: Interlude.
The Beta spazzout? That seems to use a constant angle of 90. Am I looking at the right thing? I'm talking about get-angle-to-ship or somesuch, so that a mine can spawn a missile pointed in whichever direction the ship is in.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: sin(x) and cos(x) SEXPs in FRED
Oh, I see what you mean.  Yes, that would require a get-[pitch/bank/heading]-to-location sexp, which is definitely doable, but not in SCP yet.