6 namespace droid.Runtime.Utilities.Structs {
14 public int DecimalGranularity {
15 get {
return this._decimal_granularity; }
16 set { this._decimal_granularity = value; }
28 get {
return this._distribution_sampler; }
29 set { this._distribution_sampler = value; }
35 public bool IsNormalised {
get {
return this.normalised; }
set { this.normalised = value; } }
52 public Space4(
int decimal_granularity = 2) : this() {
53 this._decimal_granularity = decimal_granularity;
54 this._Min_Values = Vector4.negativeInfinity;
55 this._Max_Values = Vector4.positiveInfinity;
62 public Vector4 Span {
get {
return this._Max_Values - this._Min_Values; } }
69 return new Space1(this.DecimalGranularity) {
70 _Min_Value = this._Min_Values.x,
71 _Max_Value = this._Max_Values.x
81 return new Space1(this.DecimalGranularity) {
82 _Min_Value = this._Min_Values.y,
83 _Max_Value = this._Max_Values.y
93 return new Space1(this.DecimalGranularity) {
94 _Min_Value = this._Min_Values.z,
95 _Max_Value = this._Max_Values.z
105 return new Space1(this.DecimalGranularity) {
106 _Min_Value = this._Min_Values.w,
107 _Max_Value = this._Max_Values.w
122 return new Vector4(x, y, z, w);
130 var vector = this.Sample();
131 return new Quaternion(vector.x, vector.y, vector.z, vector.w);
140 if (v.x >
this._Max_Values.x) {
141 v.x = this._Max_Values.x;
142 }
else if (v.x <
this._Min_Values.x) {
143 v = this._Min_Values;
146 if (this.Span.x > 0) {
147 v.x = this.Round((v.x -
this._Min_Values.x) /
this.Span.x);
152 if (v.y >
this._Max_Values.y) {
153 v.y = this._Max_Values.y;
154 }
else if (v.y <
this._Min_Values.y) {
155 v = this._Min_Values;
158 if (this.Span.y > 0) {
159 v.y = this.Round((v.y -
this._Min_Values.y) /
this.Span.y);
164 if (v.z >
this._Max_Values.z) {
165 v.z = this._Max_Values.z;
166 }
else if (v.z <
this._Min_Values.z) {
167 v = this._Min_Values;
170 if (this.Span.z > 0) {
171 v.z = this.Round((v.z -
this._Min_Values.z) /
this.Span.z);
176 if (v.w >
this._Max_Values.w) {
177 v.w = this._Max_Values.w;
178 }
else if (v.w <
this._Min_Values.w) {
179 v = this._Min_Values;
182 if (this.Span.w > 0) {
183 v.w = this.Round((v.w -
this._Min_Values.w) /
this.Span.w);
196 public float Round(
float v) {
return (
float)Math.Round(v, this.DecimalGranularity); }
202 get {
return new Space4(1) {_Min_Values = Vector4.zero, _Max_Values = Vector4.one}; }
209 get {
return new Space4(1) {_Min_Values = Vector4.one * 0.2f, _Max_Values = Vector4.one * 0.8f}; }
216 get {
return new Space4(2) {_Min_Values = -Vector4.one, _Max_Values = Vector4.one}; }
Vector4 ClipNormaliseRound(Vector4 v)
float Range(float min, float max)
Space4(int decimal_granularity=2)
Quaternion RandomQuaternion()
DistributionSampler _distribution_sampler