gpt4 book ai didi

iphone - 度数的主要风向?

转载 作者:搜寻专家 更新时间:2023-10-30 19:50:26 25 4
gpt4 key购买 nike

有没有人在 Objective C 中有一些示例代码,其中风度(即 180 度变成 S(南))转换为基本风向(N、NNE、SSE、SE 等)?

最佳答案

怎么样

- (NSString *)windDirectionFromDegrees:(float)degrees
{
static NSArray *directions;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// Initialize array on first call.
directions = @[@"N", @"NNE", @"NE", @"ENE", @"E", @"ESE", @"SE", @"SSE",
@"S", @"SSW", @"SW", @"WSW", @"W", @"WNW", @"NW", @"NNW"];
});

int i = (degrees + 11.25)/22.5;
return directions[i % 16];
}

(我假设 degrees 不是负数。)

关于iphone - 度数的主要风向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13220367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com