Jypeli 10
The simple game programming library
MathWriter.cs
Siirry tämän tiedoston dokumentaatioon.
1#region MIT License
2/*
3 * Copyright (c) 2005-2008 Jonathan Mark Porter. http://physics2d.googlepages.com/
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22#endregion
23
24
25
26
27#if UseDouble
28using Scalar = System.Double;
29#else
30using Scalar = System.Single;
31#endif
32using System;
33using System.IO;
34using System.Text;
35
36namespace AdvanceMath.IO
37{
38 public class MathWriter : BinaryWriter
39 {
40 protected static Stream GetBaseStream(BinaryWriter writer)
41 {
42 if (writer == null) { throw new ArgumentNullException("writer"); }
43 return writer.BaseStream;
44 }
45 public MathWriter(Stream output)
46 : base(output) { }
47 public MathWriter(Stream output, Encoding encoding)
48 : base(output, encoding) { }
49 public MathWriter(BinaryWriter writer)
50 : base(GetBaseStream(writer)) { }
51 public void Write(Vector2D value)
52 {
53 Write(value.X);
54 Write(value.Y);
55 }
56 public void Write(Vector3D value)
57 {
58 Write(value.X);
59 Write(value.Y);
60 Write(value.Z);
61 }
62 public void Write(Vector4D value)
63 {
64 Write(value.X);
65 Write(value.Y);
66 Write(value.Z);
67 Write(value.W);
68 }
69 public void Write(Quaternion value)
70 {
71 Write(value.X);
72 Write(value.Y);
73 Write(value.Z);
74 Write(value.W);
75 }
76 public void Write(Matrix2x2 value)
77 {
78 Write(value.m00);
79 Write(value.m01);
80
81 Write(value.m10);
82 Write(value.m11);
83 }
84 public void Write(Matrix3x3 value)
85 {
86 Write(value.m00);
87 Write(value.m01);
88 Write(value.m02);
89
90 Write(value.m10);
91 Write(value.m11);
92 Write(value.m12);
93
94 Write(value.m20);
95 Write(value.m21);
96 Write(value.m22);
97 }
98 public void Write(Matrix4x4 value)
99 {
100 Write(value.m00);
101 Write(value.m01);
102 Write(value.m02);
103 Write(value.m03);
104
105 Write(value.m10);
106 Write(value.m11);
107 Write(value.m12);
108 Write(value.m13);
109
110 Write(value.m20);
111 Write(value.m21);
112 Write(value.m22);
113 Write(value.m23);
114
115 Write(value.m30);
116 Write(value.m31);
117 Write(value.m32);
118 Write(value.m33);
119 }
120 public void Write(Scalar[] array)
121 {
122 if (array == null) { throw new ArgumentNullException("array"); }
123 Write(array.Length);
124 for (int index = 0; index < array.Length; index++)
125 {
126 Write(array[index]);
127 }
128 }
129 }
130}
System.Single Scalar
Definition: Clamped.cs:29
void Write(Vector2D value)
Definition: MathWriter.cs:51
void Write(Vector3D value)
Definition: MathWriter.cs:56
void Write(Scalar[] array)
Definition: MathWriter.cs:120
void Write(Matrix3x3 value)
Definition: MathWriter.cs:84
MathWriter(Stream output)
Definition: MathWriter.cs:45
static Stream GetBaseStream(BinaryWriter writer)
Definition: MathWriter.cs:40
MathWriter(BinaryWriter writer)
Definition: MathWriter.cs:49
MathWriter(Stream output, Encoding encoding)
Definition: MathWriter.cs:47
void Write(Matrix2x2 value)
Definition: MathWriter.cs:76
void Write(Matrix4x4 value)
Definition: MathWriter.cs:98
void Write(Quaternion value)
Definition: MathWriter.cs:69
void Write(Vector4D value)
Definition: MathWriter.cs:62
A 2x2 matrix which can represent rotations for 2D vectors.
Definition: Matrix2x2.cs:58
A 3x3 matrix which can represent rotations around axes.
Definition: Matrix3x3.cs:62
Summary description for Quaternion.
Definition: Quaternion.cs:82
This is the Vector Class.
Definition: Vector2D.cs:50
Scalar X
This is the X value. (Usually represents a horizontal position or direction.)
Definition: Vector2D.cs:796
Scalar Y
This is the Y value. (Usually represents a vertical position or direction.)
Definition: Vector2D.cs:805
A Vector with 3 dimensions.
Definition: Vector3D.cs:47
Scalar X
This is the X value.
Definition: Vector3D.cs:692
Scalar Y
This is the Y value.
Definition: Vector3D.cs:701
Scalar Z
This is the Z value.
Definition: Vector3D.cs:710
A Vector with 4 dimensions.
Definition: Vector4D.cs:48
Scalar X
This is the X value.
Definition: Vector4D.cs:710
Scalar Y
This is the Y value.
Definition: Vector4D.cs:719
Scalar Z
This is the Z value.
Definition: Vector4D.cs:728
Scalar W
This is the W value.
Definition: Vector4D.cs:737