Ejemplo n.º 1
0
void FGSensor::ProcessSensorSignal(void)
{
  Output = Input; // perfect sensor

  // Degrade signal as specified

  if (fail_stuck) {
    Output = PreviousOutput;
  } else if (fcs->GetTrimStatus()) {
    if (lag != 0.0)            {PreviousOutput = Output;    PreviousInput  = Input;}
    if (drift_rate != 0.0)     drift = 0;
    if (gain != 0.0)           Gain();      // models a finite gain
    if (bias != 0.0)           Bias();      // models a finite bias

    if (delay != 0)            for (int i=0; i<delay; i++) output_array[i] = Output;

    Clip();
  } else {
    if (lag != 0.0)            Lag();       // models sensor lag and filter
    if (noise_variance != 0.0) Noise();     // models noise
    if (drift_rate != 0.0)     Drift();     // models drift over time
    if (gain != 0.0)           Gain();      // models a finite gain
    if (bias != 0.0)           Bias();      // models a finite bias

    if (delay != 0)            Delay();     // models system signal transport latencies

    if (fail_low)  Output = -HUGE_VAL;
    if (fail_high) Output =  HUGE_VAL;

    if (bits != 0)             Quantize();  // models quantization degradation

    Clip();
  }
  if (IsOutput) SetOutput();
}
Ejemplo n.º 2
0
void FlatTriangle::Draw( Camera* cam ){
	int i;
	unsigned int* target = cam->target->GetData();
	unsigned int* zbuffer = cam->zbuffer;
	int width = cam->target->GetWidth();
	int height = cam->target->GetHeight();

	Poly p_in, p_out;
	p_in.vertex_count = 3;
	p_in.vertices[0] = vertices[0];
	p_in.vertices[1] = vertices[1];
	p_in.vertices[2] = vertices[2];

	Clip( &p_in, &p_out, &cam->fustrum.sides[0] );
	Clip( &p_out, &p_in, &cam->fustrum.sides[1] );
	Clip( &p_in, &p_out, &cam->fustrum.sides[2] );
	Clip( &p_out, &p_in, &cam->fustrum.sides[3] );

	for(i=0; i<p_in.vertex_count; i++) p_in.vertices[i].point.z += 1.0f;
	Clip( &p_in, &p_out, &cam->fustrum.znear );
	for(i=0; i<p_in.vertex_count; i++) p_in.vertices[i].point.z -= 1.0f;

	Poly* pol = &p_out;
	pol->Triangulate();

	for(i=0; i<pol->face_count; i++){
		vertices2D[0] = cam->TransformVector( pol->vertices[pol->faces[i].a].point );
		vertices2D[1] = cam->TransformVector( pol->vertices[pol->faces[i].b].point );
		vertices2D[2] = cam->TransformVector( pol->vertices[pol->faces[i].c].point );
		DrawFlatTriangle( cam->target, vertices2D, color, zbuffer );
	}
}
Ejemplo n.º 3
0
void GWire2(Vec4 *p, int n, Vec4* colour) {
    int i;
    int x1, y1, x2, y2;
    int reject, col;
    Vec4 value;
    for (i=1;i < n ; i++) {
        x1 = (int) p[i-1][0];
        y1 = (int) p[i-1][1];
        x2 = (int) p[i][0];
        y2 = (int) p[i][1];
        value = colour[i-1];
        col = Colour((int) value[0], (int) value[1], (int) value[2]);
        reject = Clip(0, WIDTH-1, 0, HEIGHT-1, &x1, &y1, &x2, &y2);
        if (!reject)
            Line(x1, y1, x2, y2, col);
    }
    x1 = (int) p[0][0];
    y1 = (int) p[0][1];
    x2 = (int) p[n-1][0];
    y2 = (int) p[n-1][1];
    value = colour[n-1];
    col = Colour((int) value[0], (int) value[1], (int) value[2]);
    reject = Clip(0, WIDTH, 0, HEIGHT, &x1, &y1, &x2, &y2);
    if (!reject)
        Line(x1, y1, x2, y2, col);
}
bool LfnTech::Copy(
	void* destBase,
	const void* srcBase,
	const wxRect& destBounds,
	const wxRect& srcBounds,
	const wxPoint& destPoint,
	const wxRect& srcRect,
	int destStride,
	int srcStride,
	int bytesPerPixel)
{
	bool result = false;

	if (!destBounds.IsEmpty() && !srcBounds.IsEmpty())
	{
		wxPoint destPointClipped(destPoint);
		wxPoint srcPointClipped(srcRect.GetPosition());
		wxSize sizeClipped(srcRect.GetSize());

		// Clip against src bounds, then against dest bounds, then once again
		// against src bounds in case the dest clip translation moved it significantly.
		Clip(srcBounds, srcPointClipped, sizeClipped, destPointClipped);
		Clip(destBounds, destPointClipped, sizeClipped, srcPointClipped);
		Clip(srcBounds, srcPointClipped, sizeClipped, destPointClipped);

		result = Copy(destBase, srcBase, destPointClipped, wxRect(srcPointClipped, sizeClipped), destStride, srcStride, bytesPerPixel);
	}

	return result;
}
Ejemplo n.º 5
0
void
Canvas::Copy(int dest_x, int dest_y,
             unsigned dest_width, unsigned dest_height,
             ConstImageBuffer src, int src_x, int src_y)
{
  if (!Clip(dest_x, dest_width, GetWidth(), src_x) ||
      !Clip(dest_y, dest_height, GetHeight(), src_y))
    return;

  SDLRasterCanvas canvas(buffer);
  canvas.CopyRectangle(dest_x, dest_y, dest_width, dest_height,
                       src.At(src_x, src_y), src.pitch);
}
Ejemplo n.º 6
0
void
Canvas::CopyTransparentWhite(int dest_x, int dest_y,
                             unsigned dest_width, unsigned dest_height,
                             const Canvas &src, int src_x, int src_y)
{
  if (!Clip(dest_x, dest_width, GetWidth(), src_x) ||
      !Clip(dest_y, dest_height, GetHeight(), src_y))
    return;

  SDLRasterCanvas canvas(buffer);
  TransparentPixelOperations<ActivePixelTraits> operations(canvas.Import(COLOR_WHITE));
  canvas.CopyRectangle(dest_x, dest_y, dest_width, dest_height,
                       src.buffer.At(src_x, src_y), src.buffer.pitch,
                       operations);
}
Ejemplo n.º 7
0
Animation::Animation(Renderer* _owner)
{
    owner = _owner;
    currentClip = "default";
    clip[currentClip] = Clip();
    //anim.setTexture(owner->rSource->GetTexture(owner->GetName()));
}
Ejemplo n.º 8
0
void
Canvas::StretchTransparentWhite(int dest_x, int dest_y,
                                unsigned dest_width, unsigned dest_height,
                                ConstImageBuffer src, int src_x, int src_y,
                                unsigned src_width, unsigned src_height)
{
  if (!Clip(dest_x, dest_width, GetWidth(), src_x) ||
      !Clip(dest_y, dest_height, GetHeight(), src_y))
    return;

  SDLRasterCanvas canvas(buffer);
  TransparentPixelOperations<ActivePixelTraits> operations(canvas.Import(COLOR_WHITE));
  canvas.ScaleRectangle(dest_x, dest_y, dest_width, dest_height,
                        src.At(src_x, src_y), src.pitch, src.width, src.height,
                        operations);
}
Ejemplo n.º 9
0
bool FGSensor::Run(void )
{
  Input = InputNodes[0]->getDoubleValue() * InputSigns[0];

  Output = Input; // perfect sensor

  // Degrade signal as specified

  if (fail_stuck) {
    Output = PreviousOutput;
    return true;
  }

  if (lag != 0.0)            Lag();       // models sensor lag and filter
  if (noise_variance != 0.0) Noise();     // models noise
  if (drift_rate != 0.0)     Drift();     // models drift over time
  if (bias != 0.0)           Bias();      // models a finite bias

  if (delay != 0.0)          Delay();     // models system signal transport latencies

  if (fail_low)  Output = -HUGE_VAL;
  if (fail_high) Output =  HUGE_VAL;

  if (bits != 0)             Quantize();  // models quantization degradation

  Clip(); // Is it right to clip a sensor?
  return true;
}
Ejemplo n.º 10
0
bool          Winding::Chop(const vec3_t normal, const vec_t dist)
{
    Winding*      f;
    Winding*      b;

    Clip(normal, dist, &f, &b);
    if (b)
    {
        delete b;
    }

    if (f)
    {
        delete[] m_Points;
        m_NumPoints = f->m_NumPoints;
        m_Points = f->m_Points;
        f->m_Points = NULL;
        delete f;
        return true;
    }
    else
    {
        m_NumPoints = 0;
        delete[] m_Points;
        m_Points = NULL;
        return false;
    }
}
Ejemplo n.º 11
0
int  DoClipCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    int i;
    double min, max;
    channelPtr chan, newchan;

    if (event == EVENT_COMMIT)
    {
        GetCtrlVal (panel, CLIP_CHANNELS, &i);
        GetCtrlVal (panel, CLIP_MIN, &min);
        GetCtrlVal (panel, CLIP_MAX, &max);

        chan = channellist_GetItem (i);

        newchan = channel_Create();
        if (newchan && channel_AllocMem (newchan, chan->pts) &&
            (Clip (chan->readings, chan->pts, max, min, newchan->readings) == NoErr))
        {
            Fmt (newchan->label, "%s (clipped)", chan->label);
            Fmt (newchan->note, "%s\n%s\nmin = %f[e2p3]\nmax = %f[e2p3]\n",
                 chan->note, newchan->label, min, max);
            channellist_AddChannel (newchan);
            return 1;
        }

        MessagePopup ("Clip Channel Message", "Error clipping channel--function voided");
        if (newchan)
        {
            if (newchan->readings) free (newchan->readings);
            free (newchan);
        }
    }
    return 0;
}
Ejemplo n.º 12
0
bool Painter::IntersectClipOp(const Rect& r)
{
	return true;
	RectPath(r);
	Clip();
	return true;
}
Ejemplo n.º 13
0
void FGSensor::ProcessSensorSignal(void)
{
    Output = Input; // perfect sensor

    // Degrade signal as specified

    if (fail_stuck) {
        Output = PreviousOutput;
    } else {
        if (lag != 0.0)            Lag();       // models sensor lag and filter
        if (noise_variance != 0.0) Noise();     // models noise
        if (drift_rate != 0.0)     Drift();     // models drift over time
        if (gain != 0.0)           Gain();      // models a finite gain
        if (bias != 0.0)           Bias();      // models a finite bias

        if (delay != 0)            Delay();     // models system signal transport latencies

        if (fail_low)  Output = -HUGE_VAL;
        if (fail_high) Output =  HUGE_VAL;

        if (bits != 0)             Quantize();  // models quantization degradation

        Clip();
    }
}
Ejemplo n.º 14
0
 _TMESH_TMPL_TYPE
 VOID _TMESH_TMPL_DECL::Clip(iFACET facetIndex, eCOORD coord, REAL minVal, REAL maxVal, REAL step)
 {
   for (REAL val = minVal ;  val <= maxVal; val += step ) {
     Clip(facetIndex, coord, val);
   }
 }
Ejemplo n.º 15
0
bool Painter::ClipOp(const Rect& r)
{
	Begin();
	RectPath(r);
	Clip();
	return true;
}
Ejemplo n.º 16
0
//剪切
void Sprite::Clip( Rect& region )
{
    int wid = region._right - region._left + 1;
    int hei = region._bottom - region._top + 1;

    Clip( region._left, region._top, wid, hei );
}
Ejemplo n.º 17
0
bool FGSwitch::Run(void )
{
  bool pass = false;
  double default_output=0.0;

  for (unsigned int i=0; i<tests.size(); i++) {
    if (tests[i]->Default) {
      default_output = tests[i]->GetValue();
    } else {
      pass = tests[i]->condition->Evaluate();
    }

    if (pass) {
      Output = tests[i]->GetValue();
      break;
    }
  }
  
  if (!pass) Output = default_output;

  if (delay != 0) Delay();
  Clip();
  if (IsOutput) SetOutput();

  return true;
}
Ejemplo n.º 18
0
bool FGWaypoint::Run(void )
{
  double target_latitude = target_latitude_pNode->getDoubleValue() * target_latitude_unit;
  double target_longitude = target_longitude_pNode->getDoubleValue() * target_longitude_unit;
  double source_latitude = source_latitude_pNode->getDoubleValue() * source_latitude_unit;
  double source_longitude = source_longitude_pNode->getDoubleValue() * source_longitude_unit;
  FGLocation source(source_longitude, source_latitude, radius);

  if (WaypointType == eHeading) {     // Calculate Heading
    double heading_to_waypoint_rad = source.GetHeadingTo(target_longitude,
                                                         target_latitude);

    double heading_to_waypoint = 0;
    if (eUnit == eDeg) heading_to_waypoint = heading_to_waypoint_rad * radtodeg;
    else               heading_to_waypoint = heading_to_waypoint_rad;

    Output = heading_to_waypoint;

  } else {                            // Calculate Distance
    double wp_distance = source.GetDistanceTo(target_longitude, target_latitude);

    if (eUnit == eMeters) {
      Output = FeetToMeters(wp_distance);
    } else {
      Output = wp_distance;
    }
  }

  Clip();
  if (IsOutput) SetOutput();

  return true;
}
Ejemplo n.º 19
0
void Polyhedron::Clip(const Plane& plane)
{
    Vector<Vector3> clippedVertices;
    Vector<Vector3> outFace;
    
    Clip(plane, clippedVertices, outFace);
}
Ejemplo n.º 20
0
bool FGSwitch::Run(void )
{
  bool pass = false;
  double default_output=0.0;

  for (unsigned int i=0; i<tests.size(); i++) {
    if (tests[i]->Logic == eDefault) {
      default_output = tests[i]->GetValue();
    } else if (tests[i]->Logic == eAND) {
      pass = true;
      for (unsigned int j=0; j<tests[i]->conditions.size(); j++) {
        if (!tests[i]->conditions[j]->Evaluate()) pass = false;
      }
    } else if (tests[i]->Logic == eOR) {
      pass = false;
      for (unsigned int j=0; j<tests[i]->conditions.size(); j++) {
        if (tests[i]->conditions[j]->Evaluate()) pass = true;
      }
    } else {
      cerr << "Invalid logic test" << endl;
    }

    if (pass) {
      Output = tests[i]->GetValue();
      break;
    }
  }
  
  if (!pass) Output = default_output;

  Clip();
  if (IsOutput) SetOutput();

  return true;
}
Ejemplo n.º 21
0
internals::PointLatLng MercatorProjection::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
{
    internals::PointLatLng ret;// = internals::PointLatLng.Empty;

    Size s = GetTileMatrixSizePixel(zoom);
    double mapSizeX = s.Width();
    double mapSizeY = s.Height();

    double xx = (Clip(x, 0, mapSizeX - 1) / mapSizeX) - 0.5;
    double yy = 0.5 - (Clip(y, 0, mapSizeY - 1) / mapSizeY);

    ret.SetLat(90 - 360 * atan(exp(-yy * 2 * M_PI)) / M_PI);
    ret.SetLng(360 * xx);

    return ret;
}
Ejemplo n.º 22
0
    bool IntrLine2Box2<Real>::DoClipping ( Real t0, Real t1,
                                           const Vector2<Real>& origin, const Vector2<Real>& direction,
                                           const Box2<Real>& box, bool solid, int& quantity, Vector2<Real> point[2],
                                           int& intrType )
    {
        // Convert linear component to box coordinates.
        Vector2<Real> diff = origin - box.Center;
        Vector2<Real> BOrigin(
            diff.Dot( box.Axis[0] ),
            diff.Dot( box.Axis[1] )
        );
        Vector2<Real> BDirection(
            direction.Dot( box.Axis[0] ),
            direction.Dot( box.Axis[1] )
        );

        Real saveT0 = t0, saveT1 = t1;
        bool notAllClipped =
            Clip( +BDirection.X(), -BOrigin.X() - box.Extent[0], t0, t1 ) &&
            Clip( -BDirection.X(), +BOrigin.X() - box.Extent[0], t0, t1 ) &&
            Clip( +BDirection.Y(), -BOrigin.Y() - box.Extent[1], t0, t1 ) &&
            Clip( -BDirection.Y(), +BOrigin.Y() - box.Extent[1], t0, t1 );

        if ( notAllClipped && ( solid || t0 != saveT0 || t1 != saveT1 ) )
        {
            if ( t1 > t0 )
            {
                intrType = IT_SEGMENT;
                quantity = 2;
                point[0] = origin + t0 * direction;
                point[1] = origin + t1 * direction;
            }
            else
            {
                intrType = IT_POINT;
                quantity = 1;
                point[0] = origin + t0 * direction;
            }
        }
        else
        {
            intrType = IT_EMPTY;
            quantity = 0;
        }

        return intrType != IT_EMPTY;
    }
