TrackSegments/TrackSWCorner.xaml.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace F1.TrackSegments
{
/// <summary>
/// Interaction logic for TrackSWCorner.xaml
/// </summary>
public partial class TrackSWCorner : UserControl, ITrackSegment
{
public const double SEGMENT_HEIGHT = 200;
public const double SEGMENT_WIDTH = 200;
public TrackSWCorner()
{
InitializeComponent();
}
public Point GetMidTrackPoint(double x, double y)
{
var dX = this.Position.X + SEGMENT_WIDTH - x;
var dY = y - this.Position.Y;
var h = Math.Sqrt(dX * dX + dY * dY);
var cos = dX / h;
var sin = dY / h;
var aCos = Math.Acos(cos);
var trackX = this.Position.X + SEGMENT_WIDTH - (SEGMENT_WIDTH / 2) * cos;
var trackY = this.Position.Y + (SEGMENT_HEIGHT / 2) * sin;
return new Point(trackX, trackY);
}
public double GetTrackAngle(double x, double y, double lastAngle, double lastCarAngle)
{
var dX = this.Position.X + SEGMENT_WIDTH - x;
var dY = y - this.Position.Y;
var h = Math.Sqrt(dX * dX + dY * dY);
var cos = dX / h;
var aCos = Math.Acos(cos);
var angle = 0.0;
var modLastCarAngle = lastCarAngle % 360;
if (modLastCarAngle < 0)
modLastCarAngle = 360.0 + modLastCarAngle;
if (modLastCarAngle >= 0 && modLastCarAngle <= 180)
{
angle = 180.0 + 90.0 * (aCos / (Math.PI / 2));
}
后面还有 13 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。