Complete trajectory Definition

Source: Internet
Author: User
Written in this way...

Typedef enum LocusType
{
LT_LINEAR = 0,
LT_ B _SPLINE,
LT_STEP,
} LocusType;

Class LocusBase
{
Public:
Int m_time;
Protected:
LocusBase (LocusType type );
Const LocusType mc_type;

};

Template <class Point>
Class Locus: public LocusBase // trajectory
{
Public:
LocusType type );
Struct Node
{
Node (): m_time (0), m_p ()
{
}
Node (const Node & n): m_time (n. m_time), m_p (n. m_p)
{
}
Node (int time, Point & p): m_time (time), m_p (p)
{
}
Int m_time;
Point m_p;
Bool operator <(int time) const
{
Return m_time <time;
}
};
Void loadData (const char * data );
Virtual int getInterval (int time, Point & result) = 0;
: Std: vector <Node> m_data;
};

/** // LocusLinear
/// @ Note linear interpolation trajectory
Template <class Point>
Class LocusLinear: public Locus <Point>
{
Public:
LocusLinear ();
Int getInterval (int time, Point & result );
};

/** // LocusBspline
/// @ Note B-spline interpolation trajectory
Template <class Point>
Class LocusBspline: public Locus <Point>
{
Public:
LocusBspline ();
Int getInterval (int time, Point & result );
};

/** // LocusStep
/// @ Note
Template <class Point>
Class LocusStep: public Locus <Point>
{
Public:
LocusStep ();
Int getInterval (int time, Point & result );
};

Effect:
Http://files.cnblogs.com/kaikai/locus.rar

Random data generation: srand (timeGetTime ());
Clip clip;
LocusBspline2d locus;
LocusLinear2d locusZoom;
LocusLinear1d locusRot;
Clip. pFace = & ims;
Struct DATA {
Int time;
Int type;
Int size;
Locus2d: Node node [LOCUS_MAX_NODE_COUNT];
} Data, zoom;
Data. time = 1000;
Data. type = LT_ B _SPLINE,
Data. size = 10;
Zoom. time = 1000;
Zoom. type = LT_LINEAR,
Zoom. size = 10;
Struct DATA2 {
Int time;
Int type;
Int size;
Locus1d: Node node [LOCUS_MAX_NODE_COUNT];
} Rot;
Rot. time = 1000;
Rot. type = LT_LINEAR,
Rot. size = 10;
For (I = 0; I <10; I ++)
{
Data. node [I] = Locus2d: Node (I * 100, Point2d (rand () % 640, rand () % 480 ));
Zoom. node [I] = Locus2d: Node (I * 100, Point2d (rand () % 100/50. f, rand () % 100/50. f ));
Rot. node [I]. m_time = I * 100;
Rot. node [I]. m_p = rand () % 360;
}
Locus. loadData (const char *) & data );
LocusZoom. loadData (const char *) & zoom );
LocusRot. loadData (const char *) & rot );
Anim ani (clip, & locus, & locusZoom, & locusRot );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.