-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aaed1be
commit 0398861
Showing
7 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using FastMember; | ||
using TypeWrapping; | ||
|
||
namespace BveTypes.ClassWrappers | ||
{ | ||
/// <summary> | ||
/// 自軌道のカーブを表します。 | ||
/// </summary> | ||
/// <remarks> | ||
/// 緩和曲線、円曲線のどちらもこのクラスで定義します。緩和曲線の場合は 1m ごとに曲率が変化するため、曲率の変化する 1m ごとに定義します。 | ||
/// </remarks> | ||
public class Curve : MapObjectBase | ||
{ | ||
[InitializeClassWrapper] | ||
private static void Initialize(BveTypeSet bveTypes) | ||
{ | ||
ClassMemberSet members = bveTypes.GetClassInfoOf<Curve>(); | ||
|
||
CurvatureGetMethod = members.GetSourcePropertyGetterOf(nameof(Curvature)); | ||
CurvatureSetMethod = members.GetSourcePropertySetterOf(nameof(Curvature)); | ||
|
||
DirectionGetMethod = members.GetSourcePropertyGetterOf(nameof(Direction)); | ||
DirectionSetMethod = members.GetSourcePropertySetterOf(nameof(Direction)); | ||
} | ||
|
||
/// <summary> | ||
/// オリジナル オブジェクトから <see cref="Curve"/> クラスの新しいインスタンスを初期化します。 | ||
/// </summary> | ||
/// <param name="src">ラップするオリジナル オブジェクト。</param> | ||
protected Curve(object src) : base(src) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// オリジナル オブジェクトからラッパーのインスタンスを生成します。 | ||
/// </summary> | ||
/// <param name="src">ラップするオリジナル オブジェクト。</param> | ||
/// <returns>オリジナル オブジェクトをラップした <see cref="Curve"/> クラスのインスタンス。</returns> | ||
[CreateClassWrapperFromSource] | ||
public static Curve FromSource(object src) => src is null ? null : new Curve(src); | ||
|
||
private static FastMethod CurvatureGetMethod; | ||
private static FastMethod CurvatureSetMethod; | ||
/// <summary> | ||
/// このカーブの曲率 [/m]、すなわち半径 [m] の逆数を取得・設定します。 | ||
/// </summary> | ||
public double Curvature | ||
{ | ||
get => CurvatureGetMethod.Invoke(Src, null); | ||
set => CurvatureSetMethod.Invoke(Src, new object[] { value }); | ||
} | ||
|
||
private static FastMethod DirectionGetMethod; | ||
private static FastMethod DirectionSetMethod; | ||
/// <summary> | ||
/// このカーブの始点における方角を取得・設定します。 | ||
/// </summary> | ||
public double Direction | ||
{ | ||
get => DirectionGetMethod.Invoke(Src, null); | ||
set => DirectionSetMethod.Invoke(Src, new object[] { value }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using TypeWrapping; | ||
|
||
namespace BveTypes.ClassWrappers | ||
{ | ||
/// <summary> | ||
/// 自軌道のカーブのリストを表します。 | ||
/// </summary> | ||
public class CurveList : MapObjectList | ||
{ | ||
[InitializeClassWrapper] | ||
private static void Initialize(BveTypeSet bveTypes) | ||
{ | ||
ClassMemberSet members = bveTypes.GetClassInfoOf<CurveList>(); | ||
} | ||
|
||
/// <summary> | ||
/// オリジナル オブジェクトから <see cref="CurveList"/> クラスの新しいインスタンスを初期化します。 | ||
/// </summary> | ||
/// <param name="src">ラップするオリジナル オブジェクト。</param> | ||
protected CurveList(IList src) : base(src) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// オリジナル オブジェクトからラッパーのインスタンスを生成します。 | ||
/// </summary> | ||
/// <param name="src">ラップするオリジナル オブジェクト。</param> | ||
/// <returns>オリジナル オブジェクトをラップした <see cref="CurveList"/> クラスのインスタンス。</returns> | ||
[CreateClassWrapperFromSource] | ||
public static new CurveList FromSource(object src) => src is null ? null : new CurveList((IList)src); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using SlimDX; | ||
|
||
using FastMember; | ||
using TypeWrapping; | ||
|
||
namespace BveTypes.ClassWrappers | ||
{ | ||
/// <summary> | ||
/// 自軌道を表します。 | ||
/// </summary> | ||
public class MyTrack : ClassWrapperBase | ||
{ | ||
[InitializeClassWrapper] | ||
private static void Initialize(BveTypeSet bveTypes) | ||
{ | ||
ClassMemberSet members = bveTypes.GetClassInfoOf<MyTrack>(); | ||
|
||
CurvesGetMethod = members.GetSourcePropertyGetterOf(nameof(Curves)); | ||
|
||
CurvePostsGetMethod = members.GetSourcePropertyGetterOf(nameof(CurvePosts)); | ||
|
||
GetDirectionAtMethod = members.GetSourceMethodOf(nameof(GetDirectionAt)); | ||
GetPositionMethod = members.GetSourceMethodOf(nameof(GetPosition)); | ||
} | ||
|
||
/// <summary> | ||
/// オリジナル オブジェクトから <see cref="MyTrack"/> クラスの新しいインスタンスを初期化します。 | ||
/// </summary> | ||
/// <param name="src">ラップするオリジナル オブジェクト。</param> | ||
protected MyTrack(object src) : base(src) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// オリジナル オブジェクトからラッパーのインスタンスを生成します。 | ||
/// </summary> | ||
/// <param name="src">ラップするオリジナル オブジェクト。</param> | ||
/// <returns>オリジナル オブジェクトをラップした <see cref="MyTrack"/> クラスのインスタンス。</returns> | ||
[CreateClassWrapperFromSource] | ||
public static MyTrack FromSource(object src) => src is null ? null : new MyTrack(src); | ||
|
||
private static FastMethod CurvesGetMethod; | ||
/// <summary> | ||
/// 緩和曲線および円曲線のリストを取得します。 | ||
/// </summary> | ||
public CurveList Curves => CurveList.FromSource(CurvesGetMethod.Invoke(Src, null)); | ||
|
||
private static FastMethod CurvePostsGetMethod; | ||
/// <summary> | ||
/// 円曲線の開始距離程と半径のペアを表す <see cref="ValueNode{T}"/> (T は <see cref="double"/>) のリストを取得します。 | ||
/// </summary> | ||
public MapObjectList CurvePosts => MapObjectList.FromSource(CurvePostsGetMethod.Invoke(Src, null)); | ||
|
||
private static FastMethod GetDirectionAtMethod; | ||
/// <summary> | ||
/// 指定した距離程において自軌道が向いている方角を求めます。 | ||
/// </summary> | ||
/// <param name="location">方角を求める距離程 [m]。</param> | ||
/// <returns>距離程 <paramref name="location"/> にて自軌道が向いている方角。</returns> | ||
public double GetDirectionAt(int location) => GetDirectionAtMethod.Invoke(Src, new object[] { location }); | ||
|
||
private static FastMethod GetPositionMethod; | ||
/// <summary> | ||
/// 指定した距離程を基点とした、目標距離程における自軌道の位置ベクトル [m] の差を求めます。 | ||
/// </summary> | ||
/// <param name="locationTo">目標距離程 [m]。</param> | ||
/// <param name="locationFrom">基点とする距離程 [m]。</param> | ||
/// <returns>距離程 <paramref name="locationFrom"/> を基点とした、距離程 <paramref name="locationTo"/> における自軌道の位置ベクトル。</returns> | ||
public Vector3 GetPosition(double locationTo, double locationFrom) => GetPositionMethod.Invoke(Src, new object[] { locationTo, locationFrom }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters