{"id":123,"date":"2014-11-05T09:31:00","date_gmt":"2014-11-05T09:31:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/dotnet\/2014\/11\/05\/using-system-numerics-vector-for-graphics-programming\/"},"modified":"2021-09-30T16:12:56","modified_gmt":"2021-09-30T23:12:56","slug":"using-system-numerics-vector-for-graphics-programming","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/using-system-numerics-vector-for-graphics-programming\/","title":{"rendered":"Using System.Numerics.Vector for Graphics Programming"},"content":{"rendered":"<p><span style=\"font-size: 12px\">We&#8217;ve just released a major update to the SIMD vector types we&#8217;ve blogged about earlier (<\/span><a style=\"font-size: 12px\" href=\"http:\/\/blogs.msdn.com\/b\/dotnet\/archive\/2014\/04\/07\/the-jit-finally-proposed-jit-and-simd-are-getting-married.aspx\">first announcement<\/a><span style=\"font-size: 12px\">, <\/span><a style=\"font-size: 12px\" href=\"http:\/\/blogs.msdn.com\/b\/dotnet\/archive\/2014\/05\/13\/update-to-simd-support.aspx\">second update<\/a><span style=\"font-size: 12px\">).<\/span><\/p>\n<p>We&#8217;ve now made the vector library a lot more more useful for typical graphics operations. We added matrix types, a plane type, and a quaternion type. We&#8217;ve also added many methods that are often used on fixed size vectors, such as <code>Lerp<\/code>, <code>DistanceSquared<\/code>, <code>Normalize<\/code>, and <code>Reflect<\/code>.<\/p>\n<p>We also completed our SIMD support for primitive types by adding support for <code>Vector&lt;uint&gt;<\/code> and <code>Vector&lt;ulong&gt;<\/code>.<\/p>\n<h2>Getting the new bits<\/h2>\n<p>In order to try out the update, you&#8217;ll need the following components:<\/p>\n<ul>\n<li><a href=\"http:\/\/download.microsoft.com\/download\/C\/D\/3\/CD3C6505-FE7D-46D2-8F93-6A0EE03F6138\/RyuJIT-CTP5.msi\">RyuJIT CPT 5<\/a> and checkout the <a href=\"http:\/\/blogs.msdn.com\/b\/clrcodegeneration\/archive\/2014\/10\/31\/ryujit-ctp5-getting-closer-to-shipping-and-with-better-simd-support.aspx\">announcement<\/a><\/li>\n<li><a href=\"http:\/\/www.nuget.org\/packages\/System.Numerics.Vectors\">System.Numerics.Vectors NuGet package<\/a><\/li>\n<\/ul>\n<h2>Changes in this release<\/h2>\n<p>The first thing you&#8217;ll notice is that we renamed the package from <code>Microsoft.Bcl.Simd<\/code> to <code>System.Numerics.Vectors<\/code>. We intend to ship more .NET components on NuGet so we felt that we need to use a better naming convention that allows people to find our packages.<\/p>\n<p>We decided to simply match our namespace and assembly naming convention. However, in case your project already references <code>Microsoft.Bcl.Simd<\/code>, you can simply upgrade. In that case your project will automatically add a reference to <code>System.Numerics.Vectors<\/code> and show a <code>README<\/code> file that tells you to remove the now superfluous reference to <code>Microsoft.Bcl.Simd<\/code>.<\/p>\n<p>Here is the list of API changes we performed:<\/p>\n<ul>\n<li>We&#8217;ve added support for <code>Vector&lt;uint&gt;<\/code> and <code>Vector&lt;ulong&gt;<\/code>. We now support all integral types, including unsigned<\/li>\n<li>Added new types  \n<ul>\n<li><code>Matrix3x2<\/code><\/li>\n<li><code>Matrix4x4<\/code><\/li>\n<li><code>Plane<\/code><\/li>\n<li><code>Quaternion<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Made fixed size vector types more useful by adding a bunch of methods:  \n<ul>\n<li><code>Distance<\/code>, <code>DistanceSquared<\/code><\/li>\n<li><code>Length<\/code>, <code>LengthSquared<\/code><\/li>\n<li><code>Lerp<\/code><\/li>\n<li><code>Normalize<\/code><\/li>\n<li><code>Reflect<\/code><\/li>\n<li><code>SquareRoot<\/code><\/li>\n<li><code>Transform<\/code>, <code>TransformNormal<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Renamed <code>Vector2f<\/code>, <code>Vector3f<\/code>, <code>Vector4f<\/code> by removing the <code>f<\/code> suffix<\/li>\n<li>Merged <code>VectorMath<\/code> with <code>Vector<\/code> and <code>Vector1<\/code>, <code>Vector2<\/code>, <code>Vector3<\/code><\/li>\n<li>Moved all static methods from <code>Vector&lt;T&gt;<\/code> to the non-generic <code>Vector<\/code> class<\/li>\n<li>Renamed <code>Vector&lt;T&gt;.Length<\/code> to <code>Vector&lt;T&gt;.Count<\/code><\/li>\n<\/ul>\n<p>We&#8217;ve also updated the <a href=\"https:\/\/github.com\/Microsoft\/dotnetsamples\/commit\/a819804663d54366e419331a738cdab7bb44b035\">SIMD samples<\/a> to be compatible with the new version.<\/p>\n<h3><span style=\"font-size: 1.5em\">Summary<\/span><\/h3>\n<p>Today, we&#8217;ve released <a href=\"http:\/\/blogs.msdn.com\/b\/clrcodegeneration\/archive\/2014\/10\/31\/ryujit-ctp5-getting-closer-to-shipping-and-with-better-simd-support.aspx\">RyuJIT CTP 5<\/a> and a much improved <a href=\"http:\/\/www.nuget.org\/packages\/System.Numerics.Vectors\">System.Numerics.Vectors NuGet package<\/a> which adds support for more graphics related APIs.<\/p>\n<p>Please provide feedback as we&#8217;re trying to lock down the API design. You can simply leave a comment here or send us an email via the <a href=\"http:\/\/www.nuget.org\/packages\/System.Numerics.Vectors\/ContactOwners\">contact form<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve just released a major update to the SIMD vector types we&#8217;ve blogged about earlier (first announcement, second update). We&#8217;ve now made the vector library a lot more more useful for typical graphics operations. We added matrix types, a plane type, and a quaternion type. We&#8217;ve also added many methods that are often used on [&hellip;]<\/p>\n","protected":false},"author":335,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[685],"tags":[],"class_list":["post-123","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet"],"acf":[],"blog_post_summary":"<p>We&#8217;ve just released a major update to the SIMD vector types we&#8217;ve blogged about earlier (first announcement, second update). We&#8217;ve now made the vector library a lot more more useful for typical graphics operations. We added matrix types, a plane type, and a quaternion type. We&#8217;ve also added many methods that are often used on [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/335"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=123"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/123\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}