diff --git a/BonVision/BonVision.csproj b/BonVision/BonVision.csproj index 19b7a6e..103bc13 100644 --- a/BonVision/BonVision.csproj +++ b/BonVision/BonVision.csproj @@ -14,7 +14,7 @@ true net462 strict - 0.9.0 + 0.9.1 diff --git a/BonVision/DegreeConverter.cs b/BonVision/DegreeConverter.cs index 0d4d69e..60dda4e 100644 --- a/BonVision/DegreeConverter.cs +++ b/BonVision/DegreeConverter.cs @@ -6,14 +6,24 @@ namespace BonVision { class DegreeConverter : SingleConverter { + public static double RadianToDegree(double value) + { + return value * (180.0 / Math.PI); + } + + public static double DegreeToRadian(double value) + { + return value * (Math.PI / 180.0); + } + public static float RadianToDegree(float value) { - return (float)(value * (180.0 / Math.PI)); + return (float)RadianToDegree((double)value); } public static float DegreeToRadian(float value) { - return (float)(value * (Math.PI / 180.0)); + return (float)DegreeToRadian((double)value); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) @@ -42,7 +52,7 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul class NullableDegreeConverter : NullableConverter { - TypeConverter degreeConverter; + readonly TypeConverter degreeConverter; public NullableDegreeConverter(Type type) : base(type) diff --git a/BonVision/Environment/ViewWindow.bonsai b/BonVision/Environment/ViewWindow.bonsai index 9b1623d..005c611 100644 --- a/BonVision/Environment/ViewWindow.bonsai +++ b/BonVision/Environment/ViewWindow.bonsai @@ -48,7 +48,7 @@ - + diff --git a/BonVision/RotationConverter.cs b/BonVision/RotationConverter.cs index 42c83ad..ab1443a 100644 --- a/BonVision/RotationConverter.cs +++ b/BonVision/RotationConverter.cs @@ -10,8 +10,8 @@ class RotationConverter : NumericRecordConverter { public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { - var rotation = (Point3f)base.ConvertFrom(context, culture, value); - return new Point3f( + var rotation = (Point3d)base.ConvertFrom(context, culture, value); + return new Point3d( DegreeConverter.DegreeToRadian(rotation.X), DegreeConverter.DegreeToRadian(rotation.Y), DegreeConverter.DegreeToRadian(rotation.Z)); @@ -19,8 +19,8 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { - var rotation = (Point3f)value; - value = new Point3f( + var rotation = (Point3d)value; + value = new Point3d( DegreeConverter.RadianToDegree(rotation.X), DegreeConverter.RadianToDegree(rotation.Y), DegreeConverter.RadianToDegree(rotation.Z)); diff --git a/BonVision/RotationProperty.cs b/BonVision/RotationProperty.cs index 72702da..52f08a8 100644 --- a/BonVision/RotationProperty.cs +++ b/BonVision/RotationProperty.cs @@ -14,13 +14,13 @@ namespace BonVision [WorkflowElementCategory(ElementCategory.Source)] public class RotationProperty { - Point3f value; - event Action ValueChanged; + Point3d value; + event Action ValueChanged; [XmlIgnore] [TypeConverter(typeof(RotationConverter))] [Description("The value of the rotation vector, in euler angle format.")] - public Point3f Value + public Point3d Value { get { return value; } set @@ -32,39 +32,39 @@ public Point3f Value [Browsable(false)] [XmlElement("Value")] - public Point3f ValueXml + public Point3d ValueXml { get { var x = DegreeConverter.RadianToDegree(value.X); var y = DegreeConverter.RadianToDegree(value.Y); var z = DegreeConverter.RadianToDegree(value.Z); - return new Point3f(x, y, z); + return new Point3d(x, y, z); } set { var x = DegreeConverter.DegreeToRadian(value.X); var y = DegreeConverter.DegreeToRadian(value.Y); var z = DegreeConverter.DegreeToRadian(value.Z); - this.value = new Point3f(x, y, z); + this.value = new Point3d(x, y, z); } } - void OnValueChanged(Point3f value) + void OnValueChanged(Point3d value) { ValueChanged?.Invoke(value); } - public IObservable Process() + public IObservable Process() { return Observable .Defer(() => Observable.Return(value)) - .Concat(Observable.FromEvent( + .Concat(Observable.FromEvent( handler => ValueChanged += handler, handler => ValueChanged -= handler)); } - public IObservable Process(IObservable source) + public IObservable Process(IObservable source) { return source.Select(x => value); }