Nurbs curve parameters in Maya? - maya

I get a Maya .ma file, I want to understand the parameters for nurbsCurve, the file has contents like this:
createNode nurbsCurve; # create a nurbsCurve
setAttr -k off ".v"; # set attribute about knots?
setAttr ".cc" -type "nurbsCurve" # attribute setting
3 1 0 no 3
6 0 0 0 1 1 1
4 # 4 stand for the below has 4 coordiniates
7.82436 0.545707 8.54539
7.86896 0.545707 9.61357
7.28368 0.53563 9.8433
6.06638 0.53563 9.89412
;
...
I don't understand what the line 3 1 0 no 3 and 6 0 0 0 1 1 1 stands for, anybody understand what these lines stand for?

Here's what I know so far, only the first three figures.
[3] [1] [0]
corresponds to:
[degree] [span] [index of the form: open/closed/periodic]

Related

how to move inside an array trasformed into an as.data.frame?

I have written the following code to declare an array as data frame:
b=as.data.frame(array(0,dim=c(NF,29,1,T+1),
dimnames=list(NULL,c(…..varnames))))
Now, I am not able to move inside the array.. for instance, if I need to show all the matrices in the following array position [,,1,1], what I need to write?
I have tried code like:
b$[].1.1
b$,1.1
b[,,1,1]"
but, of course, it does not work.
Thank you very much for your help!
from ?as.data.frame :
Arrays can be converted to data frames. One-dimensional arrays are
treated like vectors and two-dimensional arrays like matrices. Arrays
with more than two dimensions are converted to matrices by
‘flattening’ all dimensions after the first and creating suitable
column labels.
array1 <- array(1:8,dim = c(2,2,2),dimnames = split(paste0(rep(letters[1:2],each=3),1:3),1:3))
# , , 3 = a3
#
# 2
# 1 a2 b2
# a1 1 3
# b1 2 4
#
# , , 3 = b3
#
# 2
# 1 a2 b2
# a1 5 7
# b1 6 8
#
df1 <- as.data.frame(array1)
# a2.a3 b2.a3 a2.b3 b2.b3
# a1 1 3 5 7
# b1 2 4 6 8
df1$b2.a3
# [1] 3 4
I need to create the a data frame, starting from an array which dimension is (2,3,1,3):
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
Hence, the output that I need is:
debt loan stock debt loan stock debt loan stock
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
Is next code correct?
b=array(0, dim=c(3,3,1,4), dimnames=list(NULL,c("debt","loan","stock")))
output=as.data.frame(b)

Combining data of two vectors in a time series in R

I am a research assistent and have collected eye movement data, which I now try to analyze using R.
From the eye-tracker I use, every sample is marked as belonging to a saccade (which means the eye moves) or not and belonging to a blink or not. When someone starts to blink, the eye-tracker first identifies a saccade later identifies a blink. To be able to substitute all eye movement samples (lines in my data file), which belong to a blink, I need to create a variable that marks all saccades that contain a blink. A simple example is the following:
I have the data:
Data <- data.frame(Blink=c(0,0,0,1,1,0,0,0,1,1,0,0,0,0,0), Saccade=c(0,1,1,1,1,1,0,1,1,1,1,0,1,1,0))
I would like a variable like this as a result:
Data$Saccade_containing_blink <- c(0,1,1,1,1,1,0,1,1,1,1,0,0,0,0)
Which function would give me that result using R?
# example data
Data <- data.frame(Blink=c(0,0,0,1,1,0,0,0,1,1,0,0,0,0,0),
Saccade=c(0,1,1,1,1,1,0,1,1,1,1,0,1,1,0))
library(dplyr)
Data %>%
group_by(group = cumsum(Saccade==0)) %>% # group your Saccades
mutate(Saccade_containing_blink = max(Blink), # if there's a Blink update all rows within that Saccade
Saccade_containing_blink = ifelse(Saccade == 0, 0, Saccade_containing_blink)) %>% # update Saccade to exclude the 0s (0s separate Saccades)
ungroup() %>% # ungroup data
select(-group) # remove grouping column
# # A tibble: 15 x 3
# Blink Saccade Saccade_containing_blink
# <dbl> <dbl> <dbl>
# 1 0 0 0
# 2 0 1 1
# 3 0 1 1
# 4 1 1 1
# 5 1 1 1
# 6 0 1 1
# 7 0 0 0
# 8 0 1 1
# 9 1 1 1
# 10 1 1 1
# 11 0 1 1
# 12 0 0 0
# 13 0 1 0
# 14 0 1 0
# 15 0 0 0
The philosophy of this approach is to be able to group the Saccade column and check if there's a Blink in at least one of the rows within each Saccade. I assume that Saccades are separated by a 0 in column Saccade.

