Technical Article

Calculate Angle - Most Advanced UOC

,

This function is used to calculate the actual unit of conversion for angle.

This is a most advanced generic function , which suppose to return values for 6 combinations.

Regards,

Vignesh Arulmani

create function fn_calc_uoc_angle(@FromConversionUnit varchar(64),@ToConversionUnit varchar(64),@UnitValue float)
returns float
as
begin

--ANGLE

declare @returnvalue float

select @returnvalue = 
case 
when @FromConversionUnit = 'degree' and @ToConversionUnit = 'gradian' then @UnitValue * 1.111111111111111
when @FromConversionUnit = 'degree' and @ToConversionUnit = 'radian' then @UnitValue * 0.0174532925199433

when @FromConversionUnit = 'gradian' and @ToConversionUnit = 'degree' then @UnitValue * 0.9
when @FromConversionUnit = 'gradian' and @ToConversionUnit = 'radian' then @UnitValue * 0.015707963267949

when @FromConversionUnit = 'radian' and @ToConversionUnit = 'degree' then @UnitValue * 57.29577951308233
when @FromConversionUnit = 'radian' and @ToConversionUnit = 'gradian' then @UnitValue * 63.66197723675814

when @FromConversionUnit = @ToConversionUnit then @UnitValue * 1.0
end

return(@returnvalue)

end
go


--examples
select dbo.fn_calc_uoc_angle('degree','gradian',10)
select dbo.fn_calc_uoc_angle('degree','radian',10)

select dbo.fn_calc_uoc_angle('gradian','degree',10)
select dbo.fn_calc_uoc_angle('gradian','radian',10)

select dbo.fn_calc_uoc_angle('radian','degree',10)
select dbo.fn_calc_uoc_angle('radian','gradian',10)

Rate

1.67 (3)

You rated this post out of 5. Change rating

Share

Share

Rate

1.67 (3)

You rated this post out of 5. Change rating