1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104 |
- /*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- using System;
- namespace PBJ
- {
- public class IMessage
- {
- public virtual Google.ProtocolBuffers.IMessage _PBJISuper { get { return null; } }
- protected virtual bool _HasAllPBJFields { get { return true; } }
- public void WriteTo(Google.ProtocolBuffers.CodedOutputStream output)
- {
- _PBJISuper.WriteTo(output);
- }
- public override bool Equals(object other)
- {
- return _PBJISuper.Equals(other);
- }
- public int SerializedSize { get { return _PBJISuper.SerializedSize; } }
- public override int GetHashCode() { return _PBJISuper.GetHashCode(); }
- public override string ToString()
- {
- return _PBJISuper.ToString();
- }
- public virtual IBuilder WeakCreateBuilderForType() { return null; }
- public Google.ProtocolBuffers.ByteString ToByteString()
- {
- return _PBJISuper.ToByteString();
- }
- public byte[] ToByteArray()
- {
- return _PBJISuper.ToByteArray();
- }
- public void WriteTo(global::System.IO.Stream output)
- {
- _PBJISuper.WriteTo(output);
- }
- // Google.ProtocolBuffers.MessageDescriptor DescriptorForType { get {return _PBJISuper.DescriptorForType;} }
- public Google.ProtocolBuffers.UnknownFieldSet UnknownFields { get { return _PBJISuper.UnknownFields; } }
- public class IBuilder
- {
- public virtual Google.ProtocolBuffers.IBuilder _PBJISuper { get { return null; } }
- protected virtual bool _HasAllPBJFields { get { return true; } }
- }
- }
- public struct Vector2f
- {
- public float x;
- public float y;
- public Vector2f(float _x, float _y)
- {
- x = _x; y = _y;
- }
- public Vector2f(Vector2f cpy)
- {
- x = cpy.x; y = cpy.y;
- }
- public Vector2f Negate()
- {
- return new Vector2f(-x, -y);
- }
- public Vector2f Add(Vector2f rhs)
- {
- return new Vector2f(x + rhs.x, y + rhs.y);
- }
- public Vector2f Subtract(Vector2f rhs)
- {
- return new Vector2f(x - rhs.x, y - rhs.y);
- }
- public Vector2f Multiply(Vector2f rhs)
- {
- return new Vector2f(x * rhs.x, y * rhs.y);
- }
- public Vector2f Multiply(float s)
- {
- return new Vector2f(x * s, y * s);
- }
- public Vector2f Divide(Vector2f rhs)
- {
- return new Vector2f(x / rhs.x, y / rhs.y);
- }
- public Vector2f Divide(float s)
- {
- return new Vector2f(x / s, y / s);
- }
- public float Dot(Vector2f rhs)
- {
- return (x * rhs.x + y * rhs.y);
- }
- public void Normalize()
- {
- float len = Length;
- if (len != 0.0)
- {
- x /= len; y /= len;
- }
- }
- public Vector2f Normalized
- {
- get
- {
- Vector2f normed = new Vector2f(this);
- normed.Normalize();
- return normed;
- }
- }
- public float SquaredLength
- {
- get
- {
- return (x * x + y * y);
- }
- }
- public float Length
- {
- get
- {
- return (float)Math.Sqrt(SquaredLength);
- }
- }
- public override string ToString()
- {
- return String.Format("<{0}, {1}>", x, y);
- }
- public static Vector2f operator -(Vector2f uo)
- {
- return uo.Negate();
- }
- public static Vector2f operator +(Vector2f lhs, Vector2f rhs)
- {
- return lhs.Add(rhs);
- }
- public static Vector2f operator -(Vector2f lhs, Vector2f rhs)
- {
- return lhs.Subtract(rhs);
- }
- public static Vector2f operator *(Vector2f lhs, Vector2f rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector2f operator *(Vector2f lhs, float rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector2f operator *(float lhs, Vector2f rhs)
- {
- return rhs.Multiply(lhs);
- }
- public static Vector2f operator /(Vector2f lhs, Vector2f rhs)
- {
- return lhs.Divide(rhs);
- }
- public static Vector2f operator /(Vector2f lhs, float rhs)
- {
- return lhs.Divide(rhs);
- }
- } // struct Vector2f
- public struct Vector2d
- {
- public double x;
- public double y;
- public Vector2d(double _x, double _y)
- {
- x = _x; y = _y;
- }
- public Vector2d(Vector2d cpy)
- {
- x = cpy.x; y = cpy.y;
- }
- public Vector2d Negate()
- {
- return new Vector2d(-x, -y);
- }
- public Vector2d Add(Vector2d rhs)
- {
- return new Vector2d(x + rhs.x, y + rhs.y);
- }
- public Vector2d Subtract(Vector2d rhs)
- {
- return new Vector2d(x - rhs.x, y - rhs.y);
- }
- public Vector2d Multiply(Vector2d rhs)
- {
- return new Vector2d(x * rhs.x, y * rhs.y);
- }
- public Vector2d Multiply(double s)
- {
- return new Vector2d(x * s, y * s);
- }
- public Vector2d Divide(Vector2d rhs)
- {
- return new Vector2d(x / rhs.x, y / rhs.y);
- }
- public Vector2d Divide(double s)
- {
- return new Vector2d(x / s, y / s);
- }
- public double Dot(Vector2d rhs)
- {
- return (x * rhs.x + y * rhs.y);
- }
- public void Normalize()
- {
- double len = Length;
- if (len != 0.0)
- {
- x /= len; y /= len;
- }
- }
- public Vector2d Normalized
- {
- get
- {
- Vector2d normed = new Vector2d(this);
- normed.Normalize();
- return normed;
- }
- }
- public double SquaredLength
- {
- get
- {
- return (x * x + y * y);
- }
- }
- public double Length
- {
- get
- {
- return Math.Sqrt(SquaredLength);
- }
- }
- public override string ToString()
- {
- return String.Format("<{0}, {1}>", x, y);
- }
- public static Vector2d operator -(Vector2d uo)
- {
- return uo.Negate();
- }
- public static Vector2d operator +(Vector2d lhs, Vector2d rhs)
- {
- return lhs.Add(rhs);
- }
- public static Vector2d operator -(Vector2d lhs, Vector2d rhs)
- {
- return lhs.Subtract(rhs);
- }
- public static Vector2d operator *(Vector2d lhs, Vector2d rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector2d operator *(Vector2d lhs, double rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector2d operator *(double lhs, Vector2d rhs)
- {
- return rhs.Multiply(lhs);
- }
- public static Vector2d operator /(Vector2d lhs, Vector2d rhs)
- {
- return lhs.Divide(rhs);
- }
- public static Vector2d operator /(Vector2d lhs, double rhs)
- {
- return lhs.Divide(rhs);
- }
- } // struct Vector2d
- public struct Vector3f
- {
- public float x;
- public float y;
- public float z;
- public Vector3f(float _x, float _y, float _z)
- {
- x = _x; y = _y; z = _z;
- }
- public Vector3f(Vector3f cpy)
- {
- x = cpy.x; y = cpy.y; z = cpy.z;
- }
- public Vector3f Negate()
- {
- return new Vector3f(-x, -y, -z);
- }
- public Vector3f Add(Vector3f rhs)
- {
- return new Vector3f(x + rhs.x, y + rhs.y, z + rhs.z);
- }
- public Vector3f Subtract(Vector3f rhs)
- {
- return new Vector3f(x - rhs.x, y - rhs.y, z - rhs.z);
- }
- public Vector3f Multiply(Vector3f rhs)
- {
- return new Vector3f(x * rhs.x, y * rhs.y, z * rhs.z);
- }
- public Vector3f Multiply(float s)
- {
- return new Vector3f(x * s, y * s, z * s);
- }
- public Vector3f Divide(Vector3f rhs)
- {
- return new Vector3f(x / rhs.x, y / rhs.y, z / rhs.z);
- }
- public Vector3f Divide(float s)
- {
- return new Vector3f(x / s, y / s, z / s);
- }
- public float Dot(Vector3f rhs)
- {
- return (x * rhs.x + y * rhs.y + z * rhs.z);
- }
- public Vector3f Cross(Vector3f rhs)
- {
- return new Vector3f(y * rhs.z - z * rhs.y, z * rhs.x - x * rhs.z, x * rhs.y - y * rhs.x);
- }
- public void Normalize()
- {
- float len = Length;
- if (len != 0.0)
- {
- x /= len; y /= len; z /= len;
- }
- }
- public Vector3f Normalized
- {
- get
- {
- Vector3f normed = new Vector3f(this);
- normed.Normalize();
- return normed;
- }
- }
- public float SquaredLength
- {
- get
- {
- return (x * x + y * y + z * z);
- }
- }
- public float Length
- {
- get
- {
- return (float)Math.Sqrt(SquaredLength);
- }
- }
- public override string ToString()
- {
- return String.Format("<{0}, {1}, {2}>", x, y, z);
- }
- public static Vector3f operator -(Vector3f uo)
- {
- return uo.Negate();
- }
- public static Vector3f operator +(Vector3f lhs, Vector3f rhs)
- {
- return lhs.Add(rhs);
- }
- public static Vector3f operator -(Vector3f lhs, Vector3f rhs)
- {
- return lhs.Subtract(rhs);
- }
- public static Vector3f operator *(Vector3f lhs, Vector3f rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector3f operator *(Vector3f lhs, float rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector3f operator *(float lhs, Vector3f rhs)
- {
- return rhs.Multiply(lhs);
- }
- public static Vector3f operator /(Vector3f lhs, Vector3f rhs)
- {
- return lhs.Divide(rhs);
- }
- public static Vector3f operator /(Vector3f lhs, float rhs)
- {
- return lhs.Divide(rhs);
- }
- } // struct Vector3f
- public struct Vector3d
- {
- public double x;
- public double y;
- public double z;
- public Vector3d(double _x, double _y, double _z)
- {
- x = _x; y = _y; z = _z;
- }
- public Vector3d(Vector3d cpy)
- {
- x = cpy.x; y = cpy.y; z = cpy.z;
- }
- public Vector3d Negate()
- {
- return new Vector3d(-x, -y, -z);
- }
- public Vector3d Add(Vector3d rhs)
- {
- return new Vector3d(x + rhs.x, y + rhs.y, z + rhs.z);
- }
- public Vector3d Subtract(Vector3d rhs)
- {
- return new Vector3d(x - rhs.x, y - rhs.y, z - rhs.z);
- }
- public Vector3d Multiply(Vector3d rhs)
- {
- return new Vector3d(x * rhs.x, y * rhs.y, z * rhs.z);
- }
- public Vector3d Multiply(double s)
- {
- return new Vector3d(x * s, y * s, z * s);
- }
- public Vector3d Divide(Vector3d rhs)
- {
- return new Vector3d(x / rhs.x, y / rhs.y, z / rhs.z);
- }
- public Vector3d Divide(double s)
- {
- return new Vector3d(x / s, y / s, z / s);
- }
- public double Dot(Vector3d rhs)
- {
- return (x * rhs.x + y * rhs.y + z * rhs.z);
- }
- public Vector3d Cross(Vector3d rhs)
- {
- return new Vector3d(y * rhs.z - z * rhs.y, z * rhs.x - x * rhs.z, x * rhs.y - y * rhs.x);
- }
- public void Normalize()
- {
- double len = Length;
- if (len != 0.0)
- {
- x /= len; y /= len; z /= len;
- }
- }
- public Vector3d Normalized
- {
- get
- {
- Vector3d normed = new Vector3d(this);
- normed.Normalize();
- return normed;
- }
- }
- public double SquaredLength
- {
- get
- {
- return (x * x + y * y + z * z);
- }
- }
- public double Length
- {
- get
- {
- return Math.Sqrt(SquaredLength);
- }
- }
- public override string ToString()
- {
- return String.Format("<{0}, {1}, {2}>", x, y, z);
- }
- public static Vector3d operator -(Vector3d uo)
- {
- return uo.Negate();
- }
- public static Vector3d operator +(Vector3d lhs, Vector3d rhs)
- {
- return lhs.Add(rhs);
- }
- public static Vector3d operator -(Vector3d lhs, Vector3d rhs)
- {
- return lhs.Subtract(rhs);
- }
- public static Vector3d operator *(Vector3d lhs, Vector3d rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector3d operator *(Vector3d lhs, double rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector3d operator *(double lhs, Vector3d rhs)
- {
- return rhs.Multiply(lhs);
- }
- public static Vector3d operator /(Vector3d lhs, Vector3d rhs)
- {
- return lhs.Divide(rhs);
- }
- public static Vector3d operator /(Vector3d lhs, double rhs)
- {
- return lhs.Divide(rhs);
- }
- } // struct Vector3d
- public struct Quaternion
- {
- public float w;
- public float x;
- public float y;
- public float z;
- public Quaternion(float _w, float _x, float _y, float _z)
- {
- w = _w; x = _x; y = _y; z = _z;
- }
- public Quaternion(Quaternion cpy)
- {
- w = cpy.w; x = cpy.x; y = cpy.y; z = cpy.z;
- }
- public static readonly Quaternion Identity = new Quaternion((float)1.0, (float)0.0, (float)0.0, (float)0.0);
- public static Quaternion FromAxisAngle(Vector3f axis, float rads)
- {
- float halfAngle = rads * 0.5f;
- float sinHalf = (float)Math.Sin(halfAngle);
- float w = (float)Math.Cos(halfAngle);
- float x = sinHalf * axis.x;
- float y = sinHalf * axis.y;
- float z = sinHalf * axis.z;
- return new Quaternion(w, x, y, z);
- }
- public static Quaternion FromAxisAngle(Vector3d axis, float rads)
- {
- float halfAngle = rads * 0.5f;
- float sinHalf = (float)Math.Sin(halfAngle);
- float w = (float)Math.Cos(halfAngle);
- float x = (float)(sinHalf * axis.x);
- float y = (float)(sinHalf * axis.y);
- float z = (float)(sinHalf * axis.z);
- return new Quaternion(w, x, y, z);
- }
- public Quaternion Add(Quaternion rhs)
- {
- return new Quaternion(w + rhs.w, x + rhs.x, y + rhs.y, z + rhs.z);
- }
- public Quaternion Subtract(Quaternion rhs)
- {
- return new Quaternion(w - rhs.w, x - rhs.x, y - rhs.y, z - rhs.z);
- }
- public Quaternion Multiply(Quaternion rhs)
- {
- return new Quaternion(
- w * rhs.w - x * rhs.x - y * rhs.y - z * rhs.z,
- w * rhs.x + x * rhs.w + y * rhs.z - z * rhs.y,
- w * rhs.y + y * rhs.w + z * rhs.x - x * rhs.z,
- w * rhs.z + z * rhs.w + x * rhs.y - y * rhs.x
- );
- }
- public Vector3f Multiply(Vector3f rhs)
- {
- Vector3f qvec = new Vector3f(x, y, z);
- Vector3f uv = qvec.Cross(rhs);
- Vector3f uuv = qvec.Cross(uv);
- uv *= 2.0f * w;
- uuv *= 2.0f;
- return rhs + uv + uuv;
- }
- public Vector3d Multiply(Vector3d rhs)
- {
- Vector3d qvec = new Vector3d(x, y, z);
- Vector3d uv = qvec.Cross(rhs);
- Vector3d uuv = qvec.Cross(uv);
- uv *= 2.0f * w;
- uuv *= 2.0f;
- return rhs + uv + uuv;
- }
- public Quaternion Multiply(float rhs)
- {
- return new Quaternion(w * rhs, x * rhs, y * rhs, z * rhs);
- }
- public Quaternion Negate()
- {
- return new Quaternion(-w, -x, -y, -z);
- }
- public float Dot(Quaternion rhs)
- {
- return (w * rhs.w + x * rhs.x + y * rhs.y + z * rhs.z);
- }
- public float Norm
- {
- get
- {
- return (float)Math.Sqrt(w * w + x * x + y * y + z * z);
- }
- }
- public float SquareNorm
- {
- get
- {
- return (w * w + x * x + y * y + z * z);
- }
- }
- public void Normalize()
- {
- float len = SquareNorm;
- if (len == 0.0) return;
- float factor = 1.0f / (float)Math.Sqrt(len);
- this *= factor;
- }
- public Quaternion Normalized
- {
- get
- {
- Quaternion q = new Quaternion(this);
- q.Normalize();
- return q;
- }
- }
- public Quaternion Inverse
- {
- get
- {
- float norm = SquareNorm;
- if (norm > 0.0)
- {
- double invnorm = 1.0 / norm;
- return new Quaternion((float)(w * invnorm), (float)(-x * invnorm), (float)(-y * invnorm), (float)(-z * invnorm));
- }
- else
- return new Quaternion((float)0.0, 0.0f, 0.0f, 0.0f);
- }
- }
- public override string ToString()
- {
- return String.Format("<{0}, {1}, {2}, {3}>", w, x, y, z);
- }
- public static Quaternion operator -(Quaternion uo)
- {
- return uo.Negate();
- }
- public static Quaternion operator +(Quaternion lhs, Quaternion rhs)
- {
- return lhs.Add(rhs);
- }
- public static Quaternion operator -(Quaternion lhs, Quaternion rhs)
- {
- return lhs.Subtract(rhs);
- }
- public static Vector3f operator *(Quaternion lhs, Vector3f rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector3d operator *(Quaternion lhs, Vector3d rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Quaternion operator *(Quaternion lhs, Quaternion rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Quaternion operator *(Quaternion lhs, float rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Quaternion operator *(float lhs, Quaternion rhs)
- {
- return rhs.Multiply(lhs);
- }
- } // struct Quaternion
- public struct Vector4f
- {
- public float x;
- public float y;
- public float z;
- public float w;
- public Vector4f(float _x, float _y, float _z, float _w)
- {
- x = _x; y = _y; z = _z; w = _w;
- }
- public Vector4f(Vector4f cpy)
- {
- x = cpy.x; y = cpy.y; z = cpy.z; w = cpy.w;
- }
- public Vector4f Negate()
- {
- return new Vector4f(-x, -y, -z, -w);
- }
- public Vector4f Add(Vector4f rhs)
- {
- return new Vector4f(x + rhs.x, y + rhs.y, z + rhs.z, w + rhs.w);
- }
- public Vector4f Subtract(Vector4f rhs)
- {
- return new Vector4f(x - rhs.x, y - rhs.y, z - rhs.z, w - rhs.w);
- }
- public Vector4f Multiply(Vector4f rhs)
- {
- return new Vector4f(x * rhs.x, y * rhs.y, z * rhs.z, w * rhs.w);
- }
- public Vector4f Multiply(float s)
- {
- return new Vector4f(x * s, y * s, z * s, w * s);
- }
- public Vector4f Divide(Vector4f rhs)
- {
- return new Vector4f(x / rhs.x, y / rhs.y, z / rhs.z, w / rhs.w);
- }
- public Vector4f Divide(float s)
- {
- return new Vector4f(x / s, y / s, z / s, w / s);
- }
- public float Dot(Vector4f rhs)
- {
- return (x * rhs.x + y * rhs.y + z * rhs.z + w * rhs.w);
- }
- public void Normalize()
- {
- float len = Length;
- if (len != 0.0)
- {
- x /= len; y /= len; z /= len; w /= len;
- }
- }
- public Vector4f Normalized
- {
- get
- {
- Vector4f normed = new Vector4f(this);
- normed.Normalize();
- return normed;
- }
- }
- public float SquaredLength
- {
- get
- {
- return (x * x + y * y + z * z + w * w);
- }
- }
- public float Length
- {
- get
- {
- return (float)Math.Sqrt(SquaredLength);
- }
- }
- public override string ToString()
- {
- return String.Format("<{0}, {1}, {2}, {3}>", x, y, z, w);
- }
- public static Vector4f operator -(Vector4f uo)
- {
- return uo.Negate();
- }
- public static Vector4f operator +(Vector4f lhs, Vector4f rhs)
- {
- return lhs.Add(rhs);
- }
- public static Vector4f operator -(Vector4f lhs, Vector4f rhs)
- {
- return lhs.Subtract(rhs);
- }
- public static Vector4f operator *(Vector4f lhs, Vector4f rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector4f operator *(Vector4f lhs, float rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector4f operator *(float lhs, Vector4f rhs)
- {
- return rhs.Multiply(lhs);
- }
- public static Vector4f operator /(Vector4f lhs, Vector4f rhs)
- {
- return lhs.Divide(rhs);
- }
- public static Vector4f operator /(Vector4f lhs, float rhs)
- {
- return lhs.Divide(rhs);
- }
- } // struct Vector4f
- public struct Vector4d
- {
- public double x;
- public double y;
- public double z;
- public double w;
- public Vector4d(double _x, double _y, double _z, double _w)
- {
- x = _x; y = _y; z = _z; w = _w;
- }
- public Vector4d(Vector4d cpy)
- {
- x = cpy.x; y = cpy.y; z = cpy.z; w = cpy.w;
- }
- public Vector4d Negate()
- {
- return new Vector4d(-x, -y, -z, -w);
- }
- public Vector4d Add(Vector4d rhs)
- {
- return new Vector4d(x + rhs.x, y + rhs.y, z + rhs.z, w + rhs.w);
- }
- public Vector4d Subtract(Vector4d rhs)
- {
- return new Vector4d(x - rhs.x, y - rhs.y, z - rhs.z, w - rhs.w);
- }
- public Vector4d Multiply(Vector4d rhs)
- {
- return new Vector4d(x * rhs.x, y * rhs.y, z * rhs.z, w * rhs.w);
- }
- public Vector4d Multiply(double s)
- {
- return new Vector4d(x * s, y * s, z * s, w * s);
- }
- public Vector4d Divide(Vector4d rhs)
- {
- return new Vector4d(x / rhs.x, y / rhs.y, z / rhs.z, w / rhs.w);
- }
- public Vector4d Divide(double s)
- {
- return new Vector4d(x / s, y / s, z / s, w / s);
- }
- public double Dot(Vector4d rhs)
- {
- return (x * rhs.x + y * rhs.y + z * rhs.z + w * rhs.w);
- }
- public void Normalize()
- {
- double len = Length;
- if (len != 0.0)
- {
- x /= len; y /= len; z /= len; w /= len;
- }
- }
- public Vector4d Normalized
- {
- get
- {
- Vector4d normed = new Vector4d(this);
- normed.Normalize();
- return normed;
- }
- }
- public double SquaredLength
- {
- get
- {
- return (x * x + y * y + z * z + w * w);
- }
- }
- public double Length
- {
- get
- {
- return Math.Sqrt(SquaredLength);
- }
- }
- public override string ToString()
- {
- return String.Format("<{0}, {1}, {2}, {3}>", x, y, z, w);
- }
- public static Vector4d operator -(Vector4d uo)
- {
- return uo.Negate();
- }
- public static Vector4d operator +(Vector4d lhs, Vector4d rhs)
- {
- return lhs.Add(rhs);
- }
- public static Vector4d operator -(Vector4d lhs, Vector4d rhs)
- {
- return lhs.Subtract(rhs);
- }
- public static Vector4d operator *(Vector4d lhs, Vector4d rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector4d operator *(Vector4d lhs, double rhs)
- {
- return lhs.Multiply(rhs);
- }
- public static Vector4d operator *(double lhs, Vector4d rhs)
- {
- return rhs.Multiply(lhs);
- }
- public static Vector4d operator /(Vector4d lhs, Vector4d rhs)
- {
- return lhs.Divide(rhs);
- }
- public static Vector4d operator /(Vector4d lhs, double rhs)
- {
- return lhs.Divide(rhs);
- }
- } // struct Vector4d
- public struct BoundingBox3f3f
- {
- Vector3f mMin;
- Vector3f mDiag;
- public BoundingBox3f3f(float minx, float miny, float minz, float diagx, float diagy, float diagz)
- {
- mMin.x = minx;
- mMin.y = miny;
- mMin.z = minz;
- mDiag.x = diagx;
- mDiag.y = diagy;
- mDiag.z = diagz;
- }
- public BoundingBox3f3f(Vector3f min, Vector3f max)
- {
- mMin = min;
- mDiag = (max - min);
- }
- public BoundingBox3f3f(BoundingBox3f3f cpy, Vector3f scale)
- {
- mMin.x = (float)(cpy.mMin.x * scale.x);
- mMin.y = (float)(cpy.mMin.y * scale.y);
- mMin.z = (float)(cpy.mMin.z * scale.z);
- mDiag.x = (float)(cpy.mDiag.x * scale.x);
- mDiag.y = (float)(cpy.mDiag.y * scale.y);
- mDiag.z = (float)(cpy.mDiag.z * scale.z);
- }
- public Vector3f Min
- {
- get
- {
- return new Vector3f(mMin.x, mMin.y, mMin.z);
- }
- }
- public Vector3f Max
- {
- get
- {
- return new Vector3f(mMin.x + mDiag.x, mMin.y + mDiag.y, mMin.z + mDiag.z);
- }
- }
- public Vector3f Diag
- {
- get
- {
- return new Vector3f(mDiag.x, mDiag.y, mDiag.z);
- }
- }
- public override string ToString()
- {
- return "[" + this.Min.ToString() + " - " + this.Max.ToString() + "]";
- }
- public BoundingBox3f3f Merge(BoundingBox3f3f other)
- {
- Vector3f thisMax = Max;
- Vector3f otherMax = other.Max;
- bool xless = other.mMin.x > mMin.x;
- bool yless = other.mMin.y > mMin.y;
- bool zless = other.mMin.z > mMin.z;
- bool xmore = otherMax.x < thisMax.x;
- bool ymore = otherMax.y < thisMax.y;
- bool zmore = otherMax.z < thisMax.z;
- return new BoundingBox3f3f(xless ? mMin.x : other.mMin.x,
- yless ? mMin.y : other.mMin.y,
- zless ? mMin.z : other.mMin.z,
- xmore ? (xless ? mDiag.x : otherMax.x - mMin.x) : (xless ? thisMax.x - other.mMin.x : other.mDiag.x),
- ymore ? (yless ? mDiag.y : otherMax.y - mMin.y) : (yless ? thisMax.y - other.mMin.y : other.mDiag.y),
- zmore ? (zless ? mDiag.z : otherMax.z - mMin.z) : (zless ? thisMax.z - other.mMin.z : other.mDiag.z));
- }
- } // struct BoundingBox
- public struct BoundingBox3d3f
- {
- Vector3d mMin;
- Vector3f mDiag;
- public BoundingBox3d3f(double minx, double miny, double minz, float diagx, float diagy, float diagz)
- {
- mMin.x = minx;
- mMin.y = miny;
- mMin.z = minz;
- mDiag.x = diagx;
- mDiag.y = diagy;
- mDiag.z = diagz;
- }
- public BoundingBox3d3f(Vector3d min, Vector3f max)
- {
- mMin = min;
- mDiag = new Vector3f((float)(max.x - min.x),
- (float)(max.y - min.y),
- (float)(max.z - min.z));
- }
- public BoundingBox3d3f(BoundingBox3d3f cpy, Vector3d scale)
- {
- mMin.x = (double)(cpy.mMin.x * scale.x);
- mMin.y = (double)(cpy.mMin.y * scale.y);
- mMin.z = (double)(cpy.mMin.z * scale.z);
- mDiag.x = (float)(cpy.mDiag.x * scale.x);
- mDiag.y = (float)(cpy.mDiag.y * scale.y);
- mDiag.z = (float)(cpy.mDiag.z * scale.z);
- }
- public Vector3d Min
- {
- get
- {
- return new Vector3d(mMin.x, mMin.y, mMin.z);
- }
- }
- public Vector3d Max
- {
- get
- {
- return new Vector3d(mMin.x + mDiag.x, mMin.y + mDiag.y, mMin.z + mDiag.z);
- }
- }
- public Vector3d Diag
- {
- get
- {
- return new Vector3d(mDiag.x, mDiag.y, mDiag.z);
- }
- }
- public override string ToString()
- {
- return "[" + this.Min.ToString() + " - " + this.Max.ToString() + "]";
- }
- public BoundingBox3d3f Merge(BoundingBox3d3f other)
- {
- Vector3d thisMax = Max;
- Vector3d otherMax = other.Max;
- bool xless = other.mMin.x > mMin.x;
- bool yless = other.mMin.y > mMin.y;
- bool zless = other.mMin.z > mMin.z;
- bool xmore = otherMax.x < thisMax.x;
- bool ymore = otherMax.y < thisMax.y;
- bool zmore = otherMax.z < thisMax.z;
- return new BoundingBox3d3f(xless ? mMin.x : other.mMin.x,
- yless ? mMin.y : other.mMin.y,
- zless ? mMin.z : other.mMin.z,
- (float)(xmore ? (xless ? mDiag.x : otherMax.x - mMin.x) : (xless ? thisMax.x - other.mMin.x : other.mDiag.x)),
- (float)(ymore ? (yless ? mDiag.y : otherMax.y - mMin.y) : (yless ? thisMax.y - other.mMin.y : other.mDiag.y)),
- (float)(zmore ? (zless ? mDiag.z : otherMax.z - mMin.z) : (zless ? thisMax.z - other.mMin.z : other.mDiag.z)));
- }
- } // struct BoundingBox
- public struct BoundingSphere3f
- {
- Vector3f mCenter;
- float mRadius;
- public BoundingSphere3f(float x, float y, float z, float r)
- {
- mCenter = new Vector3f(x, y, z);
- mRadius = r;
- }
- public BoundingSphere3f(Vector3f center, float radius)
- {
- mCenter = center;
- mRadius = radius;
- }
- public BoundingSphere3f(BoundingSphere3f cpy, float scale)
- {
- mCenter = cpy.mCenter;
- mRadius = cpy.mRadius * scale;
- }
- public Vector3f Center
- {
- get
- {
- return new Vector3f(mCenter.x, mCenter.y, mCenter.z);
- }
- }
- public float Radius
- {
- get
- {
- return mRadius;
- }
- }
- public override string ToString()
- {
- return "[" + this.Center.ToString() + " : " + this.Radius.ToString() + "]";
- }
- } // struct BoundingSphere3f
- public struct BoundingSphere3d
- {
- Vector3d mCenter;
- float mRadius;
- public BoundingSphere3d(double x, double y, double z, float r)
- {
- mCenter.x = x;
- mCenter.y = y;
- mCenter.z = z;
- mRadius = r;
- }
- public BoundingSphere3d(Vector3d center, float radius)
- {
- mCenter = center;
- mRadius = radius;
- }
- public BoundingSphere3d(BoundingSphere3d cpy, float scale)
- {
- mCenter = cpy.mCenter;
- mRadius = cpy.mRadius * scale;
- }
- public Vector3d Center
- {
- get
- {
- return new Vector3d(mCenter.x, mCenter.y, mCenter.z);
- }
- }
- public float Radius
- {
- get
- {
- return mRadius;
- }
- }
- public override string ToString()
- {
- return "[" + this.Center.ToString() + " : " + this.Radius.ToString() + "]";
- }
- } // struct BoundingSphere3f
- public struct UUID
- {
- ulong mLowOrderBytes;
- ulong mHighOrderBytes;
- static ulong SetUUIDlow(Google.ProtocolBuffers.ByteString data, int offset)
- {
- ulong LowOrderBytes = 0;
- int shiftVal = 0;
- for (int i = 0; i < 8; ++i)
- {
- ulong temp = data[i];
- LowOrderBytes |= (temp << shiftVal);
- shiftVal += 8;
- }
- return LowOrderBytes;
- }
- static ulong SetUUIDhigh(Google.ProtocolBuffers.ByteString data)
- {
- return SetUUIDlow(data, 8);
- }
- static ulong SetUUIDlow(byte[] data, int offset)
- {
- ulong LowOrderBytes = 0;
- int shiftVal = 0;
- for (int i = 0; i < 8; ++i)
- {
- ulong temp = data[i];
- LowOrderBytes |= (temp << shiftVal);
- shiftVal += 8;
- }
- return LowOrderBytes;
- }
- static ulong SetUUIDhigh(byte[] data)
- {
- return SetUUIDlow(data, 8);
- }
- public bool SetUUID(byte[] data)
- {
- if (data.Length == 16)
- {
- mLowOrderBytes = 0;
- mHighOrderBytes = 0;
- mLowOrderBytes = SetUUIDlow(data, 0);
- mHighOrderBytes = SetUUIDlow(data, 8);
- return true;
- }
- else
- {
- return false;
- }
- }
- public byte[] GetUUID()
- {
- byte[] data = new byte[16];
- int shiftVal = 0;
- for (int i = 0; i < 8; ++i)
- {
- ulong temp = 0xff;
- temp = (mLowOrderBytes & (temp << shiftVal));
- temp = (temp >> shiftVal);
- data[i] = (byte)temp;
- shiftVal += 8;
- }
- shiftVal = 0;
- for (int i = 8; i < 16; ++i)
- {
- ulong temp = 0xff;
- temp = (mHighOrderBytes & (temp << shiftVal));
- temp = (temp >> shiftVal);
- data[i] = (byte)temp;
- shiftVal += 8;
- }
- return data;
- }
- public static UUID Empty = new UUID(new byte[16]);
- public UUID(byte[] data)
- {
- if (data.Length != 16)
- {
- throw new System.ArgumentException("UUIDs must be provided 16 bytes");
- }
- mLowOrderBytes = SetUUIDlow(data, 0);
- mHighOrderBytes = SetUUIDhigh(data);
- }
- public UUID(Google.ProtocolBuffers.ByteString data)
- {
- if (data.Length != 16)
- {
- throw new System.ArgumentException("UUIDs must be provided 16 bytes");
- }
- mLowOrderBytes = SetUUIDlow(data, 0);
- mHighOrderBytes = SetUUIDhigh(data);
- }
- }
- public struct SHA256
- {
- ulong mLowOrderBytes;
- ulong mLowMediumOrderBytes;
- ulong mMediumHighOrderBytes;
- ulong mHighOrderBytes;
- static ulong SetLMH(Google.ProtocolBuffers.ByteString data, int offset)
- {
- ulong LowOrderBytes = 0;
- int shiftVal = 0;
- for (int i = 0; i < 8; ++i)
- {
- ulong temp = data[i];
- LowOrderBytes |= (temp << shiftVal);
- shiftVal += 8;
- }
- return LowOrderBytes;
- }
- static ulong SetLow(Google.ProtocolBuffers.ByteString data)
- {
- return SetLMH(data, 0);
- }
- static ulong SetLowMedium(Google.ProtocolBuffers.ByteString data)
- {
- return SetLMH(data, 8);
- }
- static ulong SetMediumHigh(Google.ProtocolBuffers.ByteString data)
- {
- return SetLMH(data, 16);
- }
- static ulong SetHigh(Google.ProtocolBuffers.ByteString data)
- {
- return SetLMH(data, 24);
- }
- static ulong SetLMH(byte[] data, int offset)
- {
- ulong LowOrderBytes = 0;
- int shiftVal = 0;
- for (int i = 0; i < 8; ++i)
- {
- ulong temp = data[i];
- LowOrderBytes |= (temp << shiftVal);
- shiftVal += 8;
- }
- return LowOrderBytes;
- }
- static ulong SetLow(byte[] data)
- {
- return SetLMH(data, 0);
- }
- static ulong SetLowMedium(byte[] data)
- {
- return SetLMH(data, 8);
- }
- static ulong SetMediumHigh(byte[] data)
- {
- return SetLMH(data, 16);
- }
- static ulong SetHigh(byte[] data)
- {
- return SetLMH(data, 24);
- }
- public bool SetSHA256(byte[] data)
- {
- if (data.Length == 32)
- {
- mLowOrderBytes = SetLow(data);
- mLowMediumOrderBytes = SetLowMedium(data);
- mMediumHighOrderBytes = SetMediumHigh(data);
- mHighOrderBytes = SetHigh(data);
- return true;
- }
- else
- {
- return false;
- }
- }
- public byte[] GetBinaryData()
- {
- byte[] data = new byte[32];
- int shiftVal = 0;
- for (int i = 0; i < 8; ++i)
- {
- ulong temp = 0xff;
- temp = (mLowOrderBytes & (temp << shiftVal));
- temp = (temp >> shiftVal);
- data[i] = (byte)temp;
- shiftVal += 8;
- }
- shiftVal = 0;
- for (int i = 8; i < 16; ++i)
- {
- ulong temp = 0xff;
- temp = (mLowMediumOrderBytes & (temp << shiftVal));
- temp = (temp >> shiftVal);
- data[i] = (byte)temp;
- shiftVal += 8;
- }
- shiftVal = 0;
- for (int i = 16; i < 24; ++i)
- {
- ulong temp = 0xff;
- temp = (mMediumHighOrderBytes & (temp << shiftVal));
- temp = (temp >> shiftVal);
- data[i] = (byte)temp;
- shiftVal += 8;
- }
- shiftVal = 0;
- for (int i = 24; i < 32; ++i)
- {
- ulong temp = 0xff;
- temp = (mHighOrderBytes & (temp << shiftVal));
- temp = (temp >> shiftVal);
- data[i] = (byte)temp;
- shiftVal += 8;
- }
- return data;
- }
- public static SHA256 Empty = new SHA256(new byte[32]);
- public SHA256(byte[] data)
- {
- if (data.Length != 32)
- {
- throw new System.ArgumentException("SHA256s must be provided 32 bytes");
- }
- mLowOrderBytes = SetLow(data);
- mLowMediumOrderBytes = SetLowMedium(data);
- mMediumHighOrderBytes = SetMediumHigh(data);
- mHighOrderBytes = SetHigh(data);
- }
- public SHA256(Google.ProtocolBuffers.ByteString data)
- {
- if (data.Length != 32)
- {
- throw new System.ArgumentException("SHA256s must be provided 32 bytes");
- }
- mLowOrderBytes = SetLow(data);
- mLowMediumOrderBytes = SetLowMedium(data);
- mMediumHighOrderBytes = SetMediumHigh(data);
- mHighOrderBytes = SetHigh(data);
- }
- }
- public struct Time
- {
- ulong usec;
- public Time(ulong usec_since_epoch)
- {
- usec = usec_since_epoch;
- }
- public ulong toMicro()
- {
- return usec;
- }
- }
- public class Duration
- {
- long usec;
- public Duration(long time_since)
- {
- usec = time_since;
- }
- public long toMicro()
- {
- return usec;
- }
- }
- class _PBJ
- {
- public static bool ValidateBool(bool d)
- {
- return true;
- }
- public static bool ValidateDouble(double d)
- {
- return true;
- }
- public static bool ValidateFloat(float d)
- {
- return true;
- }
- public static bool ValidateUint64(ulong d)
- {
- return true;
- }
- public static bool ValidateUint32(uint d)
- {
- return true;
- }
- public static bool ValidateUint16(ushort d)
- {
- return true;
- }
- public static bool ValidateUint8(byte d)
- {
- return true;
- }
- public static bool ValidateInt64(long d)
- {
- return true;
- }
- public static bool ValidateInt32(int d)
- {
- return true;
- }
- public static bool ValidateInt16(short d)
- {
- return true;
- }
- public static bool ValidateInt8(sbyte d)
- {
- return true;
- }
- public static bool ValidateString<S>(S input)
- {
- return true;
- }
- public static bool ValidateBytes<B>(B input)
- {
- return true;
- }
- public static bool ValidateUuid(Google.ProtocolBuffers.ByteString input)
- {
- return input.Length == 16;
- }
- public static bool ValidateSha256(Google.ProtocolBuffers.ByteString input)
- {
- return input.Length == 32;
- }
- public static bool ValidateAngle(float input)
- {
- return input >= 0 && input <= 3.1415926536 * 2.0;
- }
- public static bool ValidateTime(ulong input)
- {
- return true;
- }
- public static bool ValidateDuration(long input)
- {
- return true;
- }
- public static bool ValidateFlags(ulong input, ulong verification)
- {
- return (input & verification) == input;
- }
- public static bool CastBool(bool d)
- {
- return d;
- }
- public static double CastDouble(double d)
- {
- return d;
- }
- public static float CastFloat(float d)
- {
- return d;
- }
- public static ulong CastUint64(ulong d)
- {
- return d;
- }
- public static uint CastUint32(uint d)
- {
- return d;
- }
- public static ushort CastUint16(ushort d)
- {
- return d;
- }
- public static byte CastUint8(byte d)
- {
- return d;
- }
- public static long CastInt64(long d)
- {
- return d;
- }
- public static int CastInt32(int d)
- {
- return d;
- }
- public static short CastInt16(short d)
- {
- return d;
- }
- public static sbyte CastInt8(sbyte d)
- {
- return d;
- }
- public static S CastString<S>(S input)
- {
- return input;
- }
- public static B CastBytes<B>(B input)
- {
- return input;
- }
- public static bool CastBool()
- {
- return false;
- }
- public static double CastDouble()
- {
- return 0;
- }
- public static float CastFloat()
- {
- return 0;
- }
- public static ulong CastUint64()
- {
- return 0;
- }
- public static uint CastUint32()
- {
- return 0;
- }
- public static ushort CastUint16()
- {
- return 0;
- }
- public static byte CastUint8()
- {
- return 0;
- }
- public static long CastInt64()
- {
- return 0;
- }
- public static int CastInt32()
- {
- return 0;
- }
- public static short CastInt16()
- {
- return 0;
- }
- public static sbyte CastInt8()
- {
- return 0;
- }
- public static string CastString()
- {
- return "";
- }
- public static Google.ProtocolBuffers.ByteString CastBytes()
- {
- return Google.ProtocolBuffers.ByteString.Empty;
- }
- public static ulong CastFlags(ulong data, ulong allFlagsOn)
- {
- return allFlagsOn & data;
- }
- public static ulong CastFlags(ulong allFlagsOn)
- {
- return 0;
- }
- public static Vector3f CastNormal(float x, float y)
- {
- float neg = (x > 1.5f || y > 1.5f) ? -1.0f : 1.0f;
- if (x > 1.5)
- x -= 3;
- if (y > 1.5)
- y -= 3;
- return new Vector3f(x, y, neg - neg * (float)Math.Sqrt(x * x + y * y));
- }
- public static Vector3f CastNormal()
- {
- return new Vector3f(0, 1, 0);
- }
- public static Vector2f CastVector2f(float x, float y)
- {
- return new Vector2f(x, y);
- }
- public static Vector2f CastVector2f()
- {
- return new Vector2f(0, 0);
- }
- public static Vector3f CastVector3f(float x, float y, float z)
- {
- return new Vector3f(x, y, z);
- }
- public static Vector3f CastVector3f()
- {
- return new Vector3f(0, 0, 0);
- }
- public static Vector4f CastVector4f(float x, float y, float z, float w)
- {
- return new Vector4f(x, y, z, w);
- }
- public static Vector4f CastVector4f()
- {
- return new Vector4f(0, 0, 0, 0);
- }
- public static Vector2d CastVector2d(double x, double y)
- {
- return new Vector2d(x, y);
- }
- public static Vector2d CastVector2d()
- {
- return new Vector2d(0, 0);
- }
- public static Vector3d CastVector3d(double x, double y, double z)
- {
- return new Vector3d(x, y, z);
- }
- public static Vector3d CastVector3d()
- {
- return new Vector3d(0, 0, 0);
- }
- public static Vector4d CastVector4d(double x, double y, double z, double w)
- {
- return new Vector4d(x, y, z, w);
- }
- public static Vector4d CastVector4d()
- {
- return new Vector4d(0, 0, 0, 0);
- }
- public static BoundingSphere3f CastBoundingsphere3f(float x, float y, float z, float r)
- {
- return new BoundingSphere3f(new Vector3f(x, y, z), r);
- }
- public static BoundingSphere3d CastBoundingsphere3d(double x, double y, double z, double r)
- {
- return new BoundingSphere3d(new Vector3d(x, y, z), (float)r);
- }
- public static BoundingSphere3f CastBoundingsphere3f()
- {
- return new BoundingSphere3f(new Vector3f(0, 0, 0), 0);
- }
- public static BoundingSphere3d CastBoundingsphere3d()
- {
- return new BoundingSphere3d(new Vector3d(0, 0, 0), (float)0);
- }
- public static BoundingBox3f3f CastBoundingbox3f3f(float x, float y, float z, float dx, float dy, float dz)
- {
- return new BoundingBox3f3f(x, y, z, dx, dy, dz);
- }
- public static BoundingBox3d3f CastBoundingbox3d3f(double x, double y, double z, double dx, double dy, double dz)
- {
- return new BoundingBox3d3f(x, y, z, (float)dx, (float)dy, (float)dz);
- }
- public static BoundingBox3f3f CastBoundingbox3f3f()
- {
- return new BoundingBox3f3f(new Vector3f(0, 0, 0), new Vector3f(0, 0, 0));
- }
- public static BoundingBox3d3f CastBoundingbox3d3f()
- {
- return new BoundingBox3d3f(0, 0, 0, 0, 0, 0);
- }
- public static Quaternion CastQuaternion(float x, float y, float z)
- {
- float neg = (x > 1.5 || y > 1.5 || z > 1.5) ? -1.0f : 1.0f;
- if (x > 1.5)
- x -= 3.0f;
- if (y > 1.5)
- y -= 3.0f;
- if (z > 1.5)
- z -= 3.0f;
- return new Quaternion(neg - neg * (float)Math.Sqrt(x * x + y * y + z * z), x, y, z);
- }
- public static Quaternion CastQuaternion()
- {
- return new Quaternion(1, 0, 0, 0);
- }
- public static UUID CastUuid(Google.ProtocolBuffers.ByteString input)
- {
- return new UUID(input);
- }
- public static SHA256 CastSha256(Google.ProtocolBuffers.ByteString input)
- {
- return new SHA256(input);
- }
- public static SHA256 CastSha256()
- {
- return SHA256.Empty;
- }
- public static UUID CastUuid()
- {
- return UUID.Empty;
- }
- public static float CastAngle(float d)
- {
- return d;
- }
- public static float CastAngle()
- {
- return 0;
- }
- public static Time CastTime(ulong t)
- {
- return new Time(t);
- }
- public static Time CastTime()
- {
- return new Time(0);
- }
- public static Duration CastDuration(long t)
- {
- return new Duration(t);
- }
- public static Duration CastDuration()
- {
- return new Duration(0);
- }
- public static T Construct<T>(T retval)
- {
- return retval;
- }
- public static long Construct(Duration d)
- {
- return d.toMicro();
- }
- public static ulong Construct(Time t)
- {
- return t.toMicro();
- }
- public static Google.ProtocolBuffers.ByteString Construct(UUID u)
- {
- byte[] data = u.GetUUID();
- Google.ProtocolBuffers.ByteString retval = Google.ProtocolBuffers.ByteString.CopyFrom(data, 0, 16);
- return retval;
- }
- public static Google.ProtocolBuffers.ByteString Construct(SHA256 u)
- {
- byte[] data = u.GetBinaryData();
- Google.ProtocolBuffers.ByteString retval = Google.ProtocolBuffers.ByteString.CopyFrom(data, 0, 16);
- return retval;
- }
- public static float[] ConstructNormal(Vector3f d)
- {
- return new float[] { d.x + (d.z < 0 ? 3.0f : 0.0f), d.y };
- }
- public static float[] ConstructQuaternion(Quaternion d)
- {
- return new float[] { d.x + (d.w < 0 ? 3.0f : 0.0f), d.y, d.z };
- }
- public static float[] ConstructVector2f(Vector2f d)
- {
- return new float[] { d.x, d.y };
- }
- public static double[] ConstructVector2d(Vector2d d)
- {
- return new double[] { d.x, d.y };
- }
- public static float[] ConstructVector3f(Vector3f d)
- {
- return new float[] { d.x, d.y, d.z };
- }
- public static double[] ConstructVector3d(Vector3d d)
- {
- return new double[] { d.x, d.y, d.z };
- }
- public static float[] ConstructVector4f(Vector4f d)
- {
- return new float[] { d.x, d.y, d.z, d.w };
- }
- public static double[] ConstructVector4d(Vector4d d)
- {
- return new double[] { d.x, d.y, d.z, d.w };
- }
- public static float[] ConstructBoundingsphere3f(BoundingSphere3f d)
- {
- return new float[] { d.Center.x, d.Center.y, d.Center.z, d.Radius };
- }
- public static double[] ConstructBoundingsphere3d(BoundingSphere3d d)
- {
- return new double[] { d.Center.x, d.Center.y, d.Center.z, d.Radius };
- }
- public static float[] ConstructBoundingbox3f3f(BoundingBox3f3f d)
- {
- return new float[] { d.Min.x, d.Min.y, d.Min.z, d.Diag.x, d.Diag.y, d.Diag.z };
- }
- public static double[] ConstructBoundingbox3d3f(BoundingBox3d3f d)
- {
- return new double[] { d.Min.x, d.Min.y, d.Min.z, d.Diag.x, d.Diag.y, d.Diag.z };
- }
- }
- }
|