//  https://github.com/orocos/orocos_kinematics_dynamics/blob/master/orocos_kdl/src/frames.hpp
// Vector2 defination #include <iostream>
#include <cstring>
#include<string>
#include <math.h>
#include <vector>
#include <frames.hpp>
using namespace std;
using namespace KDL;
#define PI 3.1415926 class Point //二维点class
{
public:
Vector2 point;//二维点
string name;
Point(Vector2 v,string s){point=v;name=s;};
Point(Vector2 v){point=v;};
Point(double x,double y){point=Vector2(x,y);}
Point(){};
void move_p(double x,double y);//平移算子
void rota_p(double an);//旋转算子
};
void Point::move_p(double x,double y){point+=Vector2(x,y);}
void Point::rota_p(double an){
Rotation2 rot(-an/*PI);
point=rot.Inverse(point);
} //class defination finished; ostream&
operator << (ostream& os, const Point& X)
{
return os << '(' << X.point.x()<< ',' << X.point.y()<< ')';
}
//重载运算符 class Shape //由点构成的二维图形class
{
public:
string name;//名称
int n; //顶点数
vector<Point> points;//顶点容器
Shape(string s){name=s;}
Shape(){}
void getpoint(Point p){points.push_back(p);}
void move_s(double x,double y){for(int i=;i<points.size();i++)points[i].move_p(x,y);}
void rota_s(double an){for(int j=;j<points.size();j++)points[j].rota_p(an);}
}; int main(){
Point p(,),p1(,),p2(,);
Shape s1("mine");
s1.getpoint(p);
s1.getpoint(p1);
s1.getpoint(p2); cout<<"图形"<<s1.name<<"里面有"<<s1.points.size()<<"个点"<<endl;
vector<Shape> volume();//图形容器
volume.push_back(s1); cout<<"当前有"<<volume.size()<<"个图形"<<endl;
s1.move_s(,);
for(int i=;i<s1.points.size();i++)cout<<s1.points[i]<<endl; return ;
}

主要由顶点容器构成的平面图形类(Shape)——(第一次作业Draw类定义升级)的更多相关文章

  1. 2.定义图形类Shape,该类中有获得面积的方法getArea();定义长方形类Rect,该类是Shape的子类,类中有矩形长和宽的变量double a,double b,设置长和宽的方法setWidth()、setHeight(),使用getArea()求矩形面积;利用getArea方法实现题1中圆面积的求解。

    // 图形类Shape package d922B; public class Shape { double getArea(ShapePara x){ return x.getArea(); } d ...

  2. DI容器Ninject在管理接口和实现、基类和派生类并实现依赖注入方面的实例

    当一个类依赖于另一个具体类的时候,这样很容易形成两者间的"强耦合"关系.我们通常根据具体类抽象出一个接口,然后让类来依赖这个接口,这样就形成了"松耦合"关系,有 ...

  3. 以点类 Point 及平面图形类 Plane 为基础设计圆类 Circle

    学习内容:以点类 Point 及平面图形类 Plane 为基础设计圆类 Circle 代码示例: import java.util.Scanner; class Point2{ private dou ...

  4. 以点类 Point 及平面图形类 Plane 为基础设计三角形类 Triangle

    学习内容:以点类 Point 及平面图形类 Plane 为基础设计三角形类 Triangle 代码示例: import java.util.Scanner; class Point{ private ...

  5. C#基础-事件 继承类无法直接引发基类的事件

    An event can be raised only from the declaration space in which it is declared. Therefore, a class c ...

  6. JPA实体类注解、springboot测试类、lombok的使用

    前提准备: 搭建一个springboot项目,详情请参见其它博客:点击前往 1 引入相关依赖 web.mysql.jpa.lombok <?xml version="1.0" ...

  7. Effective Java 第三版——23. 优先使用类层次而不是标签类

    Tips <Effective Java, Third Edition>一书英文版已经出版,这本书的第二版想必很多人都读过,号称Java四大名著之一,不过第二版2009年出版,到现在已经将 ...

  8. arcgis for js学习之Draw类

    arcgis for js学习之Draw类 <!DOCTYPE html> <html> <head> <meta http-equiv="Cont ...

  9. UML与软件建模:第二次作业(类图中类的表示)

    一.类图 (1)类图定义 类图,是UML(统一建模语言)中用于描述"类"以及"类与类"之间的示意图.它形象的描述出了系统的结构,帮助人们理解系统. 类图是在&q ...

随机推荐

  1. 前端常用的几个js判断(一)

    1. 禁止右键点击$(document).ready(function(){ $(document).bind("contextmenu",function(e){ return ...

  2. angularJs|es6|reactJs|vueJs相关技术(请访问https://expendo.github.io/)

    技术博客地址:https://expendo.github.io/

  3. ThinkPHP 3.2.3(三)架构之URL模式

    一.标准URL格式 http://serverName/index.php/模块/控制器/操作   二.URL大小写 在/ThinkPHP/Conf/convention.php文件里有URL大小写的 ...

  4. [转]C#中POST数据和接收的几种方式

    POST方式提交数据,一种众所周知的方式: html页面中使用form表单提交,接收方式,使用Request.Form[""]或Request.QueryString[" ...

  5. Swift 03.Dictionary

    字典 key它必须是可哈希的,也就是说,它必须能够提供一个方式让自己被唯一表示出来.Swift的所有基础类型(例如String.Int.Double和Bool)默认都是可哈希的,这些类型都能够用作字典 ...

  6. js判断数组

    1.constructor 在W3C定义中的定义:constructor 属性返回对创建此对象的数组函数的引用 就是返回对象相对应的构造函数.从定义上来说跟instanceof不太一致,但效果都是一样 ...

  7. CALayer 详解 -----转自李明杰

    本文目录 一.什么是CALayer 二.CALayer的简单使用 回到顶部 一.什么是CALayer * 在iOS系统中,你能看得见摸得着的东西基本上都是UIView,比如一个按钮.一个文本标签.一个 ...

  8. bzoj 4066: 简单题

    #include<cstdio> #include<iostream> #include<cstdlib> #include<algorithm> #d ...

  9. Codeforces Round #383 (Div. 1)

    A: 题目大意:给出一个有向图(n<=100),每个点的出度都为1,求最小的t,使得任意两点x,y,如果x走t步后能到y,那么y走t步后到x. 题解: 首先每个点应该都在一个环上,否则无解. 对 ...

  10. Android studio 项目的layout的文件打开,preview 视图无法显示,提示“no sdk found...”可能原因?

    1.安装android studio后启动,引导新的下载的sdk文件夹,不要默认在c:\users\你的用户名\appdata...下的sdk文件夹. 2.如果已经默认的,重新在settings/pr ...