我想创建一个计算波音747- 400 F所需起飞速度的工具.作为一个avgeek我自己,我有机会获得真实飞机的真实文件.

下图代表了气候条件,并被划分为区域(A、B、D.).通过了解当前的温度和机场海拔,您可以确定您所处的条件;例如,区域A.

Graphic with a lot of curves

背景

在 Select 了一个地区(A代表例如)之后,您将转到第二个表,在该表中您需要知道飞机的重量.在与区域A交叉后,您可以确定所需的起飞速度:V1、VR、V2.

Table with takeoff speeds

这两张图很容易用reading来确定起飞速度.不过,我想自动执行第一步:

问题

我如何才能将第一个图形转换成某种数据 struct ,以便在Java脚本或打字脚本代码中使用它?

推荐答案

您可以标识形成区域边界的多段线线段.获得该温度后,您可以使用给定的温度(x坐标)来查找围绕该温度的线段(每个边界最多一个),并确定这些线段中仍高于给定点的最低线段.如果从下(A)到上(J)迭代边界,则具有高于给定压力海拔高度的线段的第一个边界将标识该区域.

最主要的工作是识别多段线的线段.给你:

[
[[-55.2,29],[-50,160],[-40.7,335],[-30.2,510],[23.5,1239],[29.3,1050],[32.2,496],[38.3,-1370],[40.1,-2012]],
[[-55.2,2230],[10.2,3017],[16,3090],[22.4,3032],[27.6,2595],[31.9,2041],[34.6,1458],[40.1,58],[42.4,-641],[46,-2012]],
[[-55.2,4169],[1.5,4956],[11.9,5087],[19.9,5117],[24.7,4548],[33.1,3178],[37.5,2332],[40.4,1662],[43,1020],[46.8,0],[53.2,-2012]],
[[-55.2,5787],[-20,6210],[7,6516],[15.5,6531],[21.9,6210],[26.4,5510],[36.9,3411],[41,2566],[47.1,1137],[50.2,262],[57.9,-2012]],
[[-55.2,7551],[-0.3,8178],[7.8,8324],[16.3,8149],[23.2,7420],[28.8,6618],[31.9,6020],[40.4,4198],[50,2012],[54,1020],[64.9,-2012]],
[[-55.2,8863],[7.3,9679],[15.5,9344],[22.7,8455],[28.6,7580],[32.5,6880],[34.9,6443],[38.6,5685],[41.5,5015],[52.6,2507],[57.5,1283],[69.4,-2012]],
[[20.5,10029],[27.7,8980],[31.7,8338],[34.1,7901],[38.6,7026],[43.6,6006],[50.1,4548],[56.5,3032],[60.7,2041],[75,-1749]],
[[32.2,10029],[35.6,9519],[40.1,8688],[43.4,8017],[51,6414],[57.2,5015],[63.3,3557],[73.2,1050],[75,525]],
[[36.5,10029],[39.9,9592],[45.5,8513],[50.2,7522],[54.7,6531],[59,5510],[63,4519],[67.1,3528],[71.2,2536],[75,1633]],
]

这里有一个小片段,它使用这些信息来获得给定温度和气压-海拔的区域:

// The region's border lines specified as polyline coordinates:
const borders = [[[-55.2,29],[-50,160],[-40.7,335],[-30.2,510],[23.5,1239],[29.3,1050],[32.2,496],[38.3,-1370],[40.1,-2012]],[[-55.2,2230],[10.2,3017],[16,3090],[22.4,3032],[27.6,2595],[31.9,2041],[34.6,1458],[40.1,58],[42.4,-641],[46,-2012]],[[-55.2,4169],[1.5,4956],[11.9,5087],[19.9,5117],[24.7,4548],[33.1,3178],[37.5,2332],[40.4,1662],[43,1020],[46.8,0],[53.2,-2012]],[[-55.2,5787],[-20,6210],[7,6516],[15.5,6531],[21.9,6210],[26.4,5510],[36.9,3411],[41,2566],[47.1,1137],[50.2,262],[57.9,-2012]],[[-55.2,7551],[-0.3,8178],[7.8,8324],[16.3,8149],[23.2,7420],[28.8,6618],[31.9,6020],[40.4,4198],[50,2012],[54,1020],[64.9,-2012]],[[-55.2,8863],[7.3,9679],[15.5,9344],[22.7,8455],[28.6,7580],[32.5,6880],[34.9,6443],[38.6,5685],[41.5,5015],[52.6,2507],[57.5,1283],[69.4,-2012]],[[20.5,10029],[27.7,8980],[31.7,8338],[34.1,7901],[38.6,7026],[43.6,6006],[50.1,4548],[56.5,3032],[60.7,2041],[75,-1749]],[[32.2,10029],[35.6,9519],[40.1,8688],[43.4,8017],[51,6414],[57.2,5015],[63.3,3557],[73.2,1050],[75,525]],[[36.5,10029],[39.9,9592],[45.5,8513],[50.2,7522],[54.7,6531],[59,5510],[63,4519],[67.1,3528],[71.2,2536],[75,1633]]];

// Function to determine the region (A, B, ...) that corresponds to a 
//   given temperature (C°) and pressure-altitude (Ft):
function getRegion(temperatureCelcius, pressureAltitudeFeet) {
    // Return null when the inputs are out of range:
    if (temperatureCelcius < -55 || temperatureCelcius > 75) return null;
    if (pressureAltitudeFeet < -2000 || pressureAltitudeFeet > 10000) return null;
    // Find the region:
    const region = borders.findIndex(border => {
        // Find the segment on this polyline that concerns the given temperature
        const i = border.findIndex(([x1]) => x1 >= temperatureCelcius);
        if (i < 1) return !i; // There is no such segment: can be indication of region or not.
        // Get coordinates of the line segment that concerns this temperature
        const [[x0, y0], [x1, y1]] = border.slice(i - 1, i + 1);
        // Is our point below this line segment? Then we have identified the region
        return (pressureAltitudeFeet - y0) * (x1 - x0) < (temperatureCelcius - x0) * (y1 - y0);
    });
    return "JABCDEFGHI"[region+1]; // Translate the region index to a letter
}

// Demo for a temperature of 30°C and 5000 ft pressure-altitude.
const region = getRegion(30, 5000);
console.log(region); // "E"

如果给定输入的任一维度的值超出范围,则该函数将返回null.

Javascript相关问答推荐

容器如何更改默认插槽中子项的显示?

JavaScript文本区域阻止KeyDown/KeyUp事件本身上的Alt GR +键组合

如何为GrapesJS模板编辑器创建自定义撤销/重复按钮?

Phaser框架-将子对象附加到Actor

提交表格后保留Web表格中的收件箱值?

通过嵌套模型对象进行Mongoose搜索

Angular material 拖放堆叠的牌副,悬停时自动展开&

在react JS中映射数组对象的嵌套数据

React.Development.js和未捕获的ReferenceError:未定义useState

映射类型定义,其中值对应于键

Angular 形式,从DOM中删除不会删除指定索引处的内容,但会删除最后一项

Webpack在导入前混淆文件名

为什么延迟在我的laravel项目中不起作用?

如何使本地html页面在重新加载时保持当前可隐藏部分的打开状态?

bootstrap S JS赢得了REACT中的函数/加载

JSX/React -如何在组件props 中循环遍历数组

我如何才能让p5.js在不使用实例模式的情况下工作?

将Windows XP转换为原始数据以在html前端中显示

当一条路由在Reaction路由中命中时,如何有条件地渲染两个组件或更改两个插座?

JavaScript structuredClone在Chrome/Edge中获得了非法调用,但在NodeJS中没有