How to use offset in arrays in bash?

Here is my code.
#! /bin/bash
array=(3 2 1 0 0 0 0 0 0 0)
for i in {0..10}
do
this=${array:$i:$((i+1))}
echo $this
done
I want to print each number of my number separately. I have used this line to get the array elements using an offset number.
this=${array:$i:$((i+1))}
However I am only getting 3 printed and rest all are new lines. I basically want to print 3, 2, 1 etc on separate lines. How do I correct this?
First, you need to use the whole array array[#], not array.
echo "${array[#]:3:2}"
Then, you may change the index to simple variable names:
this=${array[#]:i:i+1}
And then, you probably need to extract just one value of the list:
this=${array[#]:i:1}
Try this code:
array=(3 2 1 0 0 0 0 0 0 0)
for i in {0..10}
do
this=${array[#]:i:1}
echo "$this"
done
There is no reason to use an array slice here, just access the individual elements of the array. Try this:
#! /bin/bash
array=(3 2 1 0 0 0 0 0 0 0)
for i in {0..10}
do
this=${array[$((i+1))]}
echo $this
done
In general you can access a single element of an array like that: ${array[3]}.
Note that in this case, it would have been preferable to do this:
array=(3 2 1 0 0 0 0 0 0 0)
for this in "${array[#]}"
do
echo $this
done

R arrays of 3 dimensions with different inner size

I have an R list (docs) where its first 2 elements are as follows:
1. A. 1 2 5 6
B. 5 6 2
C. 7 8 1 2 3 5
2. A. 4 5 3
B. 1 2 3 5 4 7 8
What I want to achieve is another list with equal sizes but with zeros instead:
1. A. 0 0 0 0
B. 0 0 0
C. 0 0 0 0 0 0
2. A. 0 0 0
B. 0 0 0 0 0 0 0
I have tried:
sapply(docs, function(x) rep(0, length(x)))
but the behaviour is not the intended because it considers the size of the outer list. Could you please help me?
It appears that you have a list of lists, that is docs is a list containing the lists 1 and 2, which then contain numeric vectors. If this is the case, try the following:
# create test list
temp <- list("v1"=list("A"=1:4,"B"=5:7,"C"=1:8), "v2"=list("A"=1:3,"B"=5:10,"C"=3:8))
# get a list of zeros with the same dimension
answer <- lapply(temp, function(x) sapply(x, function(y) rep(0, length(y))))

Plot with image in gnuplot error

I'm trying to plot with image using gnuplot but it always returns me "Reading ras files from sequential devices not supported". Think of a file named "test.txt" includes:
6 5 4 3 1 0
3 2 2 0 0 1
0 0 0 0 1 0
0 0 0 0 2 3
0 0 1 2 4 3
0 1 2 3 4 5
Using gnuplot:
gnuplot> plot "test.txt" matrix w image
gnuplot> Reading ras files from sequential devices not supported
Reading ras files from sequential devices not supported
What can I do about it? Is there any software that I haven't installed in my computer?
I'm using openSuse and I'm not very familiar with it yet.
Thank you in advance

Resources