Ejemplo n.º 23
0
void            Winding::Clip(const dplane_t& plane, Winding** front, Winding** back)
{
    vec3_t normal;
    vec_t dist;
    VectorCopy(plane.normal, normal);
    dist = plane.dist;
    Clip(normal, dist, front, back);
}
Ejemplo n.º 24
0
void ClipSelected()
{
  if(ClipMode())
  {
    UndoableCommand undo("clipperClip");
    Clip();
  }
}
Ejemplo n.º 25
0
void Polyhedron::Clip(const Frustum& frustum)
{
    Vector<Vector3> clippedVertices;
    Vector<Vector3> outFace;
    
    for (size_t i = 0; i < NUM_FRUSTUM_PLANES; ++i)
        Clip(frustum.planes[i], clippedVertices, outFace);
}
Ejemplo n.º 26
0
Clip ImageEffect::getClip(const std::string &name) throw(Exception) {
  OfxImageClipHandle hClip;
  OfxStatus stat = mHost->imageEffectSuite()->clipGetHandle(mHandle, name.c_str(), &hClip, NULL);
  if (stat != kOfxStatOK) {
    throw Exception(stat, "ofx::ImageEffect::getClip");
  }
  return Clip(mHost, hClip);
}
Ejemplo n.º 27
0
bool Painter::ClipoffOp(const Rect& r)
{
	Begin();
	RectPath(r);
	Clip();
	Translate(r.left, r.top);
	return true;
}
Ejemplo n.º 28
0
bool Painter::ExcludeClipOp(const Rect& r)
{
	RectPath(Rect(-99999, -99999, 99999, r.top));
	RectPath(Rect(-99999, r.top, r.left, 99999));
	RectPath(Rect(r.right, r.top, 99999, 99999));
	RectPath(Rect(r.left, r.bottom, r.right, 99999));
	Clip();
	return true;
}