How to convert Proper Motion in RA & Dec to Galactic Coordinates I'm trying to parse stellar data in the GAIA 2 release to galactic coordinates and am struggling with the velocity component. I've tried following online documentation and papers, but end up with velocity results with strange biases that indicate I'm probably doing something wrong. Sources I've used are:
http://adsabs.harvard.edu/full/1987AJ.....93..864J
https://gea.esac.esa.int/archive/documentation//GDR1/Data_processing/chap_cu3ast/sec_cu3ast_intro.html#SS
The GAIA 2 dataset has these relevant variables per star:

ra   (from 0-360)
dec  (from -90 to 90)
pmra
pmdec
parallax
radial_velocity

And this is the code I have (C#) to try to obtain the velocity components. Done by first converting pmra and pmdec to cartesian velocities based on the stars position, and then rotating that location to galactic coordinates.
double RA = ra * Math.PI / 180.0;
double DEC = (dec + 90) * Math.PI / 90.0;

Microsoft.Xna.Framework.Matrix positionrotation = new Microsoft.Xna.Framework.Matrix();
positionrotation.M11 = (float)(Math.Cos(RA) * Math.Cos(DEC));
positionrotation.M12 = (float)-Math.Sin(RA);
positionrotation.M13 = (float)-(Math.Cos(RA) * Math.Sin(DEC));

positionrotation.M21 = (float)(Math.Sin(RA) * Math.Cos(DEC));
positionrotation.M22 = (float)Math.Cos(RA);
positionrotation.M23 = (float)-(Math.Sin(RA) * Math.Sin(DEC));

positionrotation.M31 = (float)(Math.Sin(DEC));
positionrotation.M32 = 0;
positionrotation.M33 = (float)(Math.Cos(DEC));


Microsoft.Xna.Framework.Vector3 vector = new Microsoft.Xna.Framework.Vector3((float)(radial_velocity), (float)(pmra / parallax), (float)(pmdec/ parallax));
vector = Microsoft.Xna.Framework.Vector3.Transform(vector, positionrotation);

Microsoft.Xna.Framework.Matrix galacticrotation = new Microsoft.Xna.Framework.Matrix();
galacticrotation.M11 = -0.054876f;
galacticrotation.M12 = -0.87347f;
galacticrotation.M13 = -0.483835f;
galacticrotation.M21 = 0.494109f;
galacticrotation.M22 = -0.444830f;
galacticrotation.M23 = 0.746982f;
galacticrotation.M31 = -0.867666f;
galacticrotation.M32 = -0.198076f;
galacticrotation.M33 = 0.455984f;
vector = Microsoft.Xna.Framework.Vector3.Transform(vector, galacticrotation);
The DEC conversion in the question is incorrect.
Try this:
double DEC = dec * Math.PI / 180.0;

positionrotation looks like a composition of two rotations bringing (1, 0, 0) to the RA and DEC of interest.
It seems correct, but something like this would be easier to verify:
using Microsoft.Xna.Framework.Matrix;

Matrix positionrotation =
    Matrix.CreateRotationZ((float) RA) * Matrix.CreateRotationY((float) -DEC);

The units in vector are mixed up.
According to these Gaia DR2 docs, radial_velocity is in km/s.
pmra and pmdec are in mas/yr; dividing (*) them by parallax in mas (1 au baseline) gives results in au/yr. Try this:
using Microsoft.Xna.Framework.Vector3;

// conversion to km/s
double au_yr = 1.49598e+8 / 3.15576e+7;

Vector3 velocity = new Vector3(
    (float) radial_velocity, // km/s
    (float) pmra / parallax * au_yr,
    (float) pmdec / parallax * au_yr);

Vector3 vel_icrs = Vector3.Transform(velocity, positionrotation);

If galacticrotation is from equation 3.61 in these Gaia DR2 docs,
// Matrix galacticrotation as above except
galacticrotation.M12 = -0.873437f;

Vector3 vel_gal = Vector3.transform(vel_ircs, galacticrotation);

(*) Actual distance in parsecs may differ from the reciprocal of measured parallax in arcseconds, which may be zero or negative.