Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jeremie Garcia
Trajectoires
Commits
17396aef
Commit
17396aef
authored
Oct 22, 2015
by
Jérémie Garcia
Browse files
refactoring some code
parent
6db68443
Changes
5
Hide whitespace changes
Inline
Side-by-side
WOB/server/interfaces/js/OSC.js
View file @
17396aef
...
...
@@ -31,7 +31,7 @@ Traj.OSC = {
return
'
b
'
;
break
;
case
'
number
'
:
return
Traj
.
OSC
.
isInteger
(
elem
)
?
'
i
'
:
'
f
'
;
;
return
Traj
.
OSC
.
isInteger
(
elem
)
?
'
i
'
:
'
f
'
;
//not using doubles because Max does not understand them
break
;
default
:
return
'
f
'
;
...
...
WOB/server/interfaces/js/TimedCurve.js
View file @
17396aef
...
...
@@ -33,6 +33,7 @@ TimedCurve.prototype.spaceScale = function (factor) {
this
.
Z
[
k
]
=
factor
*
this
.
Z
[
k
];
}
}
TimedCurve
.
prototype
.
sapceScaleAxis
=
function
(
factor
,
vectorAxis
,
pointAxis
)
{
var
point
=
[],
distance
=
0
,
...
...
@@ -66,7 +67,6 @@ TimedCurve.prototype.sapceScaleAxisRange = function(factor,vectorAxis,pointAxis,
}
}
TimedCurve
.
prototype
.
timeScale
=
function
(
factor
)
{
for
(
var
k
=
0
;
k
<
this
.
X
.
length
;
k
++
)
{
this
.
t
[
k
]
=
Math
.
floor
(
factor
*
this
.
t
[
k
]);
...
...
@@ -79,7 +79,6 @@ TimedCurve.prototype.changeTotalTime = function(time) {
this
.
timeScale
(
rapport
);
}
TimedCurve
.
prototype
.
changeXScale
=
function
(
factor
)
{
for
(
var
k
=
0
;
k
<
this
.
X
.
length
;
k
++
)
{
this
.
X
[
k
]
=
factor
*
this
.
X
[
k
];
...
...
@@ -127,7 +126,6 @@ TimedCurve.prototype.tMiror = function() {
}
}
TimedCurve
.
prototype
.
translate
=
function
(
x
,
y
,
z
)
{
var
actualX
=
this
.
X
[
0
];
var
actualY
=
this
.
Y
[
0
];
...
...
@@ -151,8 +149,6 @@ TimedCurve.prototype.rotate = function(center,angle) {
this
.
Y
[
k
]
=
newXY
[
1
];
}
}
// arrange the curve for osc sending
TimedCurve
.
prototype
.
getAllTimedPoints
=
function
()
{
var
allpoints
=
[];
...
...
@@ -183,4 +179,14 @@ TimedCurve.prototype.lengthTime = function() {
return
time
;
}
TimedCurve
.
prototype
.
getDistanceToPoint
=
function
(
pos
)
{
var
distance
=
Infinity
;
var
minDistance
=
Infinity
;
for
(
var
k
=
0
;
k
<
this
.
X
.
length
;
k
++
)
{
distance
=
Traj
.
Utils
.
distanceBtwPoints
([
this
.
X
[
k
],
this
.
Y
[
k
]],
pos
)
if
(
distance
<
minDistance
)
{
minDistance
=
distance
;
}
}
return
minDistance
;
}
WOB/server/interfaces/js/Utils.js
View file @
17396aef
/*
Utilities for Traj namespace
Convert canvas position to different coordonates systems.
Mathematical utilities for curves processing
*/
Traj
.
Utils
=
{
...
...
@@ -196,35 +202,6 @@ Traj.Utils = {
},
getDistanceCurveFromTouch
:
function
(
curve
,
pos
)
{
var
distance
=
Infinity
;
var
minDistance
=
Infinity
;
for
(
var
k
=
0
;
k
<
curve
.
X
.
length
;
k
++
)
{
distance
=
this
.
distanceBtwPoints
([
curve
.
X
[
k
],
curve
.
Y
[
k
]],
pos
)
if
(
distance
<
minDistance
)
{
minDistance
=
distance
;
}
}
return
minDistance
;
},
getClosestCurveFromTouch
:
function
(
pos
)
{
var
trajectories
=
Traj
.
TrajManager
.
trajectories
;
var
curve
=
{};
var
minDistance
=
Infinity
;
var
distance
=
0
;
var
index
=
null
;
for
(
var
k
=
0
;
k
<
trajectories
.
length
;
k
++
)
{
curve
=
trajectories
[
k
];
distance
=
this
.
getDistanceCurveFromTouch
(
curve
,
pos
);
if
(
distance
<
minDistance
){
minDistance
=
distance
;
index
=
k
;
}
}
return
index
;
},
removeDoublon
:
function
(
a
)
{
return
a
.
sort
().
filter
(
function
(
item
,
pos
,
ary
)
{
return
!
pos
||
item
!=
ary
[
pos
-
1
];
...
...
WOB/server/interfaces/js/View.js
View file @
17396aef
...
...
@@ -7,7 +7,6 @@ Traj.View = {
traj_canvas
:
{},
// rendering of the curves
traj_ctx
:
{},
//associated context
bg_canvas
:
{},
//rendering the background
bg_ctx
:
{},
//associated context
...
...
WOB/server/interfaces/js/manager.js
View file @
17396aef
...
...
@@ -285,6 +285,24 @@ Traj.Manager = {
Traj
.
Session
.
saveTrajSession
();
},
getClosestCurveFromTouch
:
function
(
pos
)
{
var
trajectories
=
Traj
.
TrajManager
.
trajectories
;
var
curve
=
{};
var
minDistance
=
Infinity
;
var
distance
=
0
;
var
index
=
null
;
for
(
var
k
=
0
;
k
<
trajectories
.
length
;
k
++
)
{
curve
=
trajectories
[
k
];
distance
=
curve
.
getDistanceToPoint
(
curve
,
pos
);
if
(
distance
<
minDistance
){
minDistance
=
distance
;
index
=
k
;
}
}
return
index
;
},
////////////////////////////////////
////////// CALLED FROM HTML ////////
////////////////////////////////////
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment