本文整理汇总了C++中deg2rad函数的典型用法代码示例。如果您正苦于以下问题:C++ deg2rad函数的具体用法?C++ deg2rad怎么用?C++ deg2rad使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deg2rad函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dc
void BoatDialog::OnPaintCrossOverChart(wxPaintEvent& event)
{
wxWindow *window = dynamic_cast<wxWindow*>(event.GetEventObject());
if(!window)
return;
wxGCDC dc(window);
dc.SetBackgroundMode(wxTRANSPARENT);
long index = SelectedPolar();
bool polar = !m_cPlotType->GetSelection();
int w, h;
m_CrossOverChart->GetSize( &w, &h);
dc.SetPen(wxPen(wxColor(0, 0, 0)));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.SetTextForeground(wxColour(0, 55, 75));
bool full = m_cbFullPlot->GetValue();
double scale;
int xc = full ? w / 2 : 0;
if(polar) {
scale = wxMin(full ? w/2 : w, h/2) / 40.0;
}
for(double VW = 0; VW < 40; VW += 10) {
if(polar) {
dc.DrawCircle(xc, h/2, VW * scale);
dc.DrawText(wxString::Format(_T("%.0f"), VW), xc, h/2+(int)VW*scale);
} else {
int y = h - VW * h / 40;
dc.DrawLine(0, y, w, y);
dc.DrawText(wxString::Format(_T("%.0f"), VW), 0, y);
}
}
for(double H = 0; H < 180; H += 10) {
if(polar) {
double x = scale*sin(deg2rad(H));
double y = scale*cos(deg2rad(H));
if(H < 180)
dc.DrawLine(xc - x, h/2 + y, xc + x, h/2 - y);
wxString str = wxString::Format(_T("%.0f"), H);
int sw, sh;
dc.GetTextExtent(str, &sw, &sh);
dc.DrawText(str, xc + .9*x - sw/2, h/2 - .9*y - sh/2);
} else {
int x = H * w / 180;
dc.DrawLine(x, 0, x, h);
dc.DrawText(wxString::Format(_T("%.0f"), H), x, 0);
}
}
wxColour colors[] = {*wxRED, *wxGREEN, *wxBLUE, *wxCYAN, *wxYELLOW,
wxColour(255, 0, 255)};
int c = 0;
for(unsigned int i=0; i<m_Boat.Polars.size(); i++) {
bool bold = i == index;
// dc.SetPen(wxPen(colors[c], bold ? 1 : 3));
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(wxColour(colors[c].Red(),
colors[c].Green(),
colors[c].Blue(),
bold ? 230 : 60));
if(++c == (sizeof colors) / (sizeof *colors))
c = 0;
bool tri = true;
TESStesselator *tess = m_Boat.Polars[i].CrossOverRegion.Tesselate(tri);
if(!tess)
continue;
const float* verts = tessGetVertices(tess);
// const int* vinds = tessGetVertexIndices(tess);
const int* elems = tessGetElements(tess);
// const int nverts = tessGetVertexCount(tess);
const int nelems = tessGetElementCount(tess);
// Draw polygons.
for (int i = 0; i < nelems; ++i)
{
if(tri) {
const int* p = &elems[i*3];
wxPoint points[3];
for (unsigned j = 0; j < 3 && p[j] != TESS_UNDEF; ++j) {
double H = verts[p[j]*2+0];
double VW = verts[p[j]*2+1];
points[j] = wxPoint(H * w / 180, h - VW * h / 40);
}
if(polar) {
int count[3] = {CalcPolarPoints(points[0], points[1]),
CalcPolarPoints(points[1], points[2]),
CalcPolarPoints(points[2], points[0])};
wxPoint *pts = new wxPoint[count[0] + count[1] + count[2]];
int c = 0;
for(int j = 0; j<3; j++) {
//.........这里部分代码省略.........
示例2: calcSunApparentLong
/* Purpose: calculate the apparent longitude of the sun (degrees) */
double calcSunApparentLong(double t) {
return calcSunTrueLong(t) - 0.00569 - 0.00478 * sin(deg2rad(125.04-1934.136*t));
}
示例3: calcSunDeclination
/* Purpose: calculate the declination of the sun (degrees) */
double calcSunDeclination(double t) {
return rad2deg(asin(sin(deg2rad(calcObliquityCorrection(t))) *
sin(deg2rad(calcSunApparentLong(t)))));
}
示例4: sqrt
/* compute apparent wind speed from boat speed and true wind */
double Polar::VelocityApparentWind(double VB, double W, double VW)
{
return sqrt(VW*VW + VB*VB + 2*VW*VB*cos(deg2rad(W))); /* law of cosines, W is flipped by 180 */
}
示例5: shear
AffineTransform& AffineTransform::skew(double angleX, double angleY)
{
return shear(tan(deg2rad(angleX)), tan(deg2rad(angleY)));
}
示例6: do_paint_myposition
void
do_paint_myposition()
{
int pixel_x, pixel_y, x,y;
float lat, lon;
GdkColor color;
GdkGC *gc;
GError *error = NULL;
gc = gdk_gc_new(pixmap);
color.green = 60000;
color.blue = 0;
color.red = 10000;
gdk_gc_set_rgb_fg_color(gc, &color);
if(!myposition_icon)
{
myposition_icon = gdk_pixbuf_new_from_file_at_size (
PACKAGE_PIXMAPS_DIR "/tangogps-myposition.png", 36,36,
&error);
if (error)
{
g_print ("%s(): loading pixbuf failure. %s\n", __FUNCTION__,
error->message);
g_error_free (error);
}
}
if (pixmap && !gc_map)
gc_map = gdk_gc_new(pixmap);
printf("*** %s(): \n",__PRETTY_FUNCTION__);
lat = deg2rad(global_myposition.lat);
lon = deg2rad(global_myposition.lon);
pixel_x = lon2pixel(global_zoom, lon);
pixel_y = lat2pixel(global_zoom, lat);
x = pixel_x - global_x;
y = pixel_y - global_y;
printf("%d %d %f %f\n",x,y,lat,lon);
//здесь рисуется жирная центральная точка позиции
if(!myposition_icon)
{
gdk_draw_arc (
pixmap,
gc,
TRUE,
x-4, y-4,
8,8,
0,23040);
}
else
{
gdk_draw_pixbuf (
pixmap,
gc_map,
myposition_icon,
0,0,
x,y-36,
36,36,
GDK_RGB_DITHER_NONE, 0, 0);
gtk_widget_queue_draw_area (
map_drawable,
x, y-36,
36,36);
}
printf("MYPOSITION: lat %f - lon %f\n",lat, lon);
}
示例7: PCL_ERROR
template <typename PointInT, typename PointOutT, typename PointRFT> bool
pcl::UniqueShapeContext<PointInT, PointOutT, PointRFT>::initCompute ()
{
if (!Feature<PointInT, PointOutT>::initCompute ())
{
PCL_ERROR ("[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
return (false);
}
// Default LRF estimation alg: SHOTLocalReferenceFrameEstimation
typename SHOTLocalReferenceFrameEstimation<PointInT, PointRFT>::Ptr lrf_estimator(new SHOTLocalReferenceFrameEstimation<PointInT, PointRFT>());
lrf_estimator->setRadiusSearch (local_radius_);
lrf_estimator->setInputCloud (input_);
lrf_estimator->setIndices (indices_);
if (!fake_surface_)
lrf_estimator->setSearchSurface(surface_);
if (!FeatureWithLocalReferenceFrames<PointInT, PointRFT>::initLocalReferenceFrames (indices_->size (), lrf_estimator))
{
PCL_ERROR ("[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
return (false);
}
if (search_radius_< min_radius_)
{
PCL_ERROR ("[pcl::%s::initCompute] search_radius_ must be GREATER than min_radius_.\n", getClassName ().c_str ());
return (false);
}
// Update descriptor length
descriptor_length_ = elevation_bins_ * azimuth_bins_ * radius_bins_;
// Compute radial, elevation and azimuth divisions
float azimuth_interval = 360.0f / static_cast<float> (azimuth_bins_);
float elevation_interval = 180.0f / static_cast<float> (elevation_bins_);
// Reallocate divisions and volume lut
radii_interval_.clear ();
phi_divisions_.clear ();
theta_divisions_.clear ();
volume_lut_.clear ();
// Fills radii interval based on formula (1) in section 2.1 of Frome's paper
radii_interval_.resize (radius_bins_ + 1);
for (size_t j = 0; j < radius_bins_ + 1; j++)
radii_interval_[j] = static_cast<float> (exp (log (min_radius_) + ((static_cast<float> (j) / static_cast<float> (radius_bins_)) * log (search_radius_/min_radius_))));
// Fill theta didvisions of elevation
theta_divisions_.resize (elevation_bins_+1);
for (size_t k = 0; k < elevation_bins_+1; k++)
theta_divisions_[k] = static_cast<float> (k) * elevation_interval;
// Fill phi didvisions of elevation
phi_divisions_.resize (azimuth_bins_+1);
for (size_t l = 0; l < azimuth_bins_+1; l++)
phi_divisions_[l] = static_cast<float> (l) * azimuth_interval;
// LookUp Table that contains the volume of all the bins
// "phi" term of the volume integral
// "integr_phi" has always the same value so we compute it only one time
float integr_phi = pcl::deg2rad (phi_divisions_[1]) - pcl::deg2rad (phi_divisions_[0]);
// exponential to compute the cube root using pow
float e = 1.0f / 3.0f;
// Resize volume look up table
volume_lut_.resize (radius_bins_ * elevation_bins_ * azimuth_bins_);
// Fill volumes look up table
for (size_t j = 0; j < radius_bins_; j++)
{
// "r" term of the volume integral
float integr_r = (radii_interval_[j+1]*radii_interval_[j+1]*radii_interval_[j+1] / 3) - (radii_interval_[j]*radii_interval_[j]*radii_interval_[j]/ 3);
for (size_t k = 0; k < elevation_bins_; k++)
{
// "theta" term of the volume integral
float integr_theta = cosf (deg2rad (theta_divisions_[k])) - cosf (deg2rad (theta_divisions_[k+1]));
// Volume
float V = integr_phi * integr_theta * integr_r;
// Compute cube root of the computed volume commented for performance but left
// here for clarity
// float cbrt = pow(V, e);
// cbrt = 1 / cbrt;
for (size_t l = 0; l < azimuth_bins_; l++)
// Store in lut 1/cbrt
//volume_lut_[ (l*elevation_bins_*radius_bins_) + k*radius_bins_ + j ] = cbrt;
volume_lut_[(l*elevation_bins_*radius_bins_) + k*radius_bins_ + j] = 1.0f / powf (V, e);
}
}
return (true);
}
示例8: GetGlobalColor
void TacticsInstrument_AppTrueWindAngle::DrawForeground(wxGCDC* dc)
{
wxPoint points[4];
double data;
double val;
double value;
// The default foreground is the arrow used in most dials
wxColour cl;
GetGlobalColor(_T("DASH2"), &cl);
wxPen pen1;
pen1.SetStyle(wxSOLID);
pen1.SetColour(cl);
pen1.SetWidth(2);
dc->SetPen(pen1);
GetGlobalColor(_T("DASH1"), &cl);
wxBrush brush1;
brush1.SetStyle(wxSOLID);
brush1.SetColour(cl);
dc->SetBrush(brush1);
dc->DrawCircle(m_cx, m_cy, m_radius / 8);
/*True Wind*/
dc->SetPen(*wxTRANSPARENT_PEN);
GetGlobalColor(_T("BLUE3"), &cl);
wxBrush brush2;
brush2.SetStyle(wxSOLID);
brush2.SetColour(cl);
dc->SetBrush(brush2);
/* this is fix for a +/-180° round instrument, when m_MainValue is supplied as <0..180><L | R>
* for example TWA & AWA */
if (m_MainValueTrueUnit == _T("\u00B0L"))
data = 360 - m_MainValueTrue;
else
data = m_MainValueTrue;
// The arrow should stay inside fixed limits
if (data < m_MainValueMin) val = m_MainValueMin;
else if (data > m_MainValueMax) val = m_MainValueMax;
else val = data;
value = deg2rad((val - m_MainValueMin) * m_AngleRange / (m_MainValueMax - m_MainValueMin)) + deg2rad(m_AngleStart - ANGLE_OFFSET);
points[0].x = m_cx + (m_radius * 0.95 * cos(value - .010));
points[0].y = m_cy + (m_radius * 0.95 * sin(value - .010));
points[1].x = m_cx + (m_radius * 0.95 * cos(value + .015));
points[1].y = m_cy + (m_radius * 0.95 * sin(value + .015));
points[2].x = m_cx + (m_radius * 0.22 * cos(value + 2.8));
points[2].y = m_cy + (m_radius * 0.22 * sin(value + 2.8));
points[3].x = m_cx + (m_radius * 0.22 * cos(value - 2.8));
points[3].y = m_cy + (m_radius * 0.22 * sin(value - 2.8));
dc->DrawPolygon(4, points, 0, 0);
/* Apparent Wind*/
dc->SetPen(*wxTRANSPARENT_PEN);
GetGlobalColor(_T("DASHN"), &cl);
wxBrush brush;
brush.SetStyle(wxSOLID);
brush.SetColour(cl);
dc->SetBrush(brush);
/* this is fix for a +/-180° round instrument, when m_MainValue is supplied as <0..180><L | R>
* for example TWA & AWA */
if (m_MainValueAppUnit == _T("\u00B0L"))
data = 360 - m_MainValueApp;
else
data = m_MainValueApp;
// The arrow should stay inside fixed limits
if (data < m_MainValueMin) val = m_MainValueMin;
else if (data > m_MainValueMax) val = m_MainValueMax;
else val = data;
value = deg2rad((val - m_MainValueMin) * m_AngleRange / (m_MainValueMax - m_MainValueMin)) + deg2rad(m_AngleStart - ANGLE_OFFSET);
points[0].x = m_cx + (m_radius * 0.95 * cos(value - .010));
points[0].y = m_cy + (m_radius * 0.95 * sin(value - .010));
points[1].x = m_cx + (m_radius * 0.95 * cos(value + .015));
points[1].y = m_cy + (m_radius * 0.95 * sin(value + .015));
points[2].x = m_cx + (m_radius * 0.22 * cos(value + 2.8));
points[2].y = m_cy + (m_radius * 0.22 * sin(value + 2.8));
points[3].x = m_cx + (m_radius * 0.22 * cos(value - 2.8));
points[3].y = m_cy + (m_radius * 0.22 * sin(value - 2.8));
dc->DrawPolygon(4, points, 0, 0);
}
示例9: osd_wp
void
osd_wp()
{
PangoContext *context = NULL;
PangoLayout *layout = NULL;
PangoFontDescription *desc = NULL;
GdkColor color;
GdkGC *gc;
gchar *buffer;
static gchar distunit[3];
static int width = 0, height = 0;
float distance;
double unit_conv = 1;
printf("** %s(): \n",__PRETTY_FUNCTION__);
if(gpsdata && mouse_dx == 0 && mouse_dy == 0)
{
switch (global_speed_unit)
{
case 0:
unit_conv = 1.0;
g_sprintf(distunit, "%s", "km");
break;
case 1 :
unit_conv = 1.0 / 1.609344;
g_sprintf(distunit, "%s", "m");
break;
case 2 :
unit_conv = 1.0 / 1.852;
g_sprintf(distunit, "%s", "NM");
break;
}
distance = get_distance(deg2rad(gpsdata->fix.latitude),
deg2rad(gpsdata->fix.longitude),
global_wp.lat,global_wp.lon);
buffer = g_strdup_printf("%.3f\n%.1f°",
distance*unit_conv,
rad2deg(gpsdata->fix.bearing));
context = gtk_widget_get_pango_context (map_drawable);
layout = pango_layout_new (context);
desc = pango_font_description_new();
pango_font_description_set_size (desc, 12 * PANGO_SCALE);
pango_layout_set_font_description (layout, desc);
pango_layout_set_text (layout, buffer, strlen(buffer));
gc = gdk_gc_new (map_drawable->window);
color.red = 0;
color.green = 0;
color.blue = 0;
gdk_gc_set_rgb_fg_color (gc, &color);
gdk_draw_drawable (
map_drawable->window,
map_drawable->style->fg_gc[GTK_WIDGET_STATE (map_drawable)],
pixmap,
global_drawingarea_width - width - 10,
global_drawingarea_height - height - 10,
global_drawingarea_width - width - 10,
global_drawingarea_height - height - 10,
width+10,height+10);
pango_layout_get_pixel_size(layout, &width, &height);
gdk_draw_layout(map_drawable->window,
gc,
global_drawingarea_width - width - 10,
global_drawingarea_height - height -10,
layout);
g_free(buffer);
pango_font_description_free (desc);
g_object_unref (layout);
//.........这里部分代码省略.........
示例10: AppendSlot
void CWallmarksEngine::AddWallmark_internal (CDB::TRI* pTri, const Fvector* pVerts, const Fvector &contact_point, ref_shader hShader, float sz)
{
// query for polygons in bounding box
// calculate adjacency
{
Fbox bb_query;
Fvector bbc,bbd;
bb_query.set (contact_point,contact_point);
bb_query.grow (sz*2.5f);
bb_query.get_CD (bbc,bbd);
xrc.box_options (CDB::OPT_FULL_TEST);
xrc.box_query (g_pGameLevel->ObjectSpace.GetStaticModel(),bbc,bbd);
u32 triCount = xrc.r_count ();
if (0==triCount) return;
CDB::TRI* tris = g_pGameLevel->ObjectSpace.GetStaticTris();
sml_collector.clear ();
sml_collector.add_face_packed_D (pVerts[pTri->verts[0]],pVerts[pTri->verts[1]],pVerts[pTri->verts[2]],0);
for (u32 t=0; t<triCount; t++) {
CDB::TRI* T = tris+xrc.r_begin()[t].id;
if (T==pTri) continue;
sml_collector.add_face_packed_D (pVerts[T->verts[0]],pVerts[T->verts[1]],pVerts[T->verts[2]],0);
}
sml_collector.calc_adjacency (sml_adjacency);
}
// calc face normal
Fvector N;
N.mknormal (pVerts[pTri->verts[0]],pVerts[pTri->verts[1]],pVerts[pTri->verts[2]]);
sml_normal.set (N);
// build 3D ortho-frustum
Fmatrix mView,mRot;
BuildMatrix (mView,1/sz,contact_point);
mRot.rotateZ (::Random.randF(deg2rad(-20.f),deg2rad(20.f)));
mView.mulA_43 (mRot);
sml_clipper.CreateFromMatrix (mView,FRUSTUM_P_LRTB);
// create wallmark
static_wallmark* W = static_wm_allocate();
RecurseTri (0,mView,*W);
// calc sphere
if (W->verts.size()<3) { static_wm_destroy(W); return; }
else {
Fbox bb; bb.invalidate();
FVF::LIT* I=&*W->verts.begin ();
FVF::LIT* E=&*W->verts.end ();
for (; I!=E; I++) bb.modify (I->p);
bb.getsphere (W->bounds.P,W->bounds.R);
}
if (W->bounds.R < 1.f)
{
// search if similar wallmark exists
wm_slot* slot = FindSlot (hShader);
if (slot){
StaticWMVecIt it = slot->static_items.begin ();
StaticWMVecIt end = slot->static_items.end ();
for (; it!=end; it++) {
static_wallmark* wm = *it;
if (wm->bounds.P.similar(W->bounds.P,0.02f)){ // replace
static_wm_destroy (wm);
*it = W;
return;
}
}
} else {
slot = AppendSlot(hShader);
}
// no similar - register _new_
slot->static_items.push_back(W);
}
}
示例11: createSceneFBO
FBOViewportPtr createSceneFBO(void)
{
//Create Camera Beacon
Matrix CameraMat;
CameraMat.setTranslate(0.0f,0.0f,4.0f);
TransformPtr CameraBeconCore = Transform::create();
beginEditCP(CameraBeconCore, Transform::MatrixFieldMask);
CameraBeconCore->setMatrix(CameraMat);
endEditCP(CameraBeconCore, Transform::MatrixFieldMask);
NodePtr CameraBeconNode = Node::create();
beginEditCP(CameraBeconNode, Node::CoreFieldMask);
CameraBeconNode->setCore(CameraBeconCore);
endEditCP(CameraBeconNode, Node::CoreFieldMask);
//Create Camera
PerspectiveCameraPtr TheCamera = PerspectiveCamera::create();
beginEditCP(TheCamera);
TheCamera->setFov(deg2rad(60.0f));
TheCamera->setAspect(1.0f);
TheCamera->setNear(0.1f);
TheCamera->setFar(100.0f);
TheCamera->setBeacon(CameraBeconNode);
endEditCP(TheCamera);
//Make the Material
BlinnMaterialPtr TheMaterial = BlinnMaterial::create();
beginEditCP(TheMaterial);
TheMaterial->setDiffuse(0.8);
TheMaterial->setColor(Color3f(1.0,1.0,1.0));
TheMaterial->setAmbientColor(Color3f(1.0,1.0,1.0));
TheMaterial->setNumLights(1);
endEditCP(TheMaterial);
// Make Torus Node (creates Torus in background of scene)
NodePtr TorusGeometryNode = makeTorus(.5, 2, 24, 48);
beginEditCP(TorusGeometryNode->getCore());
GeometryPtr::dcast(TorusGeometryNode->getCore())->setMaterial(TheMaterial);
endEditCP(TorusGeometryNode->getCore());
calcVertexNormals(GeometryPtr::dcast(TorusGeometryNode->getCore()));
calcVertexTangents(GeometryPtr::dcast(TorusGeometryNode->getCore()),0,Geometry::TexCoords7FieldId, Geometry::TexCoords6FieldId);
RootTransformCore = Transform::create();
NodePtr TorusTransformNode = Node::create();
beginEditCP(TorusTransformNode, Node::CoreFieldMask);
TorusTransformNode->setCore(RootTransformCore);
TorusTransformNode->addChild(TorusGeometryNode);
endEditCP(TorusTransformNode, Node::CoreFieldMask);
//Create Light Beacon
Matrix LightMat;
LightMat.setTranslate(0.0f,10.0f,1.0f);
TransformPtr LightBeconCore = Transform::create();
beginEditCP(LightBeconCore, Transform::MatrixFieldMask);
LightBeconCore->setMatrix(LightMat);
endEditCP(LightBeconCore, Transform::MatrixFieldMask);
NodePtr LightBeconNode = Node::create();
beginEditCP(LightBeconNode, Node::CoreFieldMask);
LightBeconNode->setCore(LightBeconCore);
endEditCP(LightBeconNode, Node::CoreFieldMask);
//Create Light
TheLight = PointLight::create();
beginEditCP(TheLight);
TheLight->setBeacon(LightBeconNode);
endEditCP(TheLight);
NodePtr LightNode = Node::create();
beginEditCP(LightNode, Node::CoreFieldMask);
LightNode->setCore(TheLight);
LightNode->addChild(TorusTransformNode);
endEditCP(LightNode, Node::CoreFieldMask);
//Create Root
NodePtr TheRoot = Node::create();
beginEditCP(TheRoot);
TheRoot->setCore(Group::create());
TheRoot->addChild(CameraBeconNode);
TheRoot->addChild(LightNode);
TheRoot->addChild(LightBeconNode);
endEditCP(TheRoot);
//Create Background
SolidBackgroundPtr TheBackground = SolidBackground::create();
TheBackground->setColor(Color3f(1.0,0.0,0.0));
//DepthClearBackgroundPtr TheBackground = DepthClearBackground::create();
//Create the Image
ImagePtr TheColorImage = Image::create();
TheColorImage->set(Image::OSG_RGB_PF,2,2,1,1,1,0.0f,0,Image::OSG_FLOAT16_IMAGEDATA);
//Create the texture
TextureChunkPtr TheColorTextureChunk = TextureChunk::create();
//.........这里部分代码省略.........
示例12: main
//.........这里部分代码省略.........
fprintf(stderr, "Couldn't mmap input file %s: %s\n", infn, strerror(errno));
exit(-1);
}
fclose(fid);
if (map_size % USNOB_RECORD_SIZE) {
fprintf(stderr, "Warning, input file %s has size %u which is not divisible into %i-byte records.\n",
infn, (unsigned int)map_size, USNOB_RECORD_SIZE);
}
lastgrass = 0;
for (i=0; i<map_size; i+=USNOB_RECORD_SIZE) {
usnob_entry entry;
int hp;
int slice;
if ((i * 80 / map_size) != lastgrass) {
printf(".");
fflush(stdout);
lastgrass = i * 80 / map_size;
}
if (usnob_parse_entry(map + i, &entry)) {
fprintf(stderr, "Failed to parse USNOB entry: offset %i in file %s.\n",
i, infn);
exit(-1);
}
// compute the usnob_id based on its DEC slice and index.
slice = (int)(entry.dec + 90.0);
assert(slice < 180);
assert((slicecounts[slice] & 0xff000000) == 0);
entry.usnob_id = (slice << 24) | (slicecounts[slice]);
slicecounts[slice]++;
hp = radectohealpix(deg2rad(entry.ra), deg2rad(entry.dec), Nside);
if (!usnobs[hp]) {
char fn[256];
qfits_header* hdr;
sprintf(fn, outfn, hp);
usnobs[hp] = usnob_fits_open_for_writing(fn);
if (!usnobs[hp]) {
fprintf(stderr, "Failed to initialized FITS file %i (filename %s).\n", hp, fn);
exit(-1);
}
if (usnob_fits_remove_an_diffraction_spike_column(usnobs[hp])) {
fprintf(stderr, "Failed to remove the AN_DIFFRACTION_SPIKE column.\n");
exit(-1);
}
hdr = usnob_fits_get_header(usnobs[hp]);
assert(hdr);
// header remarks...
fits_header_add_int(hdr, "HEALPIX", hp, "The healpix number of this catalog.");
fits_header_add_int(hdr, "NSIDE", Nside, "The healpix resolution.");
BOILERPLATE_ADD_FITS_HEADERS(hdr);
qfits_header_add(hdr, "HISTORY", "Created by the program \"usnobtofits\"", NULL, NULL);
qfits_header_add(hdr, "HISTORY", "usnobtofits command line:", NULL, NULL);
fits_add_args(hdr, args, argc);
qfits_header_add(hdr, "HISTORY", "(end of command line)", NULL, NULL);
if (usnob_fits_write_headers(usnobs[hp])) {
fprintf(stderr, "Failed to write header for FITS file %s.\n", fn);
exit(-1);
}
}
if (usnob_fits_write_entry(usnobs[hp], &entry)) {
fprintf(stderr, "Failed to write FITS entry.\n");
exit(-1);
}
nrecords++;
nobs += (entry.ndetections == 0 ? 1 : entry.ndetections);
}
munmap(map, map_size);
nfiles++;
printf("\n");
}
// close all the files...
for (i=0; i<HP; i++) {
if (!usnobs[i])
continue;
if (usnob_fits_fix_headers(usnobs[i]) ||
usnob_fits_close(usnobs[i])) {
fprintf(stderr, "Failed to close file %i: %s\n", i, strerror(errno));
}
}
printf("Read %u files, %u records, %u observations.\n",
nfiles, nrecords, nobs);
free(usnobs);
return 0;
}
示例13: degp2meter
// Convert to actual length
double degp2meter(double degp, double latp) {
return RadiusMeter * deg2rad(degp) * cos(deg2rad(latp2lat(latp)));
}
示例14: paint_pois
void
paint_pois()
{
int pixel_x, pixel_y, x, y;
float lat, lon;
GSList *list;
GdkColor color;
GError *error = NULL;
static GdkPixbuf *photo_icon = NULL;
static GdkGC *gc;
printf("*** %s(): \n",__PRETTY_FUNCTION__);
if (!gc)
gc = gdk_gc_new(pixmap);
color.green = 0;
color.blue = 60000;
color.red = 0;
gdk_gc_set_rgb_fg_color(gc, &color);
if(!photo_icon)
{
photo_icon = gdk_pixbuf_new_from_file_at_size (
PACKAGE_PIXMAPS_DIR "/tangogps-poi.png", 25,25,
&error);
}
if(global_show_pois)
{
get_pois();
for(list = poi_list; list != NULL; list = list->next)
{
poi_t *p = list->data;
lat = deg2rad(p->lat_deg);
lon = deg2rad(p->lon_deg);
pixel_x = lon2pixel(global_zoom, lon);
pixel_y = lat2pixel(global_zoom, lat);
x = pixel_x - global_x;
y = pixel_y - global_y;
p->screen_x = x;
p->screen_y = y;
if(!photo_icon)
{
gdk_draw_arc (
pixmap,
gc,
TRUE,
x-4, y-4,
8,8,
0,23040);
}
else
{
gdk_draw_pixbuf (
pixmap,
NULL,
photo_icon,
0,0,
x-12,y-12,
24,24,
GDK_RGB_DITHER_NONE, 0, 0);
}
gtk_widget_queue_draw_area (
map_drawable,
x-12, y-12,
24,24);
printf("POI: %s lat %f - lon %f\n",p->keywords,p->lat_deg, p->lon_deg);
}
}
}
示例15: meter2degp
double meter2degp(double meter, double latp) {
return rad2deg((1/RadiusMeter) * (meter / cos(deg2rad(latp2lat(latp)))));
}