Board index FlightGear Development Nasal

Nasal function for textranslate

Nasal is the scripting language of FlightGear.

Nasal function for textranslate

Postby wlbragg » Mon Jul 23, 2018 8:59 pm

I made a helper function to give me the parameters for the textranslate animation. I find the method used to supply parameters for this animation bothersome, but probably because I am not well versed in this stuff. Anyway, here it is if anyone wants it. there is tons of room for improvement like an input interface. I use it so rarely though it wasn't worth the effort for me to create an input interface.
Oh, as written it only works for a square texture, maybe someone would want to add the conversion for a rectangle texture.
If there is an easier way to get this information, please don't laugh at me.

Code: Select all
var orgXpos=918.21;
var orgYpos=19.15;
var newXpos=848.74;
var newYpos=104.33;
var texSize=1024;

var xDist = newXpos - orgXpos;
var yDist = newYpos - orgYpos;

var squXdist = xDist * xDist;
var squYdist = yDist * yDist;

var fd = math.sqrt(squXdist + squYdist);

var factor = func (fd, texSize) {
    return fd / texSize;

var textTranFactor = factor(fd, texSize);
var textTranX = xDist / fd;
var textTranY = yDist / fd;

setprop("AtextTranFactor", textTranFactor);
setprop("AtextTranX", textTranX);
setprop("AtextTranY", textTranY);
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
Posts: 5873
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Return to Nasal

Who is online

Users browsing this forum: No registered users and 1 guest