iCub-main
Loading...
Searching...
No Matches
Triangle_10pad.h
Go to the documentation of this file.
1// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3/*
4 * Copyright (C) 2009 RobotCub Consortium
5 * Author: Marco Maggiali marco.maggiali@iit.it
6 * CopyPolicy: Released under the terms of the GNU GPL v2.0.
7 *
8 */
9
10#include "include/TouchSensor.h"
11
12#ifndef _TRIANGLE_10PAD_H__
13#define _TRIANGLE_10PAD_H__
14
16{
17public:
18 Triangle_10pad(double cx,double cy,double th,double gain=1.0,int layoutNum=0,int lrMirror=0)
19 {
20 const double DEG2RAD=M_PI/180.0;
21 th=th;
22 const double CST=cos(DEG2RAD*(th+0));
23 const double SNT=sin(DEG2RAD*(th+0));
24
25 const double H=sin(DEG2RAD*60.0);
26 const double L=2.0*H/9.0;
27 const double scale=1/40.0;
28 dGain=gain;
29 ilrMirror=lrMirror;
30 ilayoutNum=layoutNum;
31 nVerts=3;
32 nTaxels=12;
33 m_RadiusOrig=2.2;
34
35 dX[8]=-128.62; dY[8]=222.83;
36 dX[10]= 0; dY[10]=296.55;
37 dX[ 9]= 0; dY[ 9]=445.54;
38 dX[ 11]= 128.62; dY[ 11]=222.83;
39 dX[ 0]= 257.2; dY[ 0]=0;
40 dX[ 6]= -256.3; dY[ 6]=-147.64;
41 dX[ 1]= 385.83; dY[1]=-222.83;
42 dX[ 2]=128.62; dY[ 2]=-222.83;
43 dX[ 3]=0.0; dY[ 3]=0.0;
44 dX[ 4]=-128.62; dY[ 4]=-222.83;
45 dX[ 5]=-385.83; dY[ 5]=-222.83;
46 dX[ 7]=-257.2; dY[ 7]=0.0;
47
48
49
50 for (int i=0; i<nTaxels; ++i)
51 {
52 dX[i]*=scale;
53 dY[i]*=scale;
54 }
55
56 dXv[0]=-55.0/4;
57 dYv[0]=-32.5/4;
58
59 dXv[1]=+55.0/4;
60 dYv[1]=-32.5/4;
61
62 dXv[2]=0.0;
63 dYv[2]=63.0/4;
64
65 for (int i=0; i<nTaxels; ++i)
66 {
67 double x=dX[i];
68 double y=dY[i];
69 if (lrMirror==1) x=-x;
70
71 dX[i]=cx+CST*x-SNT*y;
72 dY[i]=cy+SNT*x+CST*y;
73 }
74
75 for (int i=0; i<nVerts; ++i)
76 {
77 double x=dXv[i];
78 double y=dYv[i];
79 if (lrMirror==1) x=-x;
80
81 dXv[i]=cx+CST*x-SNT*y;
82 dYv[i]=cy+SNT*x+CST*y;
83 }
84
85 // in static definition
86 //dXmin=dYmin= HUGE;
87 //dXmax=dYmax=-HUGE;
88
89 for (int i=0; i<nVerts; ++i)
90 {
91 if (dXv[i]<dXmin) dXmin=dXv[i];
92 if (dXv[i]>dXmax) dXmax=dXv[i];
93 if (dYv[i]<dYmin) dYmin=dYv[i];
94 if (dYv[i]>dYmax) dYmax=dYv[i];
95 }
96
97 dXc=cx;
98 dYc=cy;
99 }
100 void draw(unsigned char *image)
101 {
102 for (int i=0; i<nVerts; ++i)
103 {
104 drawLine(image,xv[i],yv[i],xv[(i+1)%nVerts],yv[(i+1)%nVerts]);
105 }
106
107 for (int i=0; i<nTaxels; ++i)
108 {
109 if ((i==6) || (i==10))
110 {
111 drawCircle(image,x[i],y[i],m_Radius/2);
112 }
113 else
114 drawCircle(image,x[i],y[i],m_Radius);
115 }
116 }
117};
118
119#endif
#define M_PI
Definition XSensMTx.cpp:24
double dX[MAX_TAXELS]
double m_Radius
int x[MAX_TAXELS]
double m_RadiusOrig
static double dXmin
static double dYmax
double dXv[8]
double dY[MAX_TAXELS]
void drawLine(unsigned char *image, int x0, int y0, int x1, int y1)
static double dXmax
double dYv[8]
int y[MAX_TAXELS]
void drawCircle(unsigned char *image, int cx, int cy, double radius)
static double dYmin
void draw(unsigned char *image)
Triangle_10pad(double cx, double cy, double th, double gain=1.0, int layoutNum=0, int lrMirror=0)
#define DEG2RAD