content
stringlengths 0
14.9M
| filename
stringlengths 44
136
|
---|---|
---
title: "Getting Started"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Getting Started}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
eval = FALSE,
comment = "#>"
)
```
# Introduction
The `vvtableau` package provides an interface for interacting with Tableau Server using the Tableau REST API. This vignette will walk you through the main functionalities of the package, demonstrating how to authenticate, retrieve information, and perform various operations on Tableau Server.
```{r setup}
library(vvtableau)
```
# Authentication
To begin, you need to authenticate and establish a connection to Tableau Server. Use the authenticate_server() function to provide the server URL, your username, and password. Here's an example:
```{r authenticate}
tableau <- authenticate_server(
server = "https://tableau.server.com",
username = "your_username",
password = "your_password"
)
```
When authentication has succeeded the `tableau` object can be passed to the Tableau REST API methods.
# Retrieving Server Information
Once connected, you can retrieve various information about Tableau Server using the provided functions. Here is an example to retrieve the jobs on the server:
```{r jobs}
get_server_jobs(
tableau,
page_size = 300
)
```
# Conclusion
This vignette covered the basic functionalities of the `vvtableau` package, including authentication, retrieving server information, publishing workbooks, managing users and groups, and downloading workbooks and views. For a complete list of functions and their parameters, please refer to the package documentation.
Please note that this vignette serves as a brief introduction to the package and its capabilities. For more detailed instructions and examples, consult the package documentation and explore the individual function documentation.
We hope you find the `vvtableau` package helpful in automating your Tableau workflows and enhancing your Tableau Server experience!
|
/scratch/gouwar.j/cran-all/cranData/vvtableau/vignettes/getting_started.Rmd
|
#' Authenticate with Semestry Termtime API
#'
#' This function authenticates with the Semestry Termtime API by verifying the API key and base URL.
#' It returns an authenticated Semestry object that can be used for subsequent API calls.
#'
#' @param api_key The API key for Semestry.
#' @param base_url The base URL of the Semestry API.
#'
#' @return An authenticated Semestry object.
#'
#' @export
authenticate <- function(api_key, base_url) {
# Create a Semestry object to store the API key and base URL
semestry <- list(api_key = api_key, base_url = base_url)
# Check if the base URL ends with a trailing slash and remove it if present
if (substr(semestry$base_url, nchar(semestry$base_url), nchar(semestry$base_url)) == "/") {
semestry$base_url <- substr(semestry$base_url, 1, nchar(semestry$base_url) - 1)
}
# Verify authentication by making a test request
test_url <- paste0(semestry$base_url, "/v1/api/rooms")
response <- httr::GET(test_url, httr::add_headers("Authorization" = paste0("k", semestry$api_key)))
# Check the response status code
if (response$status_code != 200) {
stop("Authentication failed. Please check your API key and base URL.")
}
# Return the Semestry object
return(semestry)
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/authenticate.R
|
#' Retrieve activity report attr from the Semestry API
#'
#' This function sends a GET request to the report room endpoint of the Semestry API and retrieves the room booking data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved activity report data from the API.
#'
#' @export
get_activities_report_attr <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/report/activity/attr"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve room booking data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_activities_report_attr.R
|
#' Retrieve activity report schedule from the Semestry API
#'
#' This function sends a GET request to the report room endpoint of the Semestry API and retrieves the room booking data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved activity report data from the API.
#'
#' @export
get_activities_report_sche <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/report/activity/sche"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve room booking data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_activities_report_sche.R
|
#' Retrieve building data from the Semestry API
#'
#' This function sends a GET request to the buildings endpoint of the Semestry API and retrieves the building data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved building data from the API.
#'
#' @export
get_buildings <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/buildings"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve building data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_buildings.R
|
#' Retrieve campus data from the Semestry API
#'
#' This function sends a GET request to the campuses endpoint of the Semestry API and retrieves the campus data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved campus data from the API.
#'
#' @export
get_campuses <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/campuses"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve campus data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_campuses.R
|
#' Retrieve course data from the Semestry API
#'
#' This function sends a GET request to the courses endpoint of the Semestry API and retrieves the course data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved course data from the API.
#' @examples
#' \dontrun{
#' semestry <- authenticate_semestry()
#' get_courses(semestry)
#' }
#'
#' @export
get_courses <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/courses"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve course data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_courses.R
|
#' Retrieve data from the Semestry API database endpoint
#'
#' This function sends a GET request to the database endpoint of the Semestry API and retrieves the data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved data from the API database.
#'
#' @export
get_database <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/database"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve data from the API database. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_database.R
|
#' Retrieve department data from the Semestry API
#'
#' This function sends a GET request to the departments endpoint of the Semestry API and retrieves the department data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved department data from the API.
#'
#' @export
get_departments <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/departments"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve department data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_departments.R
|
#' Retrieve module data from the Semestry API
#'
#' This function sends a GET request to the modules endpoint of the Semestry API and retrieves the module data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved module data from the API.
#'
#' @export
get_modules <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/modules"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve module data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_modules.R
|
#' Retrieve offers from the Semestry API
#'
#' This function sends a GET request to the offers endpoint of the Semestry API and retrieves the offers.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved offers from the API.
#' @examples
#' \dontrun{
#' semestry <- authenticate_semestry()
#' get_offers(semestry)
#' }
#'
#' @export
get_offers <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/offers"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve offers from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_offers.R
|
#' Retrieve booking report from the Semestry API
#'
#' This function sends a GET request to the report booking endpoint of the Semestry API and retrieves the booking booking data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved report booking data from the API.
#'
#' @export
get_report_booking <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/report/booking"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve booking booking data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_report_booking.R
|
#' Retrieve room report from the Semestry API
#'
#' This function sends a GET request to the report room endpoint of the Semestry API and retrieves the room booking data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved report room data from the API.
#'
#' @export
get_report_room <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/report/room"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve room booking data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_report_room.R
|
#' Retrieve room booking data from the Semestry API
#'
#' This function sends a GET request to the roombookings endpoint of the Semestry API and retrieves the room booking data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved room booking data from the API.
#'
#' @export
get_roombookings <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/roombookings"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve room booking data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_roombookings.R
|
#' Retrieve room data from the Semestry API
#'
#' This function sends a GET request to the rooms endpoint of the Semestry API and retrieves the room data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved room data from the API.
#' @examples
#' \dontrun{
#' semestry <- authenticate_semestry()
#' get_rooms(semestry)
#' }
#'
#' @export
get_rooms <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/rooms"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve room data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_rooms.R
|
#' Retrieve schedule rooms data from the Semestry API
#'
#' This function sends a GET request to the schedule/rooms endpoint of the Semestry API and retrieves the schedule rooms data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved schedule rooms data from the API.
#'
#' @export
get_schedule_rooms <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/schedule/rooms"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve schedule rooms data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_schedule_rooms.R
|
#' Retrieve staff data from the Semestry API
#'
#' This function sends a GET request to the staff endpoint of the Semestry API and retrieves the staff data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved staff data from the API.
#' @examples
#' \dontrun{
#' semestry <- authenticate_semestry()
#' get_staff(semestry)
#' }
#'
#' @export
get_staff <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/staff"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve staff data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_staff.R
|
#' Retrieve staff pools from the Semestry API
#'
#' This function sends a GET request to the staffpools endpoint of the Semestry API and retrieves the staff pools.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved staff pools from the API.
#'
#' @export
get_staff_pools <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/staffpools"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve staff pools from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_staff_pools.R
|
#' Retrieve student group mapppings from the Semestry API
#'
#' This function sends a GET request to the studentgroupmaps endpoint of the Semestry API and retrieves the student group mappings data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved student group maps from the API.
#'
#' @export
get_student_group_maps <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/studentgroupmaps"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve student group maps from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_student_group_maps.R
|
#' Retrieve student data from the Semestry API
#'
#' This function sends a GET request to the students endpoint of the Semestry API and retrieves the student data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved student data from the API.
#' @examples
#' \dontrun{
#' semestry <- authenticate_semestry()
#' get_students(semestry)
#' }
#'
#' @export
get_students <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/students"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve student data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_students.R
|
#' Retrieve timeframes data from the Semestry API
#'
#' This function sends a GET request to the timeframes endpoint of the Semestry API and retrieves the timeframes data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved timeframes data from the API.
#'
#' @export
get_timeframes <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/timeframes"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve timeframes data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_timeframes.R
|
#' Retrieve webhook data from the Semestry API
#'
#' This function sends a GET request to the webhooks endpoint of the Semestry API and retrieves the webhook data.
#'
#' @param semestry An authenticated Semestry object.
#' @param timeout The timeout duration for the GET request (default: 30 seconds).
#'
#' @return The retrieved webhook data from the API.
#'
#' @export
get_webhooks <- function(semestry, timeout = 30) {
endpoint <- "/v1/api/webhooks"
url <- paste0(semestry$base_url, endpoint)
resp <- httr::GET(
url,
httr::add_headers("Authorization" = paste0("k", semestry$api_key)),
httr::timeout(timeout)
)
if (resp$status_code == 200) {
content <- httr::content(resp, as = "text", encoding = "UTF-8")
data <- jsonlite::fromJSON(content)
return(data)
} else {
stop(paste("Error: Failed to retrieve webhook data from the API. Status code:", httr::http_status(resp)$status_code))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/get_webhooks.R
|
#' Pipe operator
#'
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details.
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
#' @param lhs A value or the magrittr placeholder.
#' @param rhs A function call using the magrittr semantics.
#' @return The result of calling `rhs(lhs)`.
NULL
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/R/utils-pipe.R
|
## ---- include = FALSE---------------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
eval = FALSE,
comment = "#>"
)
## ----installation-------------------------------------------------------------
# devtools::install_github("vusaverse/vvtermtime")
## ----authenticate-------------------------------------------------------------
# library(vvtermtime)
#
# # Replace "your_api_key" and "https://semestry.com/" with your actual credentials
# semestry <- authenticate(api_key = "your_api_key", base_url = "https://semestry.com/api/")
## ----rooms--------------------------------------------------------------------
# rooms <- get_rooms(semestry)
## ----roombookings-------------------------------------------------------------
# roomsbookings <- get_roombookings(semestry)
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/inst/doc/getting_started.R
|
---
title: "Getting Started with the vvtermtime package"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Getting Started with the vvtermtime package}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
eval = FALSE,
comment = "#>"
)
```
# Introduction
The `vvtermtime` package provides a convenient way to interact with the Semestry TermTime API in R. This vignette will guide you through the installation process and demonstrate how to authenticate with the Semestry API to start retrieving data.
## Installation
You can install the `vvtermtime` package from GitHub using the following command:
```{r installation}
devtools::install_github("vusaverse/vvtermtime")
```
The goal is to make the package available on CRAN in the near future.
# Authentication
To access the Semestry API, you need an API key and the base URL of your Semestry instance. The `authenticate` function allows you to authenticate with the API using these credentials.
```{r authenticate}
library(vvtermtime)
# Replace "your_api_key" and "https://semestry.com/" with your actual credentials
semestry <- authenticate(api_key = "your_api_key", base_url = "https://semestry.com/api/")
```
Make sure to replace "your_api_key" with your actual API key provided by Semestry, and "<https://semestry.com/>" with the appropriate base URL for your Semestry instance.
# Retrieving Data
Once authenticated, you can start retrieving data from the Semestry API using the provided functions. Here are some examples:
## Retrieve Room Data
To retrieve room data, you can simply pass the `semestry` object to the `get_rooms` function:
```{r rooms}
rooms <- get_rooms(semestry)
```
This will fetch the room data from the Semestry API and store it in the rooms variable.
## Retrieve Room Bookings
To retrieve room bookings data, you can use the get_roombookings function:
```{r roombookings}
roomsbookings <- get_roombookings(semestry)
```
This will fetch the room bookings data from the Semestry API and store it in the room_bookings variable.
# Conclusion
This vignette provided a brief overview of the `vvtermtime` package and demonstrated how to get started by authenticating with the Semestry TermTime API and retrieving data. You can explore the package further by referring to the function documentation and other available vignettes.
For more information, please visit the `vvtermtime` [GitHub](https://github.com/vusaverse/vvtermtime/) repository or consult the package documentation.
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/inst/doc/getting_started.Rmd
|
---
title: "Getting Started with the vvtermtime package"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Getting Started with the vvtermtime package}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
eval = FALSE,
comment = "#>"
)
```
# Introduction
The `vvtermtime` package provides a convenient way to interact with the Semestry TermTime API in R. This vignette will guide you through the installation process and demonstrate how to authenticate with the Semestry API to start retrieving data.
## Installation
You can install the `vvtermtime` package from GitHub using the following command:
```{r installation}
devtools::install_github("vusaverse/vvtermtime")
```
The goal is to make the package available on CRAN in the near future.
# Authentication
To access the Semestry API, you need an API key and the base URL of your Semestry instance. The `authenticate` function allows you to authenticate with the API using these credentials.
```{r authenticate}
library(vvtermtime)
# Replace "your_api_key" and "https://semestry.com/" with your actual credentials
semestry <- authenticate(api_key = "your_api_key", base_url = "https://semestry.com/api/")
```
Make sure to replace "your_api_key" with your actual API key provided by Semestry, and "<https://semestry.com/>" with the appropriate base URL for your Semestry instance.
# Retrieving Data
Once authenticated, you can start retrieving data from the Semestry API using the provided functions. Here are some examples:
## Retrieve Room Data
To retrieve room data, you can simply pass the `semestry` object to the `get_rooms` function:
```{r rooms}
rooms <- get_rooms(semestry)
```
This will fetch the room data from the Semestry API and store it in the rooms variable.
## Retrieve Room Bookings
To retrieve room bookings data, you can use the get_roombookings function:
```{r roombookings}
roomsbookings <- get_roombookings(semestry)
```
This will fetch the room bookings data from the Semestry API and store it in the room_bookings variable.
# Conclusion
This vignette provided a brief overview of the `vvtermtime` package and demonstrated how to get started by authenticating with the Semestry TermTime API and retrieving data. You can explore the package further by referring to the function documentation and other available vignettes.
For more information, please visit the `vvtermtime` [GitHub](https://github.com/vusaverse/vvtermtime/) repository or consult the package documentation.
|
/scratch/gouwar.j/cran-all/cranData/vvtermtime/vignettes/getting_started.Rmd
|
## Place a brush at a location, size, and orientation
## Brush here is polyline or polygon defined in [-1, 1] coordinates
## List of x and y (as per 'polyclip' package)
placeBrush <- function(brush,
x, y,
size=1,
angle=0) {
trans <- transformation(list(translation(x, y),
rotation(angle),
scaling(size/2, size/2)))
transform(brush, trans)
}
## Angle at start/end vertex is angle of first/last segment
brushEndAngle <- function(x, y) {
angle(x, y)
}
## Angle at other vertex is (circular) average of angle of previous/next segment
brushAngle <- function(x, y) {
avgangle(x, y)
}
################################################################################
## Sweeping brushes
## Make a segment of a path by calculating the convex hull of a brush
## located at either end of the segment
makeSegment <- function(brush1, brush2, debug=FALSE) {
allpts <- list(x=c(brush1$x, brush2$x),
y=c(brush1$y, brush2$y))
hull <- chull(allpts)
if (debug) {
grid.polygon(allpts$x[hull], allpts$y[hull],
default.units="in", gp=gpar(col=NA, fill=rgb(1,0,0,.5)))
}
list(x=allpts$x[hull], y=allpts$y[hull])
}
## Make a corner of a path by calculating the convex hull of the
## brush rotated aboutsize1 corner vertex
makeCorner <- function(brush, x, y, size, debug=FALSE) {
angle1 <- angle(c(x[1], x[2]), c(y[1], y[2]))
angle2 <- angle(c(x[2], x[3]), c(y[2], y[3]))
## Calculate number of rotations so that the furthermost vertex
## of the brush only moves at most .1in on each rotation
dangle <- angle2 - angle1
if (size > 0 && abs(dangle) > 0) {
arclength <- abs(dangle)/2*pi*size
numRots <- ceiling(arclength/.1)
rotAngle <- dangle/numRots
cornerPoly <- placeBrush(brush, x[2], y[2], size, angle1)
for (i in 1:numRots) {
rotBrush <- placeBrush(brush, x[2], y[2], size, angle1 + rotAngle*i)
if (!all(is.finite(c(cornerPoly$x, rotBrush$x, cornerPoly$y, rotBrush$y)))) browser()
newPoly <- list(x=c(cornerPoly$x, rotBrush$x),
y=c(cornerPoly$y, rotBrush$y))
hull <- chull(newPoly)
cornerPoly <- list(x=newPoly$x[hull], y=newPoly$y[hull])
}
if (debug) {
grid.polygon(cornerPoly$x, cornerPoly$y,
default.units="in",
gp=gpar(col=NA, fill=rgb(0,1,0,.5)))
}
cornerPoly
} else {
result <- placeBrush(brush, x[2], y[2], size, angle1)
if (debug) {
grid.polygon(result$x, result$y,
default.units="in",
gp=gpar(col=NA, fill=rgb(0,0,1,.5)))
}
result
}
}
################################################################################
## Combining brushes, or the result of sweeping brushes
combineShapes <- function(x, y) {
## Handle when either x or y is "empty" polygon
if (length(x) && length(y)) {
polyclip(x, y, op="union")
} else {
if (length(x)) {
x
} else if (length(y)) {
y
} else {
list()
}
}
}
################################################################################
## Some predefined brushes
## Important that brush is not zero-extent
## (otherwise, union of segments can fail to join neighbouring segments)
## NOTE that units can be used (interpreted as locations within [0, 1] viewport)
verticalBrush <- list(x=c(-.001, -.001, .001, .001),
y=c(-1, 1, 1, -1))
circleBrush <- function(n=50) {
t <- seq(0, 2*pi, length.out=n)[-n]
list(x=cos(t), y=sin(t))
}
squareBrush <- list(x=c(-1, -1, 1, 1), y=c(-1, 1, 1, -1))
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/brush.R
|
################################################################################
## brushXspline()
grid.brushline <- function(...) {
grid.draw(brushlineGrob(...))
}
brushlineGrob <- function(brush, x, y, w, default.units="npc",
shape=1, angle="perp", open=TRUE,
render=vwPath(),
gp=gpar(fill="black"), name=NULL, debug=FALSE) {
## Ok to recycle x or y or w
maxlen <- max(length(x), length(y), length(w))
if (length(x) < maxlen)
x <- rep(x, length.out=maxlen)
if (length(y) < maxlen)
y <- rep(y, length.out=maxlen)
if (length(w) < maxlen)
w <- rep(w, length.out=maxlen)
checkbrushline(x, y)
if (!is.unit(x)) {
x <- unit(x, default.units)
}
if (!is.unit(y)) {
y <- unit(y, default.units)
}
if (!is.unit(w)) {
w <- unit(w, default.units)
}
gTree(brush=brush, x=x, y=y, w=w, shape=shape, angle=angle, open=open,
render=render,
gp=gp, name=name, cl="brushlineGrob",
debug=debug)
}
checkbrushline <- function(x, y, w) {
if (max(length(x), length(y)) < 2)
stop("A brushline must have at least two points")
nx <- length(x)
ny <- length(y)
nw <- length(w)
if (nx != ny || nx != nw) {
stop("x, y, and w must all have same length")
}
}
brushlineOutline <- function(grob) {
N <- length(grob$x)
x <- convertX(grob$x, "in", valueOnly=TRUE)
y <- convertY(grob$y, "in", valueOnly=TRUE)
w <- pmin(convertWidth(grob$w, "in", valueOnly=TRUE),
convertHeight(grob$w, "in", valueOnly=TRUE))
## Calculate distances between flattened vertices
lengths <- c(0, sqrt(diff(x)^2 + diff(y)^2))
cumLength <- cumsum(lengths)
totalLength <- sum(lengths)
if (grepl("vert", grob$angle)) {
a <- rep(0, length(x))
} else if (grepl("horiz", grob$angle)) {
a <- rep(pi/2, length(x))
} else {
a <- numeric(length(x))
if (grob$open) {
a[1] <- brushEndAngle(x[1:2], y[1:2])
} else {
a[1] <- brushAngle(x[c(N, 1:2)], y[c(N, 1:2)])
}
if (N > 2) {
for (i in 2:(N - 1)) {
a[i] <- brushAngle(x[(i-1):(i+1)], y[(i-1):(i+1)])
}
}
if (grob$open) {
a[N] <- brushEndAngle(x[(N-1):N], y[(N-1):N])
} else {
a[N] <- brushAngle(x[c((N-1):N, 1)], y[c((N-1):N, 1)])
}
}
brushes <- vector("list", N)
brushes[[1]] <- placeBrush(grob$brush, x[1], y[1], w[1], a[1])
if (N > 2) {
for (i in 2:(N - 1)) {
brushes[[i]] <- placeBrush(grob$brush, x[i], y[i], w[i], a[i])
}
}
brushes[[N]] <- placeBrush(grob$brush, x[N], y[N], w[N], a[N])
## Make segment for each pair of vertices
## (based on convex hull of brush at vertices)
segments <- vector("list", N - 1)
for (i in 1:(N - 1)) {
segments[[i]] <- makeSegment(brushes[[i]], brushes[[i+1]],
debug=grob$debug)
}
if (!grob$open) {
## Connect last brush to first brush
segments[[N]] <- makeSegment(brushes[[N]], brushes[[1]],
debug=grob$debug)
}
## Form union of all segments (may be more than one polygon)
curve <- Reduce(combineShapes, segments)
if (grob$debug) {
## Show the brushes at each vertex
for (i in 1:N) {
b <- brushes[[i]]
grid.polygon(b$x, b$y, default.units="in", gp=gpar(col="grey"))
}
}
curve
}
makeContent.brushlineGrob <- function(x, ...) {
outline <- brushlineOutline(x)
if (is.null(outline$x)) {
## outline is list of outlines
addGrob(x,
x$render(unlist(lapply(outline, "[[", "x")),
unlist(lapply(outline, "[[", "y")),
sapply(outline, function(o) length(o$x)),
x$gp, "outline"))
} else {
addGrob(x,
x$render(outline$x,
outline$y,
length(outline$x),
x$gp, "outline"))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/brushline.R
|
################################################################################
## brushXspline()
grid.brushXspline <- function(...) {
grid.draw(brushXsplineGrob(...))
}
## Lower 'tol'erance means more detail in the width curve
## (for when you want fine detail from the width curve)
## Higher 'tol'erance means less detail in the width curve
## (for when you want a bit less detail from the width curve)
brushXsplineGrob <- function(brush, x, y, w=unit(1, "cm"), default.units="npc",
shape=1, angle="perp", open=TRUE, spacing=NULL,
render=vwPath(),
gp=gpar(fill="black"),
name=NULL, debug=FALSE) {
checkbrushXspline(x, y)
if (!is.unit(x)) {
x <- unit(x, default.units)
}
if (!is.unit(y)) {
y <- unit(y, default.units)
}
if (!inherits(w, "widthSpline") && !inherits(w, "BezierWidth")) {
w <- widthSpline(w, default.units)
}
gTree(brush=brush, x=x, y=y, w=w, shape=shape, angle=angle, open=open,
spacing=spacing, render=render, tol=.01,
gp=gp, name=name, cl="brushXsplineGrob",
debug=debug)
}
checkbrushXspline <- function(x, y, w) {
if (max(length(x), length(y)) < 2)
stop("A brushXspline must have at least two points")
nx <- length(x)
ny <- length(y)
if (nx != ny) {
stop("x and y must have same length")
}
}
brushXsplineOutline <- function(grob) {
## Flatten curve
pts <- xsplinePoints(xsplineGrob(grob$x, grob$y, shape=grob$shape,
open=grob$open))
## Pts are in inches
xx <- as.numeric(pts$x)
yy <- as.numeric(pts$y)
N <- length(xx)
if (grob$debug) {
## Show flattened path vertices
grid.points(xx, yy, default.units="in", pch=16, size=unit(1, "mm"))
}
## Calculate distances between flattened vertices
lengths <- c(0, sqrt(diff(xx)^2 + diff(yy)^2))
## Drop points that are too close to each other
## (can lead to numerical instability when calculating angles)
smallLengths <- c(FALSE, lengths[-1] < grob$tol)
if (any(smallLengths)) {
xx <- xx[!smallLengths]
yy <- yy[!smallLengths]
N <- length(xx)
lengths <- c(0, sqrt(diff(xx)^2 + diff(yy)^2))
}
if (!grob$open) {
lengths <- c(lengths, sqrt((xx[N] - xx[1])^2 + (yy[N] - yy[1])^2))
}
cumLength <- cumsum(lengths)
totalLength <- sum(lengths)
widths <- resolveWidth(grob$w, totalLength)
## Add vertex corresponding to each explicit width
## (handles case of more widths than vertices for straight edges)
## No need to worry about 0 and 1 (they correspond exactly to vertices)
if (length(widths$x) > 2) {
newPath <- fortifyPath(xx, yy, widths$x, lengths, grob$open, grob$tol)
## New vertices
xx <- newPath$x
yy <- newPath$y
N <- length(xx)
## Recalculate distances between vertices
lengths <- c(0, sqrt(diff(xx)^2 + diff(yy)^2))
if (!grob$open) {
lengths <- c(lengths, sqrt((xx[N] - xx[1])^2 + (yy[N] - yy[1])^2))
}
cumLength <- cumsum(lengths)
totalLength <- sum(lengths)
}
if (is.null(grob$spacing)) {
## Interpolate width at each vertex
ww <- approx(widths$x, widths$y, cumLength, rule=2)$y
## fixed angle is simple
if (is.numeric(grob$angle)) {
a <- rep(grob$angle, length(xx))
} else { # should be "perp" but anything will do
a <- numeric(length(xx))
if (grob$open) {
a[1] <- brushEndAngle(xx[1:2], yy[1:2])
} else {
a[1] <- brushAngle(xx[c(N, 1:2)], yy[c(N, 1:2)])
}
if (N > 2) {
for (i in 2:(N - 1)) {
a[i] <- brushAngle(xx[(i-1):(i+1)], yy[(i-1):(i+1)])
}
}
if (grob$open) {
a[N] <- brushEndAngle(xx[(N-1):N], yy[(N-1):N])
} else {
a[N] <- brushAngle(xx[c((N-1):N, 1)], yy[c((N-1):N, 1)])
}
}
brushes <- vector("list", N)
brushes[[1]] <- placeBrush(grob$brush, xx[1], yy[1], ww[1], a[1])
if (N > 2) {
for (i in 2:(N - 1)) {
brushes[[i]] <- placeBrush(grob$brush, xx[i], yy[i], ww[i], a[i])
}
}
brushes[[N]] <- placeBrush(grob$brush, xx[N], yy[N], ww[N], a[N])
## Make segment for each pair of vertices
## (based on convex hull of brush at vertices)
segments <- vector("list", N - 1)
for (i in 1:(N - 1)) {
segments[[i]] <- makeSegment(brushes[[i]], brushes[[i+1]],
debug=grob$debug)
}
if (!grob$open) {
## Connect last brush to first brush
segments[[N]] <- makeSegment(brushes[[N]], brushes[[1]],
debug=grob$debug)
}
## Form union of all segments (may be more than one polygon)
curve <- Reduce(combineShapes, segments)
if (grob$debug) {
## Show the brushes at each vertex
for (i in 1:N) {
b <- brushes[[i]]
grid.polygon(b$x, b$y, default.units="in", gp=gpar(col="grey"))
}
}
} else {
## Determine locations of brushes
s <- resolveDistance(grob$spacing, totalLength)
brushLocs <- interpPath(xx, yy, s, lengths, grob$open)
bx <- brushLocs$x
by <- brushLocs$y
a <- brushLocs$angle
N <- length(bx)
## Interpolate width at each location
ww <- approx(widths$x, widths$y, s, rule=2)$y
## fixed angle is simple
if (is.numeric(grob$angle)) {
a <- rep(grob$angle, length(xx))
} # else should be "perp" but anything will do
brushes <- vector("list", N)
brushes[[1]] <- placeBrush(grob$brush, bx[1], by[1], ww[1], a[1])
if (N > 2) {
for (i in 2:(N - 1)) {
brushes[[i]] <- placeBrush(grob$brush, bx[i], by[i], ww[i], a[i])
}
}
if (N > 1) {
brushes[[N]] <- placeBrush(grob$brush, bx[N], by[N], ww[N], a[N])
}
if (N > 1) {
curve <- Reduce(combineShapes, brushes)
} else {
curve <- brushes
}
}
curve
}
makeContent.brushXsplineGrob <- function(x, ...) {
outline <- brushXsplineOutline(x)
if (is.null(outline$x)) {
## outline is list of outlines
addGrob(x,
x$render(unlist(lapply(outline, "[[", "x")),
unlist(lapply(outline, "[[", "y")),
sapply(outline, function(o) length(o$x)),
x$gp, "outline"))
} else {
addGrob(x,
x$render(outline$x,
outline$y,
length(outline$x),
x$gp, "outline"))
}
}
edgePoints.brushXsplineGrob <- function(x, d,
x0, y0,
which=1,
direction="forward",
debug=FALSE,
...) {
## Silently force which to length 1
which <- which[1]
outline <- brushXsplineOutline(x)
if (is.null(outline$x)) {
## outline is list of outlines
if (which > length(outline)) {
stop("Invalid which value")
}
edge <- outline[[which]]
} else {
if (length(which) != 1 || which != 1) {
stop("Invalid which value")
}
edge <- outline
}
if (!is.unit(x0)) x0 <- unit(x0, "npc")
if (!is.unit(y0)) y0 <- unit(y0, "npc")
pts <- reorderEdge(edge, x0, y0)
vwEdgePoints(pts, d, direction == "forward", x$open, debug)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/brushxspline.R
|
## For debugging diagrams
pts <- function(x, y, col="grey") {
if (length(x)) {
grid.points(x, y, default.units="in", size=unit(2, "mm"), pch=16,
gp=gpar(col=col))
}
}
lines <- function(x, y, col="grey") {
if (length(x)) {
grid.lines(x, y, default.units="in", gp=gpar(col=col))
}
}
segs <- function(x1, y1, x2, y2, col="grey") {
if (length(x1)) {
grid.segments(x1, y1, x2, y2, default.units="in", gp=gpar(col=col))
}
}
polyl <- function(x, y, id=length(x), col="black") {
if (length(x)) {
grid.polyline(x, y, default.units="in", id=id, gp=gpar(col=col))
}
}
polyg <- function(x, y, id=rep(1, length(x)), col="black", fill=NA) {
if (length(x)) {
grid.polygon(x, y, default.units="in", id=id,
gp=gpar(col=col, fill=fill))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/debug.R
|
################################################################################
## Handle specification of distance along line
resolveDistance <- function(d, length, fill=TRUE) {
if (is.unit(d)) {
dd <- pmin(convertX(d, "in", valueOnly=TRUE),
convertY(d, "in", valueOnly=TRUE))
} else {
## Assume s is proportions of length
dd <- d*length
}
dd <- sort(dd)
if (fill) {
## Repeat to fill path
mdd <- max(dd)
if (mdd < length) {
multiple <- (length - mdd) %/% mdd + 1
dd <- c(dd,
rep(1:multiple*mdd, each=length(dd)) + rep(dd, multiple))
}
}
## Trim to path
rd <- round(dd, 4)
subset <- rd >= 0 & rd <= round(length, 4)
## Make sure that locations at either end of the line are included
dstart <- rd == 0
if (any(dstart)) {
dd[dstart] <- 0
}
dend <- rd == round(length, 4)
if (any(dend)) {
dd[dend] <- length
}
dd[subset]
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/distance.R
|
## Generic interface for calculating points on the boundary of a
## variable-width curve
## 'x' is the curve object
## 'd' specifies distance along the edge
edgePoints <- function(x, d, ...) {
UseMethod("edgePoints")
}
## The difference types of curves generate different boundaries, but
## given a boundary, they all do the same thing
vwEdgePoints <- function(pts, d, forward, open, debug=FALSE) {
## each boundary is either numeric (imlpicit inches) or a unit in "in"
x <- as.numeric(pts$x)
y <- as.numeric(pts$y)
if (!forward) {
x <- rev(x)
y <- rev(y)
}
if (!open) {
x <- c(x, x[1])
y <- c(y, y[1])
}
## Calculate total length of boundary
lengths <- c(0, sqrt(diff(x)^2 + diff(y)^2))
cumLength <- cumsum(lengths)
length <- sum(lengths)
## Determine point selection
locs <- resolveDistance(d, length, fill=FALSE)
index <- apply(outer(locs, cumLength, "<="), 1,
function(x) min(which(x)))
## Add tangent info
n <- length(locs)
tangent <- numeric(n)
xx <- numeric(n)
yy <- numeric(n)
for (i in 1:n) {
## What is the distance to the next boundary point ?
prev <- index[i] - 1
if (prev < 1) {
dist <- locs[i]
prev <- length(x)
} else {
dist <- locs[i] - cumLength[prev]
}
if (dist == 0) {
## Bang on a boundary point
xx[i] <- x[index[i]]
yy[i] <- y[index[i]]
below <- index[i] - 1
if (below < 1) below <- length(x)
above <- index[i] + 1
if (above > length(x)) above <- 1
tangent[i] <- angle(x[c(above, below)], y[c(above, below)])
} else {
tangent[i] <- angle(x[c(prev, index[i])], y[c(prev, index[i])])
xx[i] <- x[prev] + dist*cos(tangent[i])
yy[i] <- y[prev] + dist*sin(tangent[i])
}
}
x <- unit(xx, "in")
y <- unit(yy, "in")
if (debug) {
grid.points(x, y, size=unit(2, "mm"),
pch=16, gp=gpar(col="red"))
grid.segments(x, y,
x + unit(5*cos(tangent - pi/2), "mm"),
y + unit(5*sin(tangent - pi/2), "mm"),
gp=gpar(col="red"))
grid.text(1:n, x, y)
}
list(x=x, y=y, tangent=tangent)
}
reorderEdge <- function(pts, x0, y0) {
x0 <- convertX(x0, "in", valueOnly=TRUE)
y0 <- convertY(y0, "in", valueOnly=TRUE)
N <- length(pts$x)
dist <- (pts$x - x0)^2 + (pts$y - y0)^2
closest <- which.min(dist)[1]
order <- (1:N + closest - 2) %% N
list(x=pts$x[order], y=pts$y[order])
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/edge.R
|
## Generate a bunch of useful information about the line
## (NOTE that width is allowed to be different to the left and to the right
## of the main line)
## 'x' and 'y' must have same length
segInfo <- function(x, y, w, open=FALSE, stepWidth=FALSE, debug=FALSE) {
if (!open) {
## There is an additional segment to close the line
x <- c(x, x[1])
y <- c(y, y[1])
w$left <- c(w$left, w$left[1])
w$right <- c(w$right, w$right[1])
}
N <- length(x)
## All of these are per *segment* (N - 1)
dx <- diff(x)
dy <- diff(y)
lengths <- dist(dx^2, dy^2)
angle <- atan2(dy, dx)
perpangle <- angleInRange(angle + pi/2)
cosperp <- cos(perpangle)
sinperp <- sin(perpangle)
if (stepWidth) {
perpStartLeftX <- x[-N] + w$left[-N]*cosperp
perpStartLeftY <- y[-N] + w$left[-N]*sinperp
perpStartRightX <- x[-N] - w$right[-N]*cosperp
perpStartRightY <- y[-N] - w$right[-N]*sinperp
perpEndLeftX <- x[-1] + w$left[-N]*cosperp
perpEndLeftY <- y[-1] + w$left[-N]*sinperp
perpEndRightX <- x[-1] - w$right[-N]*cosperp
perpEndRightY <- y[-1] - w$right[-N]*sinperp
} else {
perpStartLeftX <- x[-N] + w$left[-N]*cosperp
perpStartLeftY <- y[-N] + w$left[-N]*sinperp
perpStartRightX <- x[-N] - w$right[-N]*cosperp
perpStartRightY <- y[-N] - w$right[-N]*sinperp
perpEndLeftX <- x[-1] + w$left[-1]*cosperp
perpEndLeftY <- y[-1] + w$left[-1]*sinperp
perpEndRightX <- x[-1] - w$right[-1]*cosperp
perpEndRightY <- y[-1] - w$right[-1]*sinperp
}
if (debug) {
pts(x, y)
lines(x, y)
polyg(c(perpStartLeftX, perpEndLeftX,
perpEndRightX, perpStartRightX),
c(perpStartLeftY, perpEndLeftY,
perpEndRightY, perpStartRightY),
id=rep(1:(N-1), 4), "grey")
segs(x[-N], y[-N], perpStartLeftX, perpStartLeftY, "red")
segs(x[-1], y[-1], perpEndLeftX, perpEndLeftY, "pink")
segs(x[-N], y[-N], perpStartRightX, perpStartRightY, "blue")
segs(x[-1], y[-1], perpEndRightX, perpEndRightY, "lightblue")
}
data.frame(dx, dy, lengths, angle, perpangle, cosperp, sinperp,
perpStartLeftX, perpStartLeftY, perpStartRightX, perpStartRightY,
perpEndLeftX, perpEndLeftY, perpEndRightX, perpEndRightY)
}
cornerInfo <- function(sinfo, open=FALSE, stepWidth=FALSE, debug=FALSE) {
if (!open) {
## There is an additional corner where the line end meets the line start
sinfo <- rbind(sinfo, sinfo[1,])
}
N <- nrow(sinfo)
if (N < 2) return(data.frame())
## All of these are per *corner* (N - 1)
with(sinfo,
{
leftAngle <- angleDiff(angle[-N], angle[-1], clockwise=FALSE)
rightAngle <- angleDiff(angle[-N], angle[-1], clockwise=TRUE)
## Include parallel as inside join
epsdegree <- .1/180*pi
leftInside <- leftAngle <= pi | abs(leftAngle - 2*pi) < epsdegree
## Following PDF definition
leftMitreLength <-
ifelse(leftInside,
0,
1/sin(angleDiff(angleInRange(angle[-N] + pi),
angle[-1], clockwise=FALSE)/2))
rightMitreLength <-
ifelse(leftInside,
1/sin(angleDiff(angleInRange(angle[-N] + pi),
angle[-1], clockwise=TRUE)/2),
0)
## Intersection left edge segments with each other
leftIntEdge <- intersection(perpStartLeftX[-N], perpStartLeftY[-N],
perpEndLeftX[-N], perpEndLeftY[-N],
perpStartLeftX[-1], perpStartLeftY[-1],
perpEndLeftX[-1], perpEndLeftY[-1])
## Intersection left edge segments with next segment end
leftInt1 <- intersection(perpStartLeftX[-N], perpStartLeftY[-N],
perpEndLeftX[-N], perpEndLeftY[-N],
perpStartLeftX[-1], perpStartLeftY[-1],
perpStartRightX[-1], perpStartRightY[-1])
## Intersection left edge segments with prev segment end
leftInt2 <- intersection(perpStartLeftX[-1], perpStartLeftY[-1],
perpEndLeftX[-1], perpEndLeftY[-1],
perpEndLeftX[-N], perpEndLeftY[-N],
perpEndRightX[-N], perpEndRightY[-N])
## Edge segment intersects with next segment end on segment end
edgeIntNext <- onSegment(perpStartLeftX[-1], perpStartLeftY[-1],
leftInt1$x, leftInt1$y,
perpStartRightX[-1], perpStartRightY[-1])
edgeIntPrev <- onSegment(perpStartLeftX[-N], perpStartLeftY[-N],
leftInt2$x, leftInt2$y,
perpStartRightX[-N], perpStartRightY[-N])
## Is the intersection with next segment end between edge end
## and edge intersection ?
endIntBetween <- onSegment(perpEndLeftX[-N], perpEndLeftY[-N],
leftInt1$x, leftInt1$y,
leftIntEdge$x, leftIntEdge$y) |
onSegment(perpStartLeftX[-1], perpStartLeftY[-1],
leftInt2$x, leftInt2$y,
leftIntEdge$x, leftIntEdge$y)
## Inside corners do not use intersections at all
useEdgeInt <- leftInside | (!leftInside & !endIntBetween)
leftIntx1 <-
ifelse(useEdgeInt,
leftIntEdge$x,
ifelse(edgeIntNext, leftInt1$x, perpEndLeftX[-N]))
leftIntx2 <-
ifelse(useEdgeInt,
leftIntEdge$x,
ifelse(edgeIntNext, perpStartLeftX[-1], leftInt2$x))
leftInty1 <-
ifelse(useEdgeInt,
leftIntEdge$y,
ifelse(edgeIntNext, leftInt1$y, perpEndLeftY[-N]))
leftInty2 <-
ifelse(useEdgeInt,
leftIntEdge$y,
ifelse(edgeIntNext, perpStartLeftY[-1], leftInt2$y))
rightInside <- rightAngle >= -pi |
abs(rightAngle - -2*pi) < epsdegree
rightIntEdge <- intersection(perpStartRightX[-N],
perpStartRightY[-N],
perpEndRightX[-N], perpEndRightY[-N],
perpStartRightX[-1],
perpStartRightY[-1],
perpEndRightX[-1], perpEndRightY[-1])
rightInt1 <- intersection(perpStartRightX[-N], perpStartRightY[-N],
perpEndRightX[-N], perpEndRightY[-N],
perpStartLeftX[-1], perpStartLeftY[-1],
perpStartRightX[-1], perpStartRightY[-1])
rightInt2 <- intersection(perpStartRightX[-1], perpStartRightY[-1],
perpEndRightX[-1], perpEndRightY[-1],
perpEndLeftX[-N], perpEndLeftY[-N],
perpEndRightX[-N], perpEndRightY[-N])
edgeIntNext <- onSegment(perpStartLeftX[-1], perpStartLeftY[-1],
rightInt1$x, rightInt1$y,
perpStartRightX[-1], perpStartRightY[-1])
edgeIntPrev <- onSegment(perpStartLeftX[-N], perpStartLeftY[-N],
rightInt2$x, rightInt2$y,
perpStartRightX[-N], perpStartRightY[-N])
endIntBetween <- onSegment(perpEndRightX[-N], perpEndRightY[-N],
leftInt1$x, rightInt1$y,
rightIntEdge$x, rightIntEdge$y) |
onSegment(perpStartRightX[-1],
perpStartRightY[-1],
rightInt2$x, rightInt2$y,
rightIntEdge$x, rightIntEdge$y)
useEdgeInt <- rightInside | (!rightInside & !endIntBetween)
rightIntx1 <-
ifelse(useEdgeInt,
rightIntEdge$x,
ifelse(edgeIntNext, rightInt1$x, perpEndRightX[-N]))
rightIntx2 <-
ifelse(useEdgeInt,
rightIntEdge$x,
ifelse(edgeIntNext, perpStartRightX[-1], rightInt2$x))
rightInty1 <-
ifelse(useEdgeInt,
rightIntEdge$y,
ifelse(edgeIntNext, rightInt1$y, perpEndRightY[-N]))
rightInty2 <-
ifelse(useEdgeInt,
rightIntEdge$y,
ifelse(edgeIntNext, perpStartRightY[-1], rightInt2$y))
if (debug) {
pts(leftIntx1[leftInside], leftInty1[leftInside], "orange")
pts(leftIntx2[leftInside], leftInty2[leftInside], "orange")
pts(rightIntx1[rightInside], rightInty1[rightInside],
"orange")
pts(rightIntx2[rightInside], rightInty2[rightInside],
"orange")
pts(leftIntx1[!leftInside], leftInty1[!leftInside],
"orange")
pts(rightIntx1[!rightInside], rightInty1[!rightInside],
"orange")
pts(leftIntx2[!leftInside], leftInty2[!leftInside],
"orange")
pts(rightIntx2[!rightInside], rightInty2[!rightInside],
"orange")
polyl(c(perpEndLeftX[-N][!leftInside],
leftIntx1[!leftInside], leftIntx2[!leftInside],
perpStartLeftX[-1][!leftInside]),
c(perpEndLeftY[-N][!leftInside],
leftInty1[!leftInside], leftInty2[!leftInside],
perpStartLeftY[-1][!leftInside]),
id=rep((1:(N-1))[!leftInside], 4), "orange")
polyl(c(perpEndRightX[-N][!rightInside],
rightIntx1[!rightInside], rightIntx2[!rightInside],
perpStartRightX[-1][!rightInside]),
c(perpEndRightY[-N][!rightInside],
rightInty1[!rightInside], rightInty2[!rightInside],
perpStartRightY[-1][!rightInside]),
id=rep((1:(N-1))[!rightInside], 4), "orange")
}
data.frame(leftInside, rightInside,
leftMitreLength, rightMitreLength,
leftIntx1, leftIntx2, leftInty1, leftInty2,
rightIntx1, rightIntx2, rightInty1, rightInty2)
})
}
bezierArcInfo <- function(startx, starty, endx, endy, inside, leftedge,
N, angle, centre, cornerangle, drawArc,
isjoin, debug) {
## If we are on a join, must ensure that angles are clockwise
## around left corners and anticlockwise around right corners
## (especially when the join becomes inverted)
## Ends are not the same, just keep going around a wide end
if (isjoin) {
cornerangle <- angleInRange(cornerangle)
}
onedegree <- 1/180*pi
k <- ifelse(abs(cornerangle - pi) < onedegree |
abs(cornerangle - -pi) < onedegree,
2/3, abs(4/(3*(1/cos(cornerangle/2) + 1))))
int <- intersection(startx[-N], starty[-N],
endx[-N], endy[-N],
startx[-1], starty[-1],
endx[-1], endy[-1])
## Special case angle pi (where 'k' calculation breaks down [div by zero])
## Also special case where corner has point of inflexion
## (so incident edges do not intersect between edge ends;
## just use half dist between edge ends)
len <- ifelse(abs(cornerangle - pi) < onedegree |
abs(cornerangle - -pi) < onedegree,
dist(endx[-N] - startx[-1], endy[-N] - starty[-1]),
ifelse(onSegment(startx[-N], starty[-N], int$x, int$y,
endx[-N], endy[-N]) |
onSegment(startx[-1], starty[-1], int$x, int$y,
endx[-1], endy[-1]),
dist(endx[-N] - startx[-1], endy[-N] - starty[-1])/2,
pmin(dist(int$x - endx[-N], int$y - endy[-N]),
dist(int$x - startx[-1], int$y - starty[-1]))))
cp1 <- extend(endx[-N], endy[-N], angle[-N], k*len)
cp2 <- extend(startx[-1], starty[-1], angle[-1], -k*len)
arcs <- vector("list", N-1)
subset <- !inside & drawArc
if (any(subset)) {
for (i in (1:(N-1))[subset]) {
bezg <- BezierGrob(c(endx[i], cp1$x[i], cp2$x[i], startx[i+1]),
c(endy[i], cp1$y[i], cp2$y[i], starty[i+1]),
default.units="in")
arcs[[i]] <- BezierPoints(bezg)
}
}
if (debug) {
if (any(subset)) {
for (i in (1:(N-1))[subset]) {
segs(c(endx[i], startx[i+1]), c(endy[i], starty[i+1]),
c(cp1$x[i], cp2$x[i]), c(cp1$y[i], cp2$y[i]), "green")
grid.Bezier(c(endx[i], cp1$x[i], cp2$x[i], startx[i+1]),
c(endy[i], cp1$y[i], cp2$y[i], starty[i+1]),
default.units="in",
gp=gpar(col="green"))
}
}
}
arcx <- lapply(arcs, "[[", "x")
arcy <- lapply(arcs, "[[", "y")
data.frame(I(arcx), I(arcy), cornerangle)
}
arcInfo <- function(startx, starty, endx, endy, inside, leftedge, isjoin,
debug) {
N <- length(startx)
## All of these are per *corner* (N - 1)
dx <- endx - startx
dy <- endy - starty
angle <- atan2(dy, dx)
if (leftedge) {
perpangle <- angleInRange(angle + pi/2)
} else {
perpangle <- angleInRange(angle - pi/2)
}
cosperp <- cos(perpangle)
sinperp <- sin(perpangle)
## "width" of perp does not matter; just generating line segment
wedge1PerpX <- endx[-N] + .1*cosperp[-N]
wedge1PerpY <- endy[-N] + .1*sinperp[-N]
wedge2PerpX <- startx[-1] + .1*cosperp[-1]
wedge2PerpY <- starty[-1] + .1*sinperp[-1]
centre <- intersection(endx[-N], endy[-N],
wedge1PerpX, wedge1PerpY,
startx[-1], starty[-1],
wedge2PerpX, wedge2PerpY)
rad1 <- dist(endx[-N] - centre$x, endy[-N] - centre$y)
rad2 <- dist(startx[-1] - centre$x, starty[-1] - centre$y)
adiff <- angleDiff(perpangle[-N], perpangle[-1], leftedge)
## If only a very small gap, draw a straight line segment
arclength <- abs(pmax(rad1, rad2)*adiff)
drawArc <- !is.finite(arclength) | arclength > .01
bezInfo <- bezierArcInfo(startx, starty, endx, endy, inside, leftedge,
N, angle, centre, adiff, drawArc, isjoin,
debug)
if (debug) {
subset <- !inside
if (any(subset)) {
mapply(function(ax, ay, cx, cy) {
## If width is zero, ax will be empty
if (length(ax)) {
polyg(c(ax, cx), c(ay, cy),
col=NA, fill=rgb(0,1,0,.2))
}
},
bezInfo$arcx[subset], bezInfo$arcy[subset],
as.list(centre$x[subset]), as.list(centre$y[subset]))
}
}
bezInfo
}
cornerArcInfo <- function(sinfo, cinfo, open=FALSE, debug=FALSE) {
if (!open) {
## There is an additional corner where the line end meets the line start
sinfo <- rbind(sinfo, sinfo[1,])
}
N <- nrow(sinfo)
if (N < 2) return(data.frame())
with(sinfo,
{
## NOTE that this is ONLY an arc of a circle when line width
## is constant either side of corner OR change in line width
## is identical either side of corner
leftinfo <- arcInfo(perpStartLeftX, perpStartLeftY,
perpEndLeftX, perpEndLeftY,
cinfo$leftInside, TRUE, TRUE, debug=debug)
rightinfo <- arcInfo(perpStartRightX, perpStartRightY,
perpEndRightX, perpEndRightY,
cinfo$rightInside, FALSE, TRUE, debug=debug)
names(leftinfo) <- paste0("left", names(leftinfo))
names(rightinfo) <- paste0("right", names(rightinfo))
cbind(leftinfo, rightinfo)
})
}
## 'x' and 'y' are length 2, with *second* value the end point
capInfo <- function(x, y, d,
leftperpx1, leftperpy1, leftperpx2, leftperpy2,
rightperpx1, rightperpy1, rightperpx2, rightperpy2,
debug) {
if (d > 0) {
ext <- extend(x[2], y[2], angle(x, y), d)
perpext <- perpEnd(c(x[2], ext$x),
c(y[2], ext$y), 1)
corner1 <- intersection(leftperpx1, leftperpy1,
leftperpx2, leftperpy2,
perpext[1,1], perpext[1,2],
perpext[2,1], perpext[2,2])
corner2 <- intersection(rightperpx1, rightperpy1,
rightperpx2, rightperpy2,
perpext[1,1], perpext[1,2],
perpext[2,1], perpext[2,2])
mitre <- intersection(leftperpx1, leftperpy1,
leftperpx2, leftperpy2,
rightperpx1, rightperpy1,
rightperpx2, rightperpy2)
mitrelength <- dist(mitre$x - x[2], mitre$y - y[2])
## Check whether mitre is pointing "backwards"
mitreExt <- extend(x[2], y[2], angle(x, y), 1.1*mitrelength)
if (onSegment(x[2], y[2], mitre$x, mitre$y, mitreExt$x, mitreExt$y) &&
is.finite(mitre$x) && is.finite(mitre$y) &&
dist(mitre$x - x[2], mitre$y - y[2]) < d) {
corner1 <- mitre
corner2 <- mitre
}
} else {
corner1 <- corner2 <- mitre <- list(x=x[2], y=y[2])
mitrelength <- 0
}
if (debug) {
pts(c(corner1$x, corner2$x),
c(corner1$y, corner2$y), "pink")
lines(c(leftperpx2, corner1$x, corner2$x, rightperpx2),
c(leftperpy2, corner1$y, corner2$y, rightperpy2),
"pink")
pts(mitre$x, mitre$y, "orange")
lines(c(leftperpx2, mitre$x, rightperpx2),
c(leftperpy2, mitre$y, rightperpy2),
"orange")
}
list(corner1, corner2, mitre, mitrelength)
}
endInfo <- function(x, y, w, sinfo, stepWidth=FALSE, debug=FALSE) {
N <- length(x)
with(sinfo,
{
d <- (w$left[1] + w$right[1])/2
startInfo <- capInfo(x[2:1], y[2:1], d,
perpEndLeftX[1], perpEndLeftY[1],
perpStartLeftX[1], perpStartLeftY[1],
perpEndRightX[1], perpEndRightY[1],
perpStartRightX[1], perpStartRightY[1],
debug)
if (stepWidth) {
d <- (w$left[N-1] + w$right[N-1])/2
} else {
d <- (w$left[N] + w$right[N])/2
}
endInfo <- capInfo(x[(N-1):N], y[(N-1):N], d,
perpStartLeftX[N-1], perpStartLeftY[N-1],
perpEndLeftX[N-1], perpEndLeftY[N-1],
perpStartRightX[N-1], perpStartRightY[N-1],
perpEndRightX[N-1], perpEndRightY[N-1],
debug)
names(startInfo) <- c("startcorner1", "startcorner2",
"startmitre", "startmitrelength")
names(endInfo) <- c("endcorner1", "endcorner2",
"endmitre", "endmitrelength")
c(startInfo, endInfo)
})
}
endArcInfo <- function(sinfo, einfo, debug=FALSE) {
N <- nrow(sinfo)
with(sinfo,
{
startInfo <- arcInfo(c(perpEndRightX[1], perpStartLeftX[1]),
c(perpEndRightY[1], perpStartLeftY[1]),
c(perpStartRightX[1], perpEndLeftX[1]),
c(perpStartRightY[1], perpEndLeftY[1]),
FALSE, TRUE, FALSE, debug)
endInfo <- arcInfo(c(perpStartLeftX[N], perpEndRightX[N]),
c(perpStartLeftY[N], perpEndRightY[N]),
c(perpEndLeftX[N], perpStartRightX[N]),
c(perpEndLeftY[N], perpStartRightY[N]),
FALSE, TRUE, FALSE, debug)
list(startInfo, endInfo)
})
}
## Given an end point (x, y) and
## end edges (leftx1, leftx2, lefty1, lefty2)
## (rightx1, rightx2, righty1, righty2)
## generate a short segment (no longer than the shortest edge?)
## that is perpendicular to the line joining the edge ends
## and calculate widths at either end of that segment
## (perpendicular distances from segment ends to edges)
generateSegment <- function(x, y, leftx, lefty, rightx, righty, debug=FALSE) {
## Scale up because some X-spline segments are really tiny
x <- 1000*x
y <- 1000*y
leftx1 <- 1000*leftx[1]
leftx2 <- 1000*leftx[2]
lefty1 <- 1000*lefty[1]
lefty2 <- 1000*lefty[2]
rightx1 <- 1000*rightx[1]
rightx2 <- 1000*rightx[2]
righty1 <- 1000*righty[1]
righty2 <- 1000*righty[2]
## FIXME: '0.1' (inches) below will not be appropriate if the
## edge(s) approach the end point very obliquely
segEnd <- perpStart(c(x, leftx1), c(y, lefty1), 0.1)[2,]
perpEnd <- perpEnd(c(x, segEnd[1]), c(y, segEnd[2]), 0.1)
corner1 <- intersection(leftx1, lefty1,
leftx2, lefty2,
perpEnd[1,1], perpEnd[1,2],
perpEnd[2,1], perpEnd[2,2])
corner2 <- intersection(rightx1, righty1,
rightx2, righty2,
perpEnd[1,1], perpEnd[1,2],
perpEnd[2,1], perpEnd[2,2])
## Scale back down
x <- x/1000
y <- y/1000
leftx1 <- leftx1/1000
lefty1 <- lefty1/1000
leftx2 <- leftx2/1000
lefty2 <- lefty2/1000
rightx1 <- rightx1/1000
righty1 <- righty1/1000
rightx2 <- rightx2/1000
righty2 <- righty2/1000
segEnd <- segEnd/1000
corner1$x <- corner1$x/1000
corner1$y <- corner1$y/1000
corner2$x <- corner2$x/1000
corner2$y <- corner2$y/1000
if (debug) {
grid.points(x, y, size=unit(2, "mm"),
default.units="in",
gp=gpar(col="grey"))
grid.polygon(c(leftx1, leftx2, rightx2, rightx1),
c(lefty1, lefty2, righty2, righty1),
default.units="in",
gp=gpar(col="grey"))
grid.segments(x, y, segEnd[1], segEnd[2],
default.units="in",
gp=gpar(col="red"))
grid.segments(corner1$x, corner1$y, corner2$x, corner2$y,
default.units="in",
gp=gpar(col="red"))
}
list(x=c(x, segEnd[1]), y=c(y, segEnd[2]),
w=list(left=c(dist(x - leftx1, y - lefty1),
dist(segEnd[1] - corner1$x, segEnd[2] - corner1$y)),
right=c(dist(x - rightx1, y - righty1),
dist(segEnd[1] - corner2$x, segEnd[2] - corner2$y))))
}
testGenerateSegment <- function() {
grid.newpage()
seg <- generateSegment(1, 1,
c(1, 2), c(1.5, 2),
c(1, 2.5), c(.5, 1),
debug=TRUE)
sinfo <- segInfo(seg$x, seg$y, seg$w, FALSE, FALSE, TRUE)
einfo <- endInfo(seg$x, seg$y, seg$w, sinfo, FALSE, TRUE)
earcinfo <- endArcInfo(sinfo, einfo, TRUE)
ends <- buildEnds(seg$w, einfo, earcinfo, FALSE, "round", 4)
grid.lines(ends$startx, ends$starty, default.units="in")
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/endsjoins.R
|
## Code for calculating ends and joins in style "extend"
## for offsetBezierGrob with BezierWidth width
## Function to calculate extension amount in terms of 't'
## to extend by an amount in inches 'd'
## (based on the assumption that steps along extension, per unit 't',
## will always be longer than steps within curve, 0 < t < 1,
## so determining distance per unit 't' within curve will be lower
## bound on distance per unit 't' along extension)
calcExtensionT <- function(d, length) {
d/length
}
extendJoins <- function(pts1, pts2, w1, w2, opts1, lengths1, lengths2,
i1, i2, grob, widths) {
x <- convertX(grob$x, "in", valueOnly=TRUE)
y <- convertY(grob$y, "in", valueOnly=TRUE)
bez1 <- BezierGrob(x[i1], y[i1], default.units="in", stepFn=grob$stepFn)
bez2 <- BezierGrob(x[i2], y[i2], default.units="in", stepFn=grob$stepFn)
## Calculate corner info
n1 <- length(pts1$x)
sinfo <- segInfo(c(pts1$x[n1-1], pts2$x[1:2]),
c(pts1$y[n1-1], pts2$y[1:2]),
list(left=c(w1[n1-1], w2[1:2]),
right=c(w1[n1-1], w2[1:2])),
TRUE, FALSE, grob$debug)
cinfo <- cornerInfo(sinfo, TRUE, FALSE, grob$debug)
## How far to extend ?
joinExtend <- calcExtensionT(grob$mitrelimit*w2[1]*2,
c(sum(lengths1), sum(lengths2)))
## Extend curve 1
extpts1 <- BezierPoints(bez1, c(1, 1 + joinExtend[1]))
extopts1 <- BezierNormal(bez1, c(1, 1 + joinExtend[1]))
extlengths1 <- c(0, sqrt(diff(extpts1$x)^2 + diff(extpts1$y)^2))
extcumLength1 <- cumsum(extlengths1)
## lengths1 + cumLength because lengths are AFTER curve1
extww1 <- approx(widths$x, widths$y, lengths1 + extcumLength1, rule=2)$y/2
## Extend curve 2
extpts2 <- BezierPoints(bez2, c(0, -joinExtend[2]))
extopts2 <- BezierNormal(bez2, c(0, -joinExtend[2]))
extlengths2 <- c(0, sqrt(diff(extpts2$x)^2 + diff(extpts2$y)^2))
extcumLength2 <- cumsum(extlengths2)
## lengths1 - cumLength because lengths are BEFORE curve 2
extww2 <- approx(widths$x, widths$y, lengths1 - extcumLength2, rule=2)$y/2
## Do the "outside" edges intersect ?
if (cinfo$leftInside) {
edge1x <- extpts1$x + extww1*extopts1$x
edge1y <- extpts1$y + extww1*extopts1$y
edge2x <- extpts2$x + extww2*extopts2$x
edge2y <- extpts2$y + extww2*extopts2$y
n1 <- length(edge1x)
n2 <- length(edge2x)
intersections <- mapply(
function(sx1, sy1, ex1, ey1, sx2, sy2, ex2, ey2) {
intpts <- intersection(sx1, sy1, ex1, ey1, sx2, sy2, ex2, ey2)
onSegment(sx1, sy1, intpts$x, intpts$y, ex1, ey1) &
onSegment(sx2, sy2, intpts$x, intpts$y, ex2, ey2)
},
edge1x[-n1], edge1y[-n1],
edge1x[-1], edge1y[-1],
MoreArgs=list(edge2x[-n2], edge2y[-n2],
edge2x[-1], edge2y[-1]))
if (!any(intersections)) {
## Fall back to "bevel"
corner <- list(extend=FALSE)
} else {
intseg <- which(intersections, arr.ind=TRUE)[1,]
keep1 <- 1:(intseg[2])
keep2 <- 1:(intseg[1])
int <- intersection(edge1x[intseg[2]], edge1y[intseg[2]],
edge1x[intseg[2] + 1], edge1y[intseg[2] + 1],
edge2x[intseg[1]], edge2y[intseg[1]],
edge2x[intseg[1] + 1], edge2y[intseg[1] + 1])
corner <- list(extend=TRUE,
leftInside=TRUE,
x=c(edge1x[keep1], int$x, edge2x[keep2]),
y=c(edge1y[keep1], int$y, edge2y[keep2]))
}
} else {
edge1x <- extpts1$x - extww1*extopts1$x
edge1y <- extpts1$y - extww1*extopts1$y
edge2x <- extpts2$x - extww2*extopts2$x
edge2y <- extpts2$y - extww2*extopts2$y
n1 <- length(edge1x)
n2 <- length(edge2x)
intersections <- mapply(
function(sx1, sy1, ex1, ey1, sx2, sy2, ex2, ey2) {
intpts <- intersection(sx1, sy1, ex1, ey1, sx2, sy2, ex2, ey2)
onSegment(sx1, sy1, intpts$x, intpts$y, ex1, ey1) &
onSegment(sx2, sy2, intpts$x, intpts$y, ex2, ey2)
},
edge1x[-n1], edge1y[-n1],
edge1x[-1], edge1y[-1],
MoreArgs=list(edge2x[-n2], edge2y[-n2],
edge2x[-1], edge2y[-1]))
if (!any(intersections)) {
## Fall back to "bevel"
corner <- list(extend=FALSE)
} else {
intseg <- which(intersections, arr.ind=TRUE)
keep1 <- 1:(intseg[2])
keep2 <- 1:(intseg[1])
int <- intersection(edge1x[intseg[2]], edge1y[intseg[2]],
edge1x[intseg[2] + 1], edge1y[intseg[2] + 1],
edge2x[intseg[1]], edge2y[intseg[1]],
edge2x[intseg[1] + 1], edge2y[intseg[1] + 1])
corner <- list(extend=TRUE,
leftInside=TRUE,
x=c(edge1x[keep1], int$x, edge2x[keep2]),
y=c(edge1y[keep1], int$y, edge2y[keep2]))
}
}
if (grob$debug) {
grid.points(extpts1$x, extpts1$y, default.units="in", pch=".",
gp=gpar(col="black"))
grid.lines(extpts1$x - extww1*extopts1$x, extpts1$y - extww1*extopts1$y,
default.units="in", gp=gpar(col="blue"))
grid.lines(extpts1$x + extww1*extopts1$x, extpts1$y + extww1*extopts1$y,
default.units="in", gp=gpar(col="red"))
grid.points(extpts2$x, extpts2$y, default.units="in", pch=".",
gp=gpar(col="black"))
grid.lines(extpts2$x - extww2*extopts2$x, extpts2$y - extww2*extopts2$y,
default.units="in", gp=gpar(col="blue"))
grid.lines(extpts2$x + extww2*extopts2$x, extpts2$y + extww2*extopts2$y,
default.units="in", gp=gpar(col="red"))
}
corner
}
extendEnds <- function(grob, pts) {
x <- convertX(grob$x, "in", valueOnly=TRUE)
y <- convertY(grob$y, "in", valueOnly=TRUE)
ncurves <- (length(x) - 1) %/% 3
## First Bezier curve
bezFirst <- BezierGrob(x[1:4], y[1:4],
default.units="in",
stepFn=grob$stepFn)
firstPts <- BezierPoints(bezFirst)
firstLengths <- c(0, sqrt(diff(firstPts$x)^2 + diff(firstPts$y)^2))
cumFirstLength <- cumsum(firstLengths)
totalFirstLength <- sum(firstLengths)
## How far to extend end ?
## (if end diverging, we extend by half width at end)
## (otherwise, extend at most by mitrelength)
startWidth <- pts$info$ww[1]*2
startMitreLimit <- startWidth*grob$mitrelimit
startExtend <- calcExtensionT(c(startMitreLimit, startWidth/2),
totalFirstLength)
## Extend end
startpts <- BezierPoints(bezFirst, c(0, -startExtend[1]))
startopts <- BezierNormal(bezFirst, c(0, -startExtend[1]))
## Calculate widths based on main curve length
startWidthExtend <- calcExtensionT(c(startMitreLimit, startWidth/2),
pts$info$totalLength)
startWidths <- resolveWidth(grob$w, pts$info$totalLength,
c(0, -startWidthExtend[1]), fill=FALSE)
## If the width is not negative by this point, fall back to "square" end
if (startWidths$y[length(startWidths$y)] > 0) {
startpts <- BezierPoints(bezFirst, c(0, -startExtend[2]))
startopts <- BezierNormal(bezFirst, c(0, -startExtend[2]))
## Calculate widths based on main curve length
startWidths <- resolveWidth(grob$w, pts$info$totalLength,
c(0, -startWidthExtend[2]), fill=FALSE)
startLengths <- c(0, sqrt(diff(startpts$x)^2 + diff(startpts$y)^2))
cumStartLength <- cumsum(startLengths)
startw <- approx(startWidths$x, startWidths$y,
-cumStartLength, rule=2)$y/2
keep <- cumStartLength <= startWidth/2
startpts$x <- startpts$x[keep]
startpts$y <- startpts$y[keep]
startopts$x <- startopts$x[keep]
startopts$y <- startopts$y[keep]
startw <- startw[keep]
} else {
## Interpolate width at each vertex
## (divide by 2 because width is added to both left and right)
## This interpolation must occur on extended end
startLengths <- c(0, sqrt(diff(startpts$x)^2 + diff(startpts$y)^2))
cumStartLength <- cumsum(startLengths)
## -cumLength because lengths are BEFORE curve start
startw <- approx(startWidths$x, startWidths$y,
-cumStartLength, rule=2)$y/2
keep <- startw >= 0
startpts$x <- startpts$x[keep]
startpts$y <- startpts$y[keep]
startopts$x <- startopts$x[keep]
startopts$y <- startopts$y[keep]
startw <- startw[keep]
}
## Last Bezier curve
n <- length(x)
bezLast <- BezierGrob(x[(n-3):n], y[(n-3):n],
default.units="in",
stepFn=grob$stepFn)
lastPts <- BezierPoints(bezLast)
lastLengths <- c(0, sqrt(diff(lastPts$x)^2 + diff(lastPts$y)^2))
cumLastLength <- cumsum(lastLengths)
totalLastLength <- sum(lastLengths)
## How far to extend end ?
## (if end diverging, we extend by half width at end)
## (otherwise, extend at most by mitrelength)
endWidth <- pts$info$ww[length(pts$info$ww)]*2
endMitreLimit <- endWidth*grob$mitrelimit
endExtend <- calcExtensionT(c(endMitreLimit, endWidth/2),
totalLastLength)
## Extend end
endpts <- BezierPoints(bezLast, c(1, 1 + endExtend[1]))
endopts <- BezierNormal(bezLast, c(1, 1 + endExtend[1]))
## Calculate widths based on main curve length
endWidthExtend <- calcExtensionT(c(endMitreLimit, endWidth/2),
pts$info$totalLength)
endWidths <- resolveWidth(grob$w, pts$info$totalLength,
nWidthCurves(grob$w) + c(0, endWidthExtend[1]),
fill=FALSE)
## If the width is not negative by this point, fall back to "square" end
if (endWidths$y[length(endWidths$y)] > 0) {
endpts <- BezierPoints(bezLast, c(1, 1 + endExtend[2]))
endopts <- BezierNormal(bezLast, c(1, 1 + endExtend[2]))
## Calculate widths based on main curve length
endWidths <- resolveWidth(grob$w, pts$info$totalLength,
nWidthCurves(grob$w) +
c(0, endWidthExtend[2]),
fill=FALSE)
endLengths <- c(0, sqrt(diff(endpts$x)^2 + diff(endpts$y)^2))
cumEndLength <- cumsum(endLengths)
endw <- approx(endWidths$x, endWidths$y,
pts$info$totalLength + cumEndLength, rule=2)$y/2
keep <- cumEndLength <= endWidth/2
endpts$x <- endpts$x[keep]
endpts$y <- endpts$y[keep]
endopts$x <- endopts$x[keep]
endopts$y <- endopts$y[keep]
endw <- endw[keep]
} else {
## Interpolate width at each vertex
## (divide by 2 because width is added to both left and right)
## This interpolation must occur on extended end
endLengths <- c(0, sqrt(diff(endpts$x)^2 + diff(endpts$y)^2))
cumEndLength <- cumsum(endLengths)
## cumLength + totalLength because lengths are AFTER curve end
endw <- approx(endWidths$x, endWidths$y,
pts$info$totalLength + cumEndLength, rule=2)$y/2
keep <- endw >= 0
endpts$x <- endpts$x[keep]
endpts$y <- endpts$y[keep]
endopts$x <- endopts$x[keep]
endopts$y <- endopts$y[keep]
endw <- endw[keep]
}
if (grob$debug) {
grid.points(startpts$x, startpts$y, default.units="in", pch=".",
gp=gpar(col="black"))
grid.lines(startpts$x - startw*startopts$x,
startpts$y - startw*startopts$y,
default.units="in", gp=gpar(col="blue"))
grid.lines(startpts$x + startw*startopts$x,
startpts$y + startw*startopts$y,
default.units="in", gp=gpar(col="red"))
grid.points(endpts$x, endpts$y, default.units="in", pch=".",
gp=gpar(col="black"))
grid.lines(endpts$x - endw*endopts$x, endpts$y - endw*endopts$y,
default.units="in", gp=gpar(col="blue"))
grid.lines(endpts$x + endw*endopts$x, endpts$y + endw*endopts$y,
default.units="in", gp=gpar(col="red"))
}
list(startx=c(startpts$x + startw*startopts$x,
rev(startpts$x - startw*startopts$x)),
starty=c(startpts$y + startw*startopts$y,
rev(startpts$y - startw*startopts$y)),
endx=c(endpts$x - endw*endopts$x,
rev(endpts$x + endw*endopts$x)),
endy=c(endpts$y - endw*endopts$y,
rev(endpts$y + endw*endopts$y)))
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/extend.R
|
## grid.offsetBezier() based on gridBezier::BezierGrob() (not grid::bezierGrob)
offsetBezierEdge <- function(pts1, pts2, w1, w2, opts1, lengths1, lengths2,
i1, i2, grob, widths) {
if (grob$linejoin == "extend" &&
inherits(grob$w, "BezierWidth")) {
## Create a "vwlineGrob" consisting of just end segment of
## one curve and start segment of another
## WITH "bevel" line join
## (which gives us the inside corner and the fall back outside corner)
## and use vwlinePoints() to generate the corner
n1 <- length(pts1$x)
n2 <- length(pts2$x)
## last point of curve 1 is first point of curve 2
vwline <- vwlineGrob(c(pts1$x[n1 - 1], pts2$x[1:2]),
c(pts1$y[n1 - 1], pts2$y[1:2]),
c(w1[n1 - 1], w2[1:2])*2,
default.units="in",
linejoin="bevel",
lineend=grob$lineend,
mitrelimit=grob$mitrelimit,
debug=grob$debug)
pts <- vwlinePoints(vwline)
nl <- length(pts$left$x)
nr <- length(pts$right$x)
if (nl > 4) {
keepl <- -c(1:2, nl-1, nl)
} else {
keepl <- -c(1, nl)
}
if (nr > 4) {
keepr <- -c(1:2, nr-1, nr)
} else {
keepr <- -c(1, nr)
}
## Calculate extended outside corner
extend <- extendJoins(pts1, pts2, w1, w2, opts1, lengths1, lengths2,
i1, i2, grob, widths)
## Add corner to curve 1
## Attempt to avoid duplicating first and last points from corner
## Result from vwlinePoints() has right end going other direction
if (extend$extend) {
if (extend$leftInside) {
list(left=list(x=c(pts1$x - w1*opts1$x, pts$left$x[keepl]),
y=c(pts1$y - w1*opts1$y, pts$left$y[keepl])),
right=list(x=c(pts1$x + w1*opts1$x, extend$x),
y=c(pts1$y + w1*opts1$y, extend$y)))
} else {
list(left=list(x=c(pts1$x - w1*opts1$x, extend$x),
y=c(pts1$y - w1*opts1$y, extend$y)),
right=list(x=c(pts1$x + w1*opts1$x,
rev(pts$right$x[keepr])),
y=c(pts1$y + w1*opts1$y,
rev(pts$right$y[keepr]))))
}
} else {
## Just use the vwlineGrob result
list(left=list(x=c(pts1$x - w1*opts1$x, pts$left$x[keepl]),
y=c(pts1$y - w1*opts1$y, pts$left$y[keepl])),
right=list(x=c(pts1$x + w1*opts1$x, rev(pts$right$x[keepr])),
y=c(pts1$y + w1*opts1$y, rev(pts$right$y[keepr]))))
}
} else {
## Create a "vwlineGrob" consisting of just end segment of
## one curve and start segment of another
## and use vwlinePoints() to generate the corner
n1 <- length(pts1$x)
n2 <- length(pts2$x)
## last point of curve 1 is first point of curve 2
vwline <- vwlineGrob(c(pts1$x[n1 - 1], pts2$x[1:2]),
c(pts1$y[n1 - 1], pts2$y[1:2]),
c(w1[n1 - 1], w2[1:2])*2,
default.units="in",
linejoin=grob$linejoin,
lineend=grob$lineend,
mitrelimit=grob$mitrelimit,
debug=grob$debug)
pts <- vwlinePoints(vwline)
nl <- length(pts$left$x)
nr <- length(pts$right$x)
## Add corner to curve 1
## Attempt to avoid duplicating first and last points from corner
## (but NOT by reducing corner to nothing)
if (nl > 4) {
keepl <- -c(1:2, nl-1, nl)
} else {
keepl <- -c(1, nl)
}
if (nr > 4) {
keepr <- -c(1:2, nr-1, nr)
} else {
keepr <- -c(1, nr)
}
## Result from vwlinePoints() has right end going other direction
list(left=list(x=c(pts1$x - w1*opts1$x, pts$left$x[keepl]),
y=c(pts1$y - w1*opts1$y, pts$left$y[keepl])),
right=list(x=c(pts1$x + w1*opts1$x, rev(pts$right$x[keepr])),
y=c(pts1$y + w1*opts1$y, rev(pts$right$y[keepr]))))
}
}
## Calculate points to the left and right (and middle)
offsetBezierPoints <- function(grob) {
x <- convertX(grob$x, "in", valueOnly=TRUE)
y <- convertY(grob$y, "in", valueOnly=TRUE)
if (!grob$open) {
x <- c(x, x[1])
y <- c(y, y[1])
}
## Break bezier spline into bezier curves
ncurves <- (length(x) - 1) %/% 3
if (ncurves*3 + 1 != length(x))
stop("Invalid number of control points")
index <- lapply(1:ncurves, function(i) ((i-1)*3 + 1):(i*3 + 1))
## Calculate points for each curve
pts <- lapply(index,
function(i) {
BezierPoints(BezierGrob(x[i], y[i],
default.units="in",
stepFn=grob$stepFn))
})
opts <- lapply(index,
function(i) {
BezierNormal(BezierGrob(x[i], y[i], default.units="in",
stepFn=grob$stepFn))
})
ptsIndex <- rep(1:ncurves, sapply(pts, function(p) length(p$x)))
## Run all points together to calculate widths at each point
xx <- unlist(lapply(pts, "[[", "x"))
yy <- unlist(lapply(pts, "[[", "y"))
ox <- unlist(lapply(opts, "[[", "x"))
oy <- unlist(lapply(opts, "[[", "y"))
if (grob$debug) {
## Show flattened path vertices
grid.points(xx, yy, default.units="in", pch=16, size=unit(1, "mm"))
}
## Calculate distances between flattened vertices
lengths <- c(0, sqrt(diff(xx)^2 + diff(yy)^2))
cumLength <- cumsum(lengths)
totalLength <- sum(lengths)
widths <- resolveWidth(grob$w, totalLength)
## Interpolate width at each vertex
## (divide by 2 because width is added to both left and right)
ww <- approx(widths$x, widths$y, cumLength, rule=2)$y/2
## If more than one curve in the spline, we need corners where
## curves meet
if (ncurves > 1) {
## split widths into separate curves
curveWidths <- split(ww, ptsIndex)
curveLengths <- tapply(lengths, ptsIndex, sum, simplify=FALSE)
## If closed, need an extra corner
if (!grob$open) {
pts <- c(pts, pts[1])
opts <- c(opts, opts[1])
curveWidths <- c(curveWidths, curveWidths[1])
curveLengths <- c(curveLengths, curveLengths[1])
index <- c(index, index[1])
ncurves <- ncurves + 1
}
edges <- mapply(offsetBezierEdge,
pts[-ncurves], pts[-1],
curveWidths[-ncurves], curveWidths[-1],
opts[-ncurves],
curveLengths[-ncurves], curveLengths[-1],
index[-ncurves], index[-1],
MoreArgs=list(grob, widths),
SIMPLIFY=FALSE)
## run everything together (including final curve if open)
leftx <- unlist(lapply(edges, function(e) e$left$x))
lefty <- unlist(lapply(edges, function(e) e$left$y))
rightx <- unlist(lapply(edges, function(e) e$right$x))
righty <- unlist(lapply(edges, function(e) e$right$y))
if (grob$open) {
leftx <- c(leftx,
pts[[ncurves]]$x -
curveWidths[[ncurves]]*opts[[ncurves]]$x)
lefty <- c(lefty,
pts[[ncurves]]$y -
curveWidths[[ncurves]]*opts[[ncurves]]$y)
rightx <- c(rightx,
pts[[ncurves]]$x +
curveWidths[[ncurves]]*opts[[ncurves]]$x)
righty <- c(righty,
pts[[ncurves]]$y +
curveWidths[[ncurves]]*opts[[ncurves]]$y)
}
list(mid=list(x=xx, y=yy),
left=list(x=leftx, y=lefty),
right=list(x=rightx, y=righty),
info=list(lengths=lengths, cumLength=cumLength,
totalLength=totalLength, ww=ww))
} else {
list(mid=list(x=xx, y=yy),
left=list(x=xx - ww*ox,
y=yy - ww*oy),
right=list(x=xx + ww*ox,
y=yy + ww*oy),
info=list(lengths=lengths, cumLength=cumLength,
totalLength=totalLength, ww=ww))
}
}
## Build complete outline by adding ends (and joins if necessary)
offsetBezierOutline <- function(grob, simplify=TRUE) {
pts <- offsetBezierPoints(grob)
if (grob$open) {
if (grob$lineend == "extend" &&
inherits(grob$w, "BezierWidth")) {
ends <- extendEnds(grob, pts)
outline <- list(x=c(ends$startx, pts$left$x,
ends$endx, rev(pts$right$x)),
y=c(ends$starty, pts$left$y,
ends$endy, rev(pts$right$y)))
} else {
seg <- generateSegment(pts$mid$x[1], pts$mid$y[1],
pts$left$x[1:2], pts$left$y[1:2],
pts$right$x[1:2], pts$right$y[1:2],
grob$debug)
sinfo <- segInfo(seg$x, seg$y, seg$w, TRUE, FALSE, grob$debug)
einfo <- endInfo(seg$x, seg$y, seg$w, sinfo, FALSE, grob$debug)
earcinfo <- endArcInfo(sinfo, einfo, grob$debug)
start <- buildEnds(seg$w, einfo, earcinfo, FALSE,
grob$lineend, grob$mitrelimit)
NM <- length(pts$mid$x)
NL <- length(pts$left$x)
NR <- length(pts$right$x)
seg <- generateSegment(pts$mid$x[NM], pts$mid$y[NM],
pts$right$x[NR:(NR-1)],
pts$right$y[NR:(NR-1)],
pts$left$x[NL:(NL-1)],
pts$left$y[NL:(NL-1)],
grob$debug)
sinfo <- segInfo(seg$x, seg$y, seg$w, TRUE, FALSE, grob$debug)
einfo <- endInfo(seg$x, seg$y, seg$w, sinfo, FALSE, grob$debug)
earcinfo <- endArcInfo(sinfo, einfo, grob$debug)
end <- buildEnds(seg$w, einfo, earcinfo, FALSE,
grob$lineend, grob$mitrelimit)
outline <- list(x=c(start$startx, pts$left$x,
end$startx, rev(pts$right$x)),
y=c(start$starty, pts$left$y,
end$starty, rev(pts$right$y)))
}
} else {
outline <- list(pts$left, lapply(pts$right, rev))
}
if (simplify)
polysimplify(outline, filltype="nonzero")
else
outline
}
edgePoints.offsetBezierGrob <- function(x, d,
x0, y0,
which=1,
direction="forward",
debug=FALSE,
...) {
## Silently force which to length 1
which <- which[1]
outline <- offsetBezierOutline(x)
## outline is list of outlines
if (which > length(outline)) {
stop("Invalid which value")
}
edge <- outline[[which]]
if (!is.unit(x0)) x0 <- unit(x0, "npc")
if (!is.unit(y0)) y0 <- unit(y0, "npc")
pts <- reorderEdge(edge, x0, y0)
vwEdgePoints(pts, d, direction == "forward", x$open, debug)
}
makeContent.offsetBezierGrob <- function(x, ...) {
outline <- offsetBezierOutline(x)
addGrob(x,
x$render(unlist(lapply(outline, "[[", "x")),
unlist(lapply(outline, "[[", "y")),
sapply(outline, function(o) length(o$x)),
x$gp, "outline"))
}
checkoffsetBezier <- function(x, y, w) {
if (max(length(x), length(y)) < 4)
stop("An offsetBezier must have at least four points")
nx <- length(x)
ny <- length(y)
if (nx != ny) {
stop("x and y must have same length")
}
}
offsetBezierGrob <- function(x, y, w, default.units="npc",
stepFn=nSteps(100), open=TRUE,
lineend="butt", linejoin="round", mitrelimit=4,
render=if (open) vwPolygon else vwPath(),
gp=gpar(fill="black"), name=NULL, debug=FALSE) {
checkoffsetBezier(x, y, w)
if (!is.unit(x)) {
x <- unit(x, default.units)
}
if (!is.unit(y)) {
y <- unit(y, default.units)
}
if (!inherits(w, "widthSpline") && !inherits(w, "BezierWidth")) {
w <- widthSpline(w, default.units)
}
gTree(x=x, y=y, w=w, stepFn=stepFn, open=open, render=render,
lineend=lineend, linejoin=linejoin, mitrelimit=mitrelimit,
gp=gp, name=name, cl="offsetBezierGrob",
debug=debug)
}
grid.offsetBezier <- function(...) {
grid.draw(offsetBezierGrob(...))
}
edgePoints.offsetBezierGrob <- function(x, d,
x0, y0,
which=1,
direction="forward",
debug=FALSE,
...) {
## Silently force which to length 1
which <- which[1]
outline <- offsetBezierOutline(x)
## outline is list of outlines
if (which > length(outline)) {
stop("Invalid which value")
}
edge <- outline[[which]]
if (!is.unit(x0)) x0 <- unit(x0, "npc")
if (!is.unit(y0)) y0 <- unit(y0, "npc")
pts <- reorderEdge(edge, x0, y0)
vwEdgePoints(pts, d, direction == "forward", x$open, debug)
}
outline.offsetBezierGrob <- function(x, simplify=TRUE, ...) {
offsetBezierOutline(x, simplify=simplify)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/offsetbezier.R
|
## Draw a line with variable width by calculating an offset curve
## for an X-spline
grid.offsetXspline <- function(...) {
grid.draw(offsetXsplineGrob(...))
}
## IF open=FALSE, endShape and endWidth are IGNORED
offsetXsplineGrob <- function(x, y, w, default.units="npc", shape=1,
open=TRUE, repEnds=TRUE,
lineend="butt", mitrelimit=4,
render=if (open) vwPolygon else vwPath(),
gp=gpar(fill="black"), name=NULL, debug=FALSE) {
checkoffsetXspline(x, y, w)
if (!is.unit(x)) {
x <- unit(x, default.units)
}
if (!is.unit(y)) {
y <- unit(y, default.units)
}
if (!inherits(w, "widthSpline") && !inherits(w, "BezierWidth")) {
w <- widthSpline(w, default.units)
}
gTree(x=x, y=y, w=w, open=open, repEnds=repEnds, render=render, shape=shape,
lineend=lineend, mitrelimit=mitrelimit,
gp=gp, name=name, cl="offsetXsplineGrob",
debug=debug)
}
checkoffsetXspline <- function(x, y, w) {
if (max(length(x), length(y)) < 2)
stop("An offsetXspline must have at least two points")
nx <- length(x)
ny <- length(y)
if (nx != ny) {
stop("x and y must have same length")
}
}
## Calculate points to the left and to the right
offsetXsplinePoints <- function(grob) {
x <- convertX(grob$x, "in", valueOnly=TRUE)
y <- convertY(grob$y, "in", valueOnly=TRUE)
## Flatten curve
pts <- xspline(x, y, grob$shape, grob$open,
grob$repEnds, xsplineFun=xsplinePts)
if (grob$open && is.logical(grob$repEnds) && grob$repEnds) {
## Drop first/last points (because first/last offsets will be NaN)
npts <- length(pts$x)
pts <- list(x=pts$x[-c(1, npts)], y=pts$y[-c(1, npts)])
}
## Pts are in inches
xx <- pts$x
yy <- pts$y
N <- length(xx)
if (grob$debug) {
## Show flattened path vertices
grid.points(xx, yy, default.units="in", pch=16, size=unit(1, "mm"))
}
## Calculate distances between flattened vertices
lengths <- c(0, sqrt(diff(xx)^2 + diff(yy)^2))
cumLength <- cumsum(lengths)
totalLength <- sum(lengths)
widths <- resolveWidth(grob$w, totalLength)
## Interpolate width at each vertex
## (divide by 2 because width is added to both left and right)
ww <- approx(widths$x, widths$y, cumLength, rule=2)$y/2
opts <- xspline(x, y, grob$shape, grob$open, grob$repEnds,
xsplineFun=xsplineOffsets)
if (grob$open && is.logical(grob$repEnds) && grob$repEnds) {
## Drop first/last points (because first/last offsets will be NaN)
opts <- list(x=opts$x[-c(1, npts)], y=opts$y[-c(1, npts)])
}
list(mid=pts,
left=list(x=pts$x - ww*opts$x,
y=pts$y - ww*opts$y),
right=list(x=pts$x + ww*opts$x,
y=pts$y + ww*opts$y))
}
offsetXsplineOutline <- function(grob, simplify=TRUE) {
pts <- offsetXsplinePoints(grob)
pts <- lapply(pts, function(x) lapply(x, function(y) y[is.finite(y)]))
if (grob$open) {
seg <- generateSegment(pts$mid$x[1], pts$mid$y[1],
pts$left$x[1:2], pts$left$y[1:2],
pts$right$x[1:2], pts$right$y[1:2],
grob$debug)
sinfo <- segInfo(seg$x, seg$y, seg$w, TRUE, FALSE, grob$debug)
einfo <- endInfo(seg$x, seg$y, seg$w, sinfo, FALSE, grob$debug)
earcinfo <- endArcInfo(sinfo, einfo, grob$debug)
start <- buildEnds(seg$w, einfo, earcinfo, FALSE,
grob$lineend, grob$mitrelimit)
N <- length(pts$left$x)
seg <- generateSegment(pts$mid$x[N], pts$mid$y[N],
pts$right$x[N:(N-1)], pts$right$y[N:(N-1)],
pts$left$x[N:(N-1)], pts$left$y[N:(N-1)],
grob$debug)
sinfo <- segInfo(seg$x, seg$y, seg$w, TRUE, FALSE, grob$debug)
einfo <- endInfo(seg$x, seg$y, seg$w, sinfo, FALSE, grob$debug)
earcinfo <- endArcInfo(sinfo, einfo, grob$debug)
end <- buildEnds(seg$w, einfo, earcinfo, FALSE,
grob$lineend, grob$mitrelimit)
outline <- list(x=c(start$startx, pts$left$x,
end$startx, rev(pts$right$x)),
y=c(start$starty, pts$left$y,
end$starty, rev(pts$right$y)))
} else {
outline <- list(pts$left, lapply(pts$right, rev))
}
if (simplify)
polysimplify(outline, filltype="nonzero")
else
outline
}
makeContent.offsetXsplineGrob <- function(x, ...) {
outline <- offsetXsplineOutline(x)
## outline is list of outlines
addGrob(x,
x$render(unlist(lapply(outline, "[[", "x")),
unlist(lapply(outline, "[[", "y")),
sapply(outline, function(o) length(o$x)),
x$gp, "outline"))
}
edgePoints.offsetXsplineGrob <- function(x, d,
x0, y0,
which=1,
direction="forward",
debug=FALSE,
...) {
## Silently force which to length 1
which <- which[1]
outline <- offsetXsplineOutline(x)
## outline is list of outlines
if (which > length(outline)) {
stop("Invalid which value")
}
edge <- outline[[which]]
if (!is.unit(x0)) x0 <- unit(x0, "npc")
if (!is.unit(y0)) y0 <- unit(y0, "npc")
pts <- reorderEdge(edge, x0, y0)
vwEdgePoints(pts, d, direction == "forward", x$open, debug)
}
outline.offsetXsplineGrob <- function(x, simplify=TRUE, ...) {
offsetXsplineOutline(x, simplify=simplify)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/offsetxspline.R
|
## Generic interface for returning points that make up the boundary
## of a curve
## Different from edgePoints() (and simpler) because it returns all points
## on outline
## AND it will allow "unsimplified" outline
## The result is a list of (x, y) lists
## 'x' is the curve object
## 'simplify' says whether to simplify
outline <- function(x, simplify=TRUE, ...) {
UseMethod("outline")
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/outline.R
|
################################################################################
## Functions for rendering vw* object outlines
vwPolygon <- function(x, y, id.lengths, gp, name) {
polygonGrob(x, y, default.units="in",
id.lengths=id.lengths, gp=gp, name=name)
}
vwPath <- function(rule="winding") {
function(x, y, id.lengths, gp, name) {
pathGrob(x, y, default.units="in",
id.lengths=id.lengths, rule=rule, gp=gp, name=name)
}
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/render.R
|
################################################################################
## Angles of lines
## x and y are vectors of length 2
angle <- function(x, y) {
atan2(y[2] - y[1], x[2] - x[1])
}
## x and y are vectors of length 3
avgangle <- function(x, y) {
a1 <- angle(x[1:2], y[1:2])
a2 <- angle(x[2:3], y[2:3])
atan2(sin(a1) + sin(a2), cos(a1) + cos(a2))
}
## extend direction from pt 1 to pt 2
extend <- function(x, y, angle, d) {
list(x=x + d*cos(angle),
y=y + d*sin(angle))
}
## x and y are vectors; ends defines subset of length 2
perp <- function(x, y, len, a, mid) {
dx <- len*cos(a + pi/2)
dy <- len*sin(a + pi/2)
upper <- c(x[mid] + dx, y[mid] + dy)
lower <- c(x[mid] - dx, y[mid] - dy)
rbind(upper, lower)
}
## x and y are vectors of length 2
perpStart <- function(x, y, len) {
perp(x, y, len, angle(x, y), 1)
}
perpEnd <- function(x, y, len) {
perp(x, y, len, angle(x, y), 2)
}
## x and y are vectors of length 3
## We want the "average" angle at the middle point
perpMid <- function(x, y, len) {
## Now determine angle at midpoint
perp(x, y, len, avgangle(x, y), 2)
}
## x and y and len are vectors of any length
offset <- function(x, y, len, a) {
dx <- len*cos(a)
dy <- len*sin(a)
upper <- c(x + dx, y + dy)
lower <- c(x - dx, y - dy)
list(left=list(x=x + dx, y=y + dy),
right=list(x=x - dx, y=y - dy))
}
dist <- function(dx, dy) {
sqrt(dx^2 + dy^2)
}
angleInRange <- function(x) {
while (any(x < -pi)) {
toolow <- x < -pi
x[toolow] <- x[toolow] + 2*pi
}
while (any(x > pi)) {
toohigh <- x > pi
x[toohigh] <- x[toohigh] - 2*pi
}
x
}
angleDiff <- function(a1, a2, clockwise, debug=FALSE) {
if (clockwise) {
result <- ifelse(a1 > a2, -(a1 - a2), -((a1 + pi) + (pi - a2)))
} else {
result <- ifelse(a1 < a2, a2 - a1, (pi - a1) + (a2 + pi))
}
if (debug) {
grid.newpage()
pushViewport(viewport(width=.9, height=.9,
xscale=c(-1, 1), yscale=c(-1, 1)))
grid.segments(0, .5, 1, .5)
grid.segments(.5, 0, .5, 1)
grid.segments(0, 0, cos(a1), sin(a1), default.units="native",
gp=gpar(lwd=3), arrow=arrow())
grid.text("a1", 1.05*cos(a1), 1.05*sin(a1), default.units="native")
grid.segments(0, 0, cos(a2), sin(a2), default.units="native",
gp=gpar(lwd=3), arrow=arrow())
grid.text("a2", 1.05*cos(a2), 1.05*sin(a2), default.units="native")
t <- seq(a1, a1 + result, length.out=100)
grid.polygon(c(0, .5*cos(t)), c(0, .5*sin(t)), default.units="native",
gp=gpar(fill="grey"))
grid.text(if (clockwise) "clockwise" else "anticlockwise",
.25*cos(a1 + .5*result), .25*sin(a1 + .5*result),
default.units="native")
popViewport()
}
result
}
angleSeq <- function(a1, a2, len, clockwise, debug=FALSE) {
adiff <- angleDiff(a1, a2, clockwise)
result <- seq(a1, a1 + adiff, length.out=len)
if (debug) {
grid.newpage()
pushViewport(viewport(width=.9, height=.9,
xscale=c(-1, 1), yscale=c(-1, 1)))
grid.segments(0, .5, 1, .5)
grid.segments(.5, 0, .5, 1)
grid.segments(0, 0, cos(a1), sin(a1), default.units="native",
gp=gpar(lwd=3), arrow=arrow())
grid.text("a1", 1.05*cos(a1), 1.05*sin(a1), default.units="native")
grid.segments(0, 0, cos(a2), sin(a2), default.units="native",
gp=gpar(lwd=3), arrow=arrow())
grid.text("a2", 1.05*cos(a2), 1.05*sin(a2), default.units="native")
grid.lines(.5*cos(result), .5*sin(result), default.units="native",
arrow=arrow())
grid.text(if (clockwise) "clockwise" else "anticlockwise",
.25*cos(a1 + .5*adiff), .25*sin(a1 + .5*adiff),
default.units="native")
popViewport()
}
result
}
################################################################################
## Intersections of line segments
## Following
## http://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/
## Given three colinear points start, pt, end the function checks if
## pt lies on line segment start->end
onSegment <- function(startx, starty, ptx, pty, endx, endy) {
rptx <- round(ptx, 10)
rpty <- round(pty, 10)
rsx <- round(startx, 10)
rsy <- round(starty, 10)
rex <- round(endx, 10)
rey <- round(endy, 10)
rptx <= pmax(rsx, rex) & rptx >= pmin(rsx, rex) &
rpty <= pmax(rsy, rey) & rpty >= pmin(rsy, rey)
}
## To find orientation of ordered triplet (start, end, pt).
## The function returns following values
## 0 --> start, end and pt are colinear
## 1 --> Clockwise
## 2 --> Counterclockwise
orientation <- function(startx, starty, endx, endy, ptx, pty) {
val = (endy - starty) * (ptx - endx) - (endx - startx) * (pty - endy);
ifelse(val == 0, 0, ifelse(val > 0, 1, 2))
}
## The main function that returns true if line segment start1->end1
## and start2->end2 intersect.
doIntersect <- function(start1x, start1y, end1x, end1y,
start2x, start2y, end2x, end2y,
debug=FALSE) {
## Find the four orientations needed for general and special cases
o1 <- orientation(start1x, start1y, end1x, end1y, start2x, start2y);
o2 <- orientation(start1x, start1y, end1x, end1y, end2x, end2y);
o3 <- orientation(start2x, start2y, end2x, end2y, start1x, start1y);
o4 <- orientation(start2x, start2y, end2x, end2y, end1x, end1y);
if (debug) {
pts(c(start1x, end1x, start2x, end2x),
c(start1y, end1y, start2y, end2y))
segs(c(start1x, start2x), c(start1y, start2y),
c(end1x, end2x), c(end1y, end2y))
}
(o1 != o2 & o3 != o4) |
(o1 == 0 &
onSegment(start1x, start1y, start2x, start2y, end1x, end1y)) |
(o2 == 0 &
onSegment(start1x, start1y, end2x, end2y, end1x, end1y)) |
(o3 == 0 &
onSegment(start2x, start2y, start1x, start1y, end2x, end2y)) |
(o4 == 0 & onSegment(start2x, start2y, end1x, end1y, end2x, end2y))
}
################################################################################
## Intersections of line segments (take 2)
## Following J. O'Rourke. Computational Geometry in C. Cambridge University Press, New York, 1994.
## ALL input coordinates are INTEGER
Area2 <- function(ax, ay, bx, by, cx, cy) {
(bx - ax)*(cy - ay) - (cx - ax)*(by - ay)
}
Collinear <- function(ax, ay, bx, by, cx, cy) {
Area2(ax, ay, bx, by, cx, cy) == 0
}
Between <- function(ax, ay, bx, by, cx, cy) {
ifelse(ax != bx,
(ax <= cx & cx <= bx) | (ax >= cx & cx >= bx),
(ay <= cy & cy <= by) | (ay >= cy & cy >= by))
}
ParallelInt <- function(ax, ay, bx, by, cx, cy, dx, dy) {
Cabc <- Collinear(ax, ay, bx, by, cx, cy)
Babc <- Between(ax, ay, bx, by, cx, cy)
Babd <- Between(ax, ay, bx, by, dx, dy)
Bcda <- Between(cx, cy, dx, dy, ax, ay)
Bcdb <- Between(cx, cy, dx, dy, bx, by)
## Extension (for non-overlap)
Badb <- Between(ax, ay, dx, dy, bx, by)
Badc <- Between(ax, ay, dx, dy, cx, cy)
Bbda <- Between(bx, by, dx, dy, ax, ay)
Bbdc <- Between(bx, by, dx, dy, cx, cy)
Bacb <- Between(ax, ay, cx, cy, bx, by)
Bacd <- Between(ax, ay, cx, cy, dx, dy)
Bbca <- Between(bx, by, cx, cy, ax, ay)
Bbcd <- Between(bx, by, cx, cy, dx, dy)
## x <- ifelse(!Cabc, NA, ifelse(Babc, cx, ifelse(Babd, dx, ifelse(Bcda, ax, ifelse(Bcdb, bx, NA)))))
## y <- ifelse(!Cabc, NA, ifelse(Babc, cy, ifelse(Babd, dy, ifelse(Bcda, ay, ifelse(Bcdb, by, NA)))))
x <- ifelse(!Cabc, NA,
ifelse(Babc & Babd, (cx + dx)/2,
ifelse(Bcda & Bcdb, (ax + bx)/2,
ifelse(Babc & Bcdb, (bx + cx)/2,
ifelse(Babc & Bcda, (ax + cx)/2,
ifelse(Babd & Bcdb, (bx + dx)/2,
ifelse(Babd & Bcda, (ax + dx)/2,
## Extension (for non-overlap)
ifelse(Badb & Babc, (bx + cx)/2,
ifelse(Bbda & Bbdc, (ax + cx)/2,
ifelse(Bacb & Bacd, (bx + dx)/2,
ifelse(Bbca & Bbcd, (ax + dx)/2, NA)))))))))))
y <- ifelse(!Cabc, NA,
ifelse(Babc & Babd, (cy + dy)/2,
ifelse(Bcda & Bcdb, (ay + by)/2,
ifelse(Babc & Bcdb, (by + cy)/2,
ifelse(Babc & Bcda, (ay + cy)/2,
ifelse(Babd & Bcdb, (by + dy)/2,
ifelse(Babd & Bcda, (ay + dy)/2,
## Extension (for non-overlap)
ifelse(Badb & Babc, (by + cy)/2,
ifelse(Bbda & Bbdc, (ay + cy)/2,
ifelse(Bacb & Bacd, (by + dy)/2,
ifelse(Bbca & Bbcd, (ay + dy)/2, NA)))))))))))
list(x=x, y=y)
}
SegSegInt <- function(ax, ay, bx, by, cx, cy, dx, dy) {
denom <- ax*(dy - cy) + bx*(cy - dy) + dx*(by - ay) + cx*(ay - by)
num1 <- ax*(dy - cy) + cx*(ay - dy) + dx*(cy - ay)
s <- num1/denom
px <- ax + s*(bx - ax)
py <- ay + s*(by - ay)
paraInt <- ParallelInt(ax, ay, bx, by, cx, cy, dx, dy)
x <- ifelse(denom == 0, paraInt$x, px)
y <- ifelse(denom == 0, paraInt$y, py)
list(x=x, y=y)
}
## We are dealing in INCHES, so 1e-6 means a millionth of an inch
intersection <- function(start1x, start1y, end1x, end1y,
start2x, start2y, end2x, end2y,
eps=1e-6, debug=FALSE) {
int <- SegSegInt(round(start1x/eps), round(start1y/eps),
round(end1x/eps), round(end1y/eps),
round(start2x/eps), round(start2y/eps),
round(end2x/eps), round(end2y/eps))
if (debug) {
pts(c(start1x, end1x, start2x, end2x),
c(start1y, end1y, start2y, end2y))
segs(c(start1x, start2x), c(start1y, start2y),
c(end1x, end2x), c(end1y, end2y))
pts(int$x*eps, int$y*eps, "red")
}
list(x=int$x*eps, y=int$y*eps)
}
notrun <- function() {
testIntersect <- function(ax, ay, bx, by, cx, cy, dx, dy, x, y) {
pushViewport(viewport(x=unit(x - .5, "in"),
y=unit(y - .5, "in"),
just=c("left", "bottom"),
width=unit(2, "in"), height=unit(2, "in")))
int <- intersection(ax, ay, bx, by, cx, cy, dx, dy, debug=TRUE)
popViewport()
int
}
grid.newpage()
testIntersect(1, 1, 2, 2, 1, 2, 2, 1, 0, 0)
testIntersect(1, 1, 2, 2, 1.5, 1.5, 2.5, 2.5, 2, 0)
testIntersect(1, 1, 2, 2, 1.5, 1, 2.5, 2, 4, 0)
testIntersect(1.5, 1, 1.5, 2, 1, 1.5, 2, 1.5, 0, 2)
testIntersect(1.5, 1, 1.5, 2, 1.5, 1.5, 1.5, 2.5, 2, 2)
testIntersect(1, 1.5, 2, 1.5, 1.5, 1.5, 2.5, 1.5, 4, 2)
}
################################################################################
## 2D transformations
translation <- function(tx, ty) {
m <- diag(1, 3, 3)
m[1, 3] <- tx
m[2, 3] <- ty
m
}
scaling <- function(sx, sy) {
m <- diag(1, 3, 3)
m[1, 1] <- sx
m[2, 2] <- sy
m
}
rotation <- function(angle) {
sa <- sin(angle)
ca <- cos(angle)
m <- diag(1, 3, 3)
m[1, 1] <- ca
m[1, 2] <- -sa
m[2, 1] <- sa
m[2, 2] <- ca
m
}
transformation <- function(transformations) {
Reduce("%*%", transformations)
}
transform <- function(obj, transformation) {
result <- transformation %*% rbind(obj$x, obj$y, 1)
list(x=result[1,], y=result[2,])
}
################################################################################
## Interpolate points on a (flattened) path (x, y),
## given distance (d) along the path
## and lengths of each path segment
## (ALL in inches)
## Return a new path, with new points included
## The algorithm below could SURELY be improved!
fortifyPath <- function(x, y, d, lengths, open, tol=.01) {
cumLength <- cumsum(lengths)
N <- length(x)
if (open) {
xx <- as.list(x)[-N]
yy <- as.list(y)[-N]
loopEnd <- N - 1
} else {
xx <- as.list(x)
yy <- as.list(y)
x <- c(x, x[1])
y <- c(y, y[1])
loopEnd <- N
}
distIndex <- 1
lastDist <- 0
## For each segment START point
for (i in 1:loopEnd) {
while (d[distIndex] <= cumLength[i + 1] &&
distIndex < length(d) + 1) {
thisDist <- d[distIndex]
dist1 <- thisDist - cumLength[i]
dist2 <- cumLength[i+1] - thisDist
if (dist1 > tol && dist2 > tol &&
(thisDist - lastDist) > tol) {
newx <- x[i] + dist1/lengths[i + 1]*
(x[i + 1] - x[i])
xx[[i]] <- c(xx[[i]], newx)
newy <- y[i] + dist1/lengths[i + 1]*
(y[i + 1] - y[i])
yy[[i]] <- c(yy[[i]], newy)
lastDist <- thisDist
}
distIndex <- distIndex + 1
}
}
if (open) {
list(x=c(unlist(xx), x[N]), y=c(unlist(yy), y[N]))
} else {
list(x=unlist(xx), y=unlist(yy))
}
}
## Calculate points on a (flattened) path (x, y),
## given distance (d) along the path
## and lengths of each path segment
## (ALL in inches)
interpPath <- function(x, y, d, lengths, open) {
cumLength <- cumsum(lengths)
N <- length(x)
if (open) {
loopEnd <- N - 1
} else {
x <- c(x, x[1])
y <- c(y, y[1])
loopEnd <- N
}
xx <- numeric(length(d))
yy <- numeric(length(d))
a <- numeric(length(d))
di <- 1
## For each segment START point
for (i in 1:loopEnd) {
while (d[di] <= cumLength[i + 1] &&
di < length(d) + 1) {
dist <- d[di] - cumLength[i]
xx[di] <- x[i] + dist/lengths[i + 1]*
(x[i + 1] - x[i])
yy[di] <- y[i] + dist/lengths[i + 1]*
(y[i + 1] - y[i])
a[di] <- angle(x[i:(i+1)], y[i:(i+1)])
di <- di + 1
}
}
list(x=xx, y=yy, angle=a)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/utils.R
|
## Draw a line with variable width by just generating
## points either side of x/y and then joining them up
grid.vwcurve <- function(...) {
grid.draw(vwcurveGrob(...))
}
## IF open=FALSE, endShape and endWidth are IGNORED
vwcurveGrob <- function(x, y, w, default.units="npc", open=TRUE, angle="perp",
lineend="butt", mitrelimit=4,
render=if (open) vwPolygon else vwPath(),
gp=gpar(fill="black"), name=NULL, debug=FALSE) {
## Ok to recycle x or y or w
maxlen <- max(length(x), length(y), length(w))
if (length(x) < maxlen)
x <- rep(x, length.out=maxlen)
if (length(y) < maxlen)
y <- rep(y, length.out=maxlen)
if (length(w) < maxlen)
w <- rep(w, length.out=maxlen)
checkvwcurve(x, y, w)
if (!is.unit(x)) {
x <- unit(x, default.units)
}
if (!is.unit(y)) {
y <- unit(y, default.units)
}
if (!is.unit(w)) {
w <- unit(w, default.units)
}
gTree(x=x, y=y, w=w, open=open, render=render, angle=angle,
lineend=lineend, mitrelimit=mitrelimit,
gp=gp, name=name, cl="vwcurveGrob",
debug=debug)
}
checkvwcurve <- function(x, y, w) {
if (max(length(x), length(y), length(w)) < 2)
stop("A vwcurve must have at least two points")
nx <- length(x)
ny <- length(y)
nw <- length(w)
if (nx != ny || nx != nw) {
stop("x, y, and w must all have same length")
}
}
## Calculate points to the left and to the right
vwcurvePoints <- function(grob) {
N <- length(grob$x)
x <- convertX(grob$x, "in", valueOnly=TRUE)
y <- convertY(grob$y, "in", valueOnly=TRUE)
w <- pmin(convertWidth(grob$w, "in", valueOnly=TRUE),
convertHeight(grob$w, "in", valueOnly=TRUE))
## fixed angle is simple
if (is.numeric(grob$angle)) {
offset(x, y, w/2, grob$angle)
} else { # should be "perp" but anything will do
leftx <- numeric(N)
lefty <- numeric(N)
rightx <- numeric(N)
righty <- numeric(N)
midx <- numeric(N)
midy <- numeric(N)
## First point
if (grob$open) {
perps <- perpStart(x[1:2], y[1:2], w[1]/2)
leftx[1] <- perps[1, 1]
lefty[1] <- perps[1, 2]
rightx[1] <- perps[2, 1]
righty[1] <- perps[2, 2]
} else {
seq <- c(N, 1:2)
perps <- perpMid(as.numeric(x[seq]), as.numeric(y[seq]), w[1]/2)
leftx[1] <- perps[1, 1]
lefty[1] <- perps[1, 2]
rightx[1] <- perps[2, 1]
righty[1] <- perps[2, 2]
}
if (N > 2) {
## All but first and last points
for (i in 2:(N - 1)) {
seq <- (i - 1):(i + 1)
perps <- perpMid(as.numeric(x[seq]), as.numeric(y[seq]), w[i]/2)
leftx[i] <- perps[1, 1]
lefty[i] <- perps[1, 2]
rightx[i] <- perps[2, 1]
righty[i] <- perps[2, 2]
}
}
## Last point
if (grob$open) {
perps <- perpEnd(x[(N-1):N], y[(N-1):N], w[N]/2)
leftx[N] <- perps[1, 1]
lefty[N] <- perps[1, 2]
rightx[N] <- perps[2, 1]
righty[N] <- perps[2, 2]
} else {
seq <- c(N - 1, N, 1)
perps <- perpMid(as.numeric(x[seq]), as.numeric(y[seq]), w[N]/2)
leftx[N] <- perps[1, 1]
lefty[N] <- perps[1, 2]
rightx[N] <- perps[2, 1]
righty[N] <- perps[2, 2]
}
list(left=list(x=leftx, y=lefty),
right=list(x=rightx, y=righty))
}
}
vwcurveOutline <- function(grob) {
pts <- vwcurvePoints(grob)
if (grob$open) {
x <- convertX(grob$x[1], "in", valueOnly=TRUE)
y <- convertY(grob$y[1], "in", valueOnly=TRUE)
seg <- generateSegment(x, y,
pts$left$x[1:2], pts$left$y[1:2],
pts$right$x[1:2], pts$right$y[1:2],
grob$debug)
sinfo <- segInfo(seg$x, seg$y, seg$w, TRUE, FALSE, grob$debug)
einfo <- endInfo(seg$x, seg$y, seg$w, sinfo, FALSE, grob$debug)
earcinfo <- endArcInfo(sinfo, einfo, grob$debug)
start <- buildEnds(seg$w, einfo, earcinfo, FALSE,
grob$lineend, grob$mitrelimit)
N <- length(grob$x)
x <- convertX(grob$x[N], "in", valueOnly=TRUE)
y <- convertY(grob$y[N], "in", valueOnly=TRUE)
seg <- generateSegment(x, y,
pts$right$x[N:(N-1)], pts$right$y[N:(N-1)],
pts$left$x[N:(N-1)], pts$left$y[N:(N-1)],
grob$debug)
sinfo <- segInfo(seg$x, seg$y, seg$w, TRUE, FALSE, grob$debug)
einfo <- endInfo(seg$x, seg$y, seg$w, sinfo, FALSE, grob$debug)
earcinfo <- endArcInfo(sinfo, einfo, grob$debug)
end <- buildEnds(seg$w, einfo, earcinfo, FALSE,
grob$lineend, grob$mitrelimit)
list(x=c(start$startx, pts$left$x, end$startx, rev(pts$right$x)),
y=c(start$starty, pts$left$y, end$starty, rev(pts$right$y)),
id.lengths=sum(length(start$startx), length(pts$left$x),
length(end$startx), length(pts$right$x)))
} else {
list(x=c(pts$left$x, rev(pts$right$x)),
y=c(pts$left$y, rev(pts$right$y)),
id.lengths=c(length(pts$left$x), length(pts$right$x)))
}
}
makeContent.vwcurveGrob <- function(x, ...) {
outline <- vwcurveOutline(x)
addGrob(x,
x$render(outline$x, outline$y, outline$id.lengths, x$gp,
"outline"))
}
edgePoints.vwcurveGrob <- function(x, d,
which=c("left", "right"),
direction="forward",
debug=FALSE,
...) {
pts <- vwcurvePoints(x)
result <- list(left=NULL, right=NULL)
if ("left" %in% which) {
result$left=vwEdgePoints(pts$left, d, direction == "forward",
x$open, debug)
}
if ("right" %in% which) {
result$right=vwEdgePoints(pts$right, d, direction == "forward",
x$open, debug)
}
result
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/vwcurve.R
|
## Draw a line with variable width by generating line segments with
## specified width and then adding corner joins and line ends
grid.vwline <- function(...) {
grid.draw(vwlineGrob(...))
}
## IF open=FALSE, endShape and endWidth are IGNORED
vwlineGrob <- function(x, y, w, default.units="npc", open=TRUE,
linejoin="round", lineend="butt", mitrelimit=4,
stepWidth=FALSE,
render=if (open) vwPolygon else vwPath(),
gp=gpar(fill="black"), name=NULL, debug=FALSE) {
if (!is.unit(x)) {
x <- unit(x, default.units)
}
if (!is.unit(y)) {
y <- unit(y, default.units)
}
if (!inherits(w, "widthSpec")) {
w <- widthSpec(w, default.units)
}
checkvwline(x, y, w)
gTree(x=x, y=y, w=w, open=open, render=render,
linejoin=linejoin, lineend=lineend, mitrelimit=mitrelimit,
stepWidth=stepWidth,
gp=gp, name=name, cl="vwlineGrob",
debug=debug)
}
checkvwline <- function(x, y, w) {
if (max(length(x), length(y), length(w)) < 2)
stop("A vwline must have at least two points")
nx <- length(x)
ny <- length(y)
nw <- length(w)
if (nx != ny || nx != nw) {
stop("x, y, and w must all have same length")
}
}
buildEdge <- function(join,
perpStart, perpEnd, inside, mitrelen, mitrelimit,
intpt1, intpt2, arc, linejoin, leftedge) {
N <- length(perpStart)
x <- vector("list", N+1)
x[[1]] <- perpStart[1]
if (N > 1) {
for (i in 1:(N-1)) {
if (inside[i]) {
x[[i+1]] <- c(perpEnd[i], join[i+1], perpStart[i+1])
} else {
switch(linejoin,
round=
{
if (leftedge) {
x[[i+1]] <- c(perpEnd[i], arc[[i]],
perpStart[i+1])
} else {
x[[i+1]] <- c(perpEnd[i], rev(arc[[i]]),
perpStart[i+1])
}
},
mitre=
{
if (mitrelen[i] < mitrelimit) {
x[[i+1]] <- c(intpt1[i], intpt2[i])
} else {
## Fall back to bevel
x[[i+1]] <- c(perpEnd[i], perpStart[i+1])
}
},
bevel=
{
x[[i+1]] <- c(perpEnd[i], perpStart[i+1])
},
stop("Invalid linejoin value")
)
}
}
}
x[[N+1]] <- perpEnd[N]
unlist(x)
}
## Calculate points to the left and to the right
vwlinePoints <- function(grob) {
x <- convertX(grob$x, "in", valueOnly=TRUE)
y <- convertY(grob$y, "in", valueOnly=TRUE)
w <- grob$w
w$left <- pmin(convertWidth(w$left, "in", valueOnly=TRUE),
convertHeight(w$left, "in", valueOnly=TRUE))
w$right <- pmin(convertWidth(w$right, "in", valueOnly=TRUE),
convertHeight(w$right, "in", valueOnly=TRUE))
sinfo <- segInfo(x, y, w, grob$open, grob$stepWidth, grob$debug)
cinfo <- cornerInfo(sinfo, grob$open, grob$stepWidth, grob$debug)
carcinfo <- cornerArcInfo(sinfo, cinfo, grob$open, grob$debug)
if (!grob$open) {
x <- c(x, x[1])
y <- c(y, y[1])
}
leftx <- buildEdge(x,
sinfo$perpStartLeftX,
sinfo$perpEndLeftX,
cinfo$leftInside,
cinfo$leftMitreLength, grob$mitrelimit,
cinfo$leftIntx1,
cinfo$leftIntx2,
carcinfo$leftarcx,
grob$linejoin, TRUE)
lefty <- buildEdge(y,
sinfo$perpStartLeftY,
sinfo$perpEndLeftY,
cinfo$leftInside,
cinfo$leftMitreLength, grob$mitrelimit,
cinfo$leftInty1,
cinfo$leftInty2,
carcinfo$leftarcy,
grob$linejoin, TRUE)
rightx <- buildEdge(rev(x),
rev(sinfo$perpEndRightX),
rev(sinfo$perpStartRightX),
rev(cinfo$rightInside),
rev(cinfo$rightMitreLength), grob$mitrelimit,
rev(cinfo$rightIntx2),
rev(cinfo$rightIntx1),
rev(carcinfo$rightarcx),
grob$linejoin, FALSE)
righty <- buildEdge(rev(y),
rev(sinfo$perpEndRightY),
rev(sinfo$perpStartRightY),
rev(cinfo$rightInside),
rev(cinfo$rightMitreLength), grob$mitrelimit,
rev(cinfo$rightInty2),
rev(cinfo$rightInty1),
rev(carcinfo$rightarcy),
grob$linejoin, FALSE)
list(left=list(x=leftx, y=lefty),
right=list(x=rightx, y=righty),
sinfo=sinfo)
}
buildEnds <- function(w, einfo, earcinfo, stepWidth, lineend, mitrelimit) {
switch(lineend,
butt=
{
startx <- starty <- endx <- endy <- numeric()
},
round=
{
startx <- earcinfo[[1]]$arcx[[1]]
starty <- earcinfo[[1]]$arcy[[1]]
endx <- earcinfo[[2]]$arcx[[1]]
endy <- earcinfo[[2]]$arcy[[1]]
},
mitre=
{
width <- w$left[1] + w$right[1]
if (width > 0 &&
is.finite(einfo$startmitrelength) &&
einfo$startmitrelength/width <= mitrelimit &&
## Not diverging at end
abs(earcinfo[[1]]$cornerangle) < pi) {
startx <- einfo$startmitre$x
starty <- einfo$startmitre$y
} else {
## Fall back to square
startx <- c(einfo$startcorner2$x, einfo$startcorner1$x)
starty <- c(einfo$startcorner2$y, einfo$startcorner1$y)
}
N <- length(w$left)
if (stepWidth) {
width <- w$left[N-1] + w$right[N-1]
} else {
width <- w$left[N] + w$right[N]
}
if (width > 0 &&
is.finite(einfo$endmitrelength) &&
einfo$endmitrelength/width <= mitrelimit &&
## Not diverging at end
abs(earcinfo[[2]]$cornerangle) < pi) {
endx <- einfo$endmitre$x
endy <- einfo$endmitre$y
} else {
endx <- c(einfo$endcorner1$x, einfo$endcorner2$x)
endy <- c(einfo$endcorner1$y, einfo$endcorner2$y)
}
},
square=
{
startx <- c(einfo$startcorner2$x, einfo$startcorner1$x)
starty <- c(einfo$startcorner2$y, einfo$startcorner1$y)
endx <- c(einfo$endcorner1$x, einfo$endcorner2$x)
endy <- c(einfo$endcorner1$y, einfo$endcorner2$y)
},
stop("Invalid lineend value")
)
list(startx=startx, starty=starty, endx=endx, endy=endy)
}
vwlineOutline <- function(grob, simplify=TRUE) {
x <- convertX(grob$x, "in", valueOnly=TRUE)
y <- convertY(grob$y, "in", valueOnly=TRUE)
w <- grob$w
w$left <- pmin(convertWidth(w$left, "in", valueOnly=TRUE),
convertHeight(w$left, "in", valueOnly=TRUE))
w$right <- pmin(convertWidth(w$right, "in", valueOnly=TRUE),
convertHeight(w$right, "in", valueOnly=TRUE))
pts <- vwlinePoints(grob)
if (grob$open) {
sinfo <- segInfo(x, y, w, grob$open, grob$stepWidth, grob$debug)
einfo <- endInfo(x, y, w, sinfo, grob$stepWidth, grob$debug)
earcinfo <- endArcInfo(sinfo, einfo, grob$debug)
ends <- buildEnds(w, einfo, earcinfo, grob$stepWidth,
grob$lineend, grob$mitrelimit)
outline <- list(x=c(ends$startx, pts$left$x, ends$endx, pts$right$x),
y=c(ends$starty, pts$left$y, ends$endy, pts$right$y))
} else {
outline <- list(x=pts$left, y=pts$right)
}
xna <- is.na(outline$x)
yna <- is.na(outline$y)
if (any(xna | yna)) {
outline$x <- outline$x[!(xna | yna)]
outline$y <- outline$y[!(xna | yna)]
warning("Removed NA values from outline")
}
if (simplify)
polysimplify(outline, filltype="nonzero")
else
outline
}
makeContent.vwlineGrob <- function(x, ...) {
outline <- vwlineOutline(x)
## outline is list of outlines
addGrob(x,
x$render(unlist(lapply(outline, "[[", "x")),
unlist(lapply(outline, "[[", "y")),
sapply(outline, function(o) length(o$x)),
x$gp, "outline"))
}
edgePoints.vwlineGrob <- function(x, d,
x0, y0,
which=1,
direction="forward",
debug=FALSE,
...) {
## Silently force which to length 1
which <- which[1]
outline <- vwlineOutline(x)
## outline is list of outlines
if (which > length(outline)) {
stop("Invalid which value")
}
edge <- outline[[which]]
if (!is.unit(x0)) x0 <- unit(x0, "npc")
if (!is.unit(y0)) y0 <- unit(y0, "npc")
pts <- reorderEdge(edge, x0, y0)
vwEdgePoints(pts, d, direction == "forward", x$open, debug)
}
outline.vwlineGrob <- function(x, simplify=TRUE, ...) {
vwlineOutline(x, simplify=simplify)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/vwline.R
|
## Draw a variable-width curve based on control points and
## explicit widths at the control points
grid.vwXspline <- function(...) {
grid.draw(vwXsplineGrob(...))
}
vwXsplineGrob <- function(x, y, w, default.units="npc",
shape=1, open=TRUE, repEnds=TRUE, angle="perp",
lineend="butt", mitrelimit=4,
render=vwPath(),
gp=gpar(fill="black"), name=NULL, debug=FALSE) {
checkvwXspline(x, y, w)
if (!is.unit(x)) {
x <- unit(x, default.units)
}
if (!is.unit(y)) {
y <- unit(y, default.units)
}
if (!is.unit(w)) {
w <- unit(w, default.units)
}
gTree(x=x, y=y, w=w, shape=shape, open=open, repEnds=repEnds,
lineend=lineend, mitrelimit=mitrelimit, angle=angle, render=render,
debug=debug, gp=gp, name=name, cl="vwXsplineGrob")
}
checkvwXspline <- function(x, y, w) {
if (max(length(x), length(y), length(w)) < 3)
stop("A vwline must have at least three control points")
nx <- length(x)
ny <- length(y)
nw <- length(w)
if (nx != ny || nx != nw) {
stop("x, y, and w must all have same length")
}
}
## Generate a set of control points from which we can produce
## one or more XSplines for the outline of the vwline
## NOTE that we want to be able to produce separate upper and right (and mid)
## XSplines (for edge points) as well as a single overall boundary XSpline
## (for drawing)
vwXsplineControlPoints <- function(grob) {
N <- length(grob$x)
x <- convertX(grob$x, "in", valueOnly=TRUE)
y <- convertY(grob$y, "in", valueOnly=TRUE)
w <- pmin(convertWidth(grob$w, "in", valueOnly=TRUE),
convertHeight(grob$w, "in", valueOnly=TRUE))
## fixed angle is simple
if (is.numeric(grob$angle)) {
c(offset(x, y, w/2, grob$angle),
list(mid=list(x=x, y=y)))
} else { # should be "perp" but anything will do
leftx <- numeric(N)
lefty <- numeric(N)
rightx <- numeric(N)
righty <- numeric(N)
## First control point
if (grob$open) {
perps <- perpStart(x[1:2], y[1:2], w[1]/2)
leftx[1] <- perps[1, 1]
lefty[1] <- perps[1, 2]
rightx[1] <- perps[2, 1]
righty[1] <- perps[2, 2]
} else {
seq <- c(N, 1:2)
perps <- perpMid(as.numeric(x[seq]), as.numeric(y[seq]), w[1]/2)
leftx[1] <- perps[1, 1]
lefty[1] <- perps[1, 2]
rightx[1] <- perps[2, 1]
righty[1] <- perps[2, 2]
}
## All but first and last control points
for (i in 2:(N - 1)) {
seq <- (i - 1):(i + 1)
perps <- perpMid(as.numeric(x[seq]), as.numeric(y[seq]), w[i]/2)
leftx[i] <- perps[1, 1]
lefty[i] <- perps[1, 2]
rightx[i] <- perps[2, 1]
righty[i] <- perps[2, 2]
}
## Last control point
if (grob$open) {
perps <- perpEnd(x[(N-1):N], y[(N-1):N], w[N]/2)
leftx[N] <- perps[1, 1]
lefty[N] <- perps[1, 2]
rightx[N] <- perps[2, 1]
righty[N] <- perps[2, 2]
} else {
seq <- c(N - 1, N, 1)
perps <- perpMid(as.numeric(x[seq]), as.numeric(y[seq]), w[N]/2)
leftx[N] <- perps[1, 1]
lefty[N] <- perps[1, 2]
rightx[N] <- perps[2, 1]
righty[N] <- perps[2, 2]
}
list(left=list(x=leftx, y=lefty),
right=list(x=rightx, y=righty),
mid=list(x=x, y=y))
}
}
## Calculate sets of points along left, right, and mid of vwline
vwXsplinePoints <- function(grob) {
N <- length(grob$x)
cp <- vwXsplineControlPoints(grob)
leftpts <- xspline(cp$left$x, cp$left$y,
grob$shape, grob$open, grob$repEnds)
rightpts <- xspline(cp$right$x, cp$right$y,
grob$shape, grob$open, grob$repEnds)
midpts <- xspline(cp$mid$x, cp$mid$y,
grob$shape, grob$open, grob$repEnds)
list(left=leftpts, right=rightpts, mid=midpts)
}
## A single path for makeContent() method (and for xDetails() method)
vwXsplineOutline <- function(grob) {
N <- length(grob$x)
pts <- vwXsplinePoints(grob)
## Debugging
if (grob$debug) {
cp <- vwXsplineControlPoints(grob)
## grid.lines(cp$right$x, cp$right$y, default.units="in", gp=gpar(col="red", lty="dashed"))
grid.segments(cp$mid$x, cp$mid$y, cp$right$x, cp$right$y,
default.units="in",
gp=gpar(col="red"))
grid.points(cp$right$x, cp$right$y, pch=16,
default.units="in",
gp=gpar(col="red"))
## grid.lines(cp$left$x, cp$left$y, default.units="in", gp=gpar(col="blue", lty="dashed"))
grid.segments(cp$left$x, cp$left$y, cp$mid$x, cp$mid$y,
default.units="in",
gp=gpar(col="blue"))
grid.points(cp$left$x, cp$left$y, pch=16,
default.units="in",
gp=gpar(col="blue"))
}
if (grob$open) {
x <- convertX(grob$x[1], "in", valueOnly=TRUE)
y <- convertY(grob$y[1], "in", valueOnly=TRUE)
seg <- generateSegment(x, y,
pts$left$x[1:2], pts$left$y[1:2],
pts$right$x[1:2], pts$right$y[1:2],
grob$debug)
sinfo <- segInfo(seg$x, seg$y, seg$w, TRUE, FALSE, grob$debug)
einfo <- endInfo(seg$x, seg$y, seg$w, sinfo, FALSE, grob$debug)
earcinfo <- endArcInfo(sinfo, einfo, grob$debug)
start <- buildEnds(seg$w, einfo, earcinfo, FALSE,
grob$lineend, grob$mitrelimit)
N <- length(grob$x)
x <- convertX(grob$x[N], "in", valueOnly=TRUE)
y <- convertY(grob$y[N], "in", valueOnly=TRUE)
NL <- length(pts$left$x)
NR <- length(pts$right$x)
seg <- generateSegment(x, y,
pts$right$x[NR:(NR-1)], pts$right$y[NR:(NR-1)],
pts$left$x[NL:(NL-1)], pts$left$y[NL:(NL-1)],
grob$debug)
sinfo <- segInfo(seg$x, seg$y, seg$w, TRUE, FALSE, grob$debug)
einfo <- endInfo(seg$x, seg$y, seg$w, sinfo, FALSE, grob$debug)
earcinfo <- endArcInfo(sinfo, einfo, grob$debug)
end <- buildEnds(seg$w, einfo, earcinfo, FALSE,
grob$lineend, grob$mitrelimit)
list(x=c(start$startx, pts$left$x, end$startx, rev(pts$right$x)),
y=c(start$starty, pts$left$y, end$starty, rev(pts$right$y)),
id.lengths=sum(length(start$startx), length(pts$left$x),
length(end$startx), length(pts$right$x)))
} else {
list(x=c(pts$left$x, rev(pts$right$x)),
y=c(pts$left$y, rev(pts$right$y)),
id.lengths=c(length(pts$left$x), length(pts$right$x)))
}
}
makeContent.vwXsplineGrob <- function(x, ...) {
outline <- vwXsplineOutline(x)
addGrob(x,
x$render(outline$x, outline$y, outline$id.lengths, x$gp, "outline"))
}
edgePoints.vwXsplineGrob <- function(x, d,
which=c("left", "right"),
direction="forward",
debug=FALSE,
...) {
pts <- vwXsplinePoints(x)
result <- list(left=NULL, right=NULL)
if ("left" %in% which) {
result$left=vwEdgePoints(pts$left, d, direction == "forward",
x$open, debug)
}
if ("right" %in% which) {
result$right=vwEdgePoints(pts$right, d, direction == "forward",
x$open, debug)
}
result
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/vwxspline.R
|
################################################################################
## Handling of width specification
## Convert single width to two-sided width
widthSpec <- function(x, default.units="npc") {
if (is.list(x)) {
if (!all(c("left", "right") %in% names(x)) ||
length(x$left) != length(x$right)) {
stop("Invalid width specification")
}
} else {
x <- list(left=.5*x, right=.5*x)
}
if (!is.unit(x$left)) {
x$left <- unit(x$left, default.units)
}
if (!is.unit(x$right)) {
x$right <- unit(x$right, default.units)
}
class(x) <- "widthSpec"
x
}
length.widthSpec <- function(x) {
length(x$left)
}
## Width is specified as an X-spline where ...
## ... x values are distances along the path
## ... y values are widths
widthSpline <- function(w=unit(1, "cm"), default.units="in",
d=NULL, shape=-1, rep=FALSE) {
if (length(w) == 1) {
w <- rep(w, 2)
}
if (!is.unit(w)) {
w <- unit(w, default.units)
}
if (is.null(d)) {
d <- seq(0, 1, length.out=length(w))
}
if (length(w) != length(d)) {
stop("'w' and 'd' must have same length")
}
sw <- list(w=w, d=d, shape=shape, rep=rep)
class(sw) <- "widthSpline"
sw
}
## Width is specified as a Bezier spline where ...
## ... x values are distances along the path
## ... y values are widths
BezierWidth <- function(w=unit(1, "cm"), default.units="in",
d=NULL, rep=FALSE) {
if (length(w) == 1) {
w <- rep(w, 4)
}
ncurves <- (length(w) - 1) %/% 3
if (ncurves*3 + 1 != length(w))
stop("Invalid number of control points")
if (!is.unit(w)) {
w <- unit(w, default.units)
}
if (is.null(d)) {
d <- seq(0, 1, length.out=length(w))
}
sw <- list(w=w, d=d, rep=rep)
class(sw) <- "BezierWidth"
sw
}
widthPoints <- function(w, x, y, ...) {
UseMethod("widthPoints")
}
widthPoints.widthSpline <- function(w, x, y, ...) {
widthSpline <- xsplineGrob(x, y, default.units="in", shape=w$shape)
xsplinePoints(widthSpline)
}
widthPoints.BezierWidth <- function(w, x, y, range, ...) {
widthSpline <- BezierGrob(x, y, default.units="in")
BezierPoints(widthSpline, range)
}
nWidthCurves <- function(w) {
if (!inherits(w, "BezierWidth"))
stop("'w' must be a BezierWidth object")
(length(w$w) - 1) %/% 3
}
## Resolve the width transitions for a path
## Use fill=FALSE to only get widths for subsection of spline
resolveWidth <- function(w, length, range=NULL, fill=TRUE) {
## y-locations are widths
## x-locations are along path
## order() by x-locations
y <- pmin(convertWidth(w$w, "in", valueOnly=TRUE),
convertHeight(w$w, "in", valueOnly=TRUE))
if (is.unit(w$d)) {
x <- convertX(w$d, "in", valueOnly=TRUE)
} else {
## Assume x-location is a proportion
x <- pmin(w$d, 1)*length
}
o <- order(x)
y <- y[o]
x <- x[o]
widthPts <- widthPoints(w, x, y, range)
xx <- as.numeric(widthPts$x)
yy <- as.numeric(widthPts$y)
minx <- min(xx)
maxx <- max(xx)
## repeat or extend if necessary
if (fill && (minx > 0 || maxx < length)) {
lefty <- NULL
leftx <- NULL
righty <- NULL
rightx <- NULL
if (minx > 0) {
if (w$rep) {
## Repeat the widths
multiple <- minx %/% (maxx - minx) + 1
lefty <- rep(yy, multiple)
leftx <- rep(xx, multiple) -
rep(multiple:1*(maxx - minx), each=length(xx))
} else {
## Add initial width at start of path
lefty <- yy[1]
leftx <- 0
}
}
if (maxx < length) {
if (w$rep) {
## Repeat the widths
multiple <- (length - maxx) %/% (maxx - minx) + 1
righty <- rep(yy, multiple)
rightx <- rep(1:multiple*(maxx - minx), each=length(xx)) +
rep(xx, multiple)
} else {
## Add final width at end of path
righty <- yy[length(yy)]
rightx <- length
}
}
yy <- c(lefty, yy, righty)
xx <- c(leftx, xx, rightx)
}
## No need to trim because these widths are just used to interpolate
## locations along path and widths at existing locations along path
## What is important is that these widths EXCEED the range 0 to 'length'
## (otherwise the interpolation will produce constant values)
## Trim to path
list(x=xx, y=yy)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/width.R
|
fblend <- function(num, denom) {
u <- num/denom
p <- 2*denom*denom
u*u*u*(10 - p + (2*p - 15)*u + (6 - p)*u*u)
}
gblend <- function(u, q) {
u*(q + u*(2*q + u*(8 - 12*q + u*(14*q - 11 + u*(4 - 5*q)))))
}
hblend <- function(u, q) {
u*(q + u*(2*q + u*u*(-2*q - u*q)))
}
xsplinePts <- function(px, py, s1, s2, t) {
if (s1 < 0) {
A0 <- hblend(-t, -s1)
A2 <- gblend(t, -s1)
} else {
A0 <- ifelse(t < s1, fblend(t - s1, -1 - s1), 0)
A2 <- fblend(t + s1, 1 + s1)
}
if (s2 < 0) {
A1 <- gblend(1 - t, -s2)
A3 <- hblend(t - 1, -s2)
} else {
A1 <- fblend(t - 1 - s2, -1 - s2)
A3 <- ifelse(t > 1 - s2, fblend(t - 1 + s2, 1 + s2), 0)
}
Asum <- A0 + A1 + A2 + A3
list(x=(A0*px[1] + A1*px[2] + A2*px[3] + A3*px[4])/Asum,
y=(A0*py[1] + A1*py[2] + A2*py[3] + A3*py[4])/Asum)
}
xsplineOffsets <- function(px, py, s1, s2, t) {
evalTangents <- function(i, j) {
for (k in c("A0", "noA0")) {
for (m in c("A3", "noA3")) {
assign(paste("utx", i, j, k, m, sep="."),
do.call(get(paste("xsplineTangent",
i, j, k, m, "x", sep=".")),
list(px0=px[1], px1=px[2], px2=px[3], px3=px[4],
py0=py[1], py1=py[2], py2=py[3], py3=py[4],
s1=s1, s2=s2, t=t)))
assign(paste("uty", i, j, k, m, sep="."),
do.call(get(paste("xsplineTangent",
i, j, k, m, "y", sep=".")),
list(px0=px[1], px1=px[2], px2=px[3], px3=px[4],
py0=py[1], py1=py[2], py2=py[3], py3=py[4],
s1=s1, s2=s2, t=t)))
}
}
list(x=ifelse(t < s1 & t > 1 - s2,
get(paste("utx", i, j, "A0.A3", sep=".")),
ifelse(t < s1,
get(paste("utx", i, j, "A0.noA3", sep=".")),
ifelse(t > 1 - s2,
get(paste("utx", i, j, "noA0.A3", sep=".")),
get(paste("utx", i, j, "noA0.noA3",
sep="."))))),
y=ifelse(t < s1 & t > 1 - s2,
get(paste("uty", i, j, "A0.A3", sep=".")),
ifelse(t < s1,
get(paste("uty", i, j, "A0.noA3", sep=".")),
ifelse(t > 1 - s2,
get(paste("uty", i, j, "noA0.A3", sep=".")),
get(paste("uty", i, j, "noA0.noA3",
sep="."))))))
}
if (s1 < 0) {
if (s2 < 0) {
tangents <- evalTangents("s1neg", "s2neg")
} else {
tangents <- evalTangents("s1neg", "s2pos")
}
} else {
if (s2 < 0) {
tangents <- evalTangents("s1pos", "s2neg")
} else {
tangents <- evalTangents("s1pos", "s2pos")
}
}
## Unit normals from unit tangents
tangentLengths <- sqrt(tangents$x^2 + tangents$y^2)
unitTangents <- list(x=tangents$x/tangentLengths,
y=tangents$y/tangentLengths)
list(x=unitTangents$y, y=-unitTangents$x)
}
xsplineStep <- function(px, py, s1, s2, precision=.5, MAX_SPLINE_STEP=.2) {
## Calculate points at each end and in the middle
pts <- xsplinePts(px, py, s1, s2, c(0, .5, 1))
## These calculations mirror XFig C code calculations
## which assume 1200ppi
pts <- lapply(pts, function(x) x*1200)
xv <- diff(pts$x)
yv <- diff(pts$y)
scal_prod <- xv[1]*(-xv[2]) + yv[1]*(-yv[2]);
sides_length_prod <- sqrt((xv[1]*xv[1] + yv[1]*yv[1])*
(xv[2]*xv[2] + yv[2]*yv[2]))
## compute cosinus of origin-middle-extremity angle, which approximates the
## curve of the spline segment
if (sides_length_prod == 0) {
angle_cos <- 0
} else {
angle_cos <- scal_prod/sides_length_prod
}
xlength <- diff(pts$x[-2])
ylength <- diff(pts$y[-2])
start_to_end_dist <- sqrt(xlength*xlength + ylength*ylength)
## more steps if segment's origin and extremity are remote
number_of_steps <- sqrt(start_to_end_dist)/2;
## more steps if the curve is high
number_of_steps <- number_of_steps + (1 + angle_cos)*10
if (number_of_steps == 0) {
step <- 1
} else {
step <- precision/number_of_steps
}
if ((step > MAX_SPLINE_STEP) || (step == 0)) {
step <- MAX_SPLINE_STEP
}
step
}
xspline <- function(x, y, shape=1, open=TRUE, repEnds=TRUE, tstep=NULL,
xsplineFun=xsplinePts) {
N <- length(x)
shape <- rep(shape, length=N)
if (open) {
if (is.character(repEnds) && repEnds == "extend") {
## Extend first and last control points in direction
## of first and last line-between-control-points
a1 <- angle(x[2:1], y[2:1])
d1 <- dist(diff(x[2:1]), diff(y[2:1]))
ext1 <- extend(x[1], y[1], a1, d1)
a2 <- angle(x[(N-1):N], y[(N-1):N])
d2 <- dist(diff(x[(N-1):N]), diff(y[(N-1):N]))
ext2 <- extend(x[N], y[N], a2, d2)
x <- c(ext1$x, x, ext2$x)
y <- c(ext1$y, y, ext2$y)
shape <- c(0, shape, 0)
N <- N + 2
} else if (repEnds) {
## Force first and last shape to be zero
shape[1] <- shape[N] <- 0
## Repeat first and last control points
x <- c(x[1], x, x[N])
y <- c(y[1], y, y[N])
shape <- c(shape[1], shape, shape[N])
N <- N + 2
}
} else if (!open) {
## Add last control point to start
## AND last first two control points to end
x <- c(x[N], x, x[1:2])
y <- c(y[N], y, y[1:2])
shape <- c(shape[N], shape, shape[1:2])
N <- N + 3
}
curves <- vector("list", N)
for (i in 1:(N-3)) {
index <- i:(i+3)
if (is.null(tstep)) {
step <- xsplineStep(x[index], y[index],
shape[i+1], shape[i+2])
} else {
step <- tstep
}
curves[[i]] <- xsplineFun(x[index], y[index],
shape[i+1], shape[i+2],
seq(0, 1, step))
}
cx <- unlist(lapply(curves, "[[", "x"))
cy <- unlist(lapply(curves, "[[", "y"))
list(x=cx, y=cy)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xspline.R
|
xsplineTangent.s1neg.s2neg.A0.A3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * px0 - ((1 -
t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))) +
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) * px1 +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) *
px2 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * px3)/((-t) * ((-s1) + (-t) *
(2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2))))) - ((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) *
px0 + (1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) *
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2)))))) * px1 + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) * px2 + (t - 1) * ((-s2) + (t - 1) * (2 *
(-s2) + (t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) *
px3) * ((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) - ((1 - t) *
((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 *
(-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) +
(((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 *
(-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) +
(t - 1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) *
(-s2)) - (t - 1) * (t - 1) * (-s2)))))/((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2neg.A0.A3.x.R
|
xsplineTangent.s1neg.s2neg.A0.A3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * py0 - ((1 -
t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))) +
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) * py1 +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) *
py2 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * py3)/((-t) * ((-s1) + (-t) *
(2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2))))) - ((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) *
py0 + (1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) *
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2)))))) * py1 + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) * py2 + (t - 1) * ((-s2) + (t - 1) * (2 *
(-s2) + (t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) *
py3) * ((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) - ((1 - t) *
((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 *
(-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) +
(((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 *
(-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) +
(t - 1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) *
(-s2)) - (t - 1) * (t - 1) * (-s2)))))/((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2neg.A0.A3.y.R
|
xsplineTangent.s1neg.s2neg.A0.noA3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * px0 - ((1 -
t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))) +
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) * px1 +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) *
px2 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * px3)/((-t) * ((-s1) + (-t) *
(2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2))))) - ((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) *
px0 + (1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) *
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2)))))) * px1 + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) * px2 + (t - 1) * ((-s2) + (t - 1) * (2 *
(-s2) + (t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) *
px3) * ((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) - ((1 - t) *
((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 *
(-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) +
(((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 *
(-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) +
(t - 1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) *
(-s2)) - (t - 1) * (t - 1) * (-s2)))))/((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2neg.A0.noA3.x.R
|
xsplineTangent.s1neg.s2neg.A0.noA3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * py0 - ((1 -
t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))) +
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) * py1 +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) *
py2 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * py3)/((-t) * ((-s1) + (-t) *
(2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2))))) - ((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) *
py0 + (1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) *
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2)))))) * py1 + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) * py2 + (t - 1) * ((-s2) + (t - 1) * (2 *
(-s2) + (t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) *
py3) * ((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) - ((1 - t) *
((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 *
(-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) +
(((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 *
(-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) +
(t - 1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) *
(-s2)) - (t - 1) * (t - 1) * (-s2)))))/((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2neg.A0.noA3.y.R
|
xsplineTangent.s1neg.s2neg.noA0.A3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * px0 - ((1 -
t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))) +
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) * px1 +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) *
px2 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * px3)/((-t) * ((-s1) + (-t) *
(2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2))))) - ((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) *
px0 + (1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) *
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2)))))) * px1 + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) * px2 + (t - 1) * ((-s2) + (t - 1) * (2 *
(-s2) + (t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) *
px3) * ((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) - ((1 - t) *
((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 *
(-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) +
(((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 *
(-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) +
(t - 1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) *
(-s2)) - (t - 1) * (t - 1) * (-s2)))))/((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2neg.noA0.A3.x.R
|
xsplineTangent.s1neg.s2neg.noA0.A3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * py0 - ((1 -
t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))) +
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) * py1 +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) *
py2 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * py3)/((-t) * ((-s1) + (-t) *
(2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2))))) - ((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) *
py0 + (1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) *
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2)))))) * py1 + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) * py2 + (t - 1) * ((-s2) + (t - 1) * (2 *
(-s2) + (t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) *
py3) * ((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) - ((1 - t) *
((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 *
(-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) +
(((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 *
(-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) +
(t - 1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) *
(-s2)) - (t - 1) * (t - 1) * (-s2)))))/((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2neg.noA0.A3.y.R
|
xsplineTangent.s1neg.s2neg.noA0.noA3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * px0 - ((1 -
t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))) +
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) * px1 +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) *
px2 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * px3)/((-t) * ((-s1) + (-t) *
(2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2))))) - ((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) *
px0 + (1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) *
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2)))))) * px1 + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) * px2 + (t - 1) * ((-s2) + (t - 1) * (2 *
(-s2) + (t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) *
px3) * ((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) - ((1 - t) *
((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 *
(-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) +
(((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 *
(-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) +
(t - 1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) *
(-s2)) - (t - 1) * (t - 1) * (-s2)))))/((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2neg.noA0.noA3.x.R
|
xsplineTangent.s1neg.s2neg.noA0.noA3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * py0 - ((1 -
t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))) +
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) * py1 +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) *
py2 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * py3)/((-t) * ((-s1) + (-t) *
(2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2))))) - ((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) *
py0 + (1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) *
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2)))))) * py1 + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) * py2 + (t - 1) * ((-s2) + (t - 1) * (2 *
(-s2) + (t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) *
py3) * ((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) - ((1 - t) *
((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) + (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 *
(-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 -
5 * (-s1))))) + t * ((8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) -
11 + t * (4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) +
(((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 *
(-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) +
(t - 1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) *
(-s2)) - (t - 1) * (t - 1) * (-s2)))))/((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
(1 - t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 -
12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))))) + t * ((-s1) + t * (2 * (-s1) + t * (8 -
12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2neg.noA0.noA3.y.R
|
xsplineTangent.s1neg.s2pos.A0.A3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * px0 + (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 -
(2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 -
s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) -
15) * (1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) *
(1/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 -
s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) *
px1 + (((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t *
(14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1))))) + t * ((8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) - 11 + t *
(4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) * px2 + (((1/(1 +
s2) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) *
(1/(1 + s2))) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 - (2 *
(1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) + ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((2 * (2 * (1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) +
((6 - (2 * (1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))))) * px3)/((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t -
1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + t *
((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) *
(10 - (2 * (1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 +
s2)) - 15) * ((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 +
s2) * (1 + s2))) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)))) - ((-t) * ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) * px0 + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) * px1 + t * ((-s1) + t * (2 *
(-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t *
(4 - 5 * (-s1)))))) * px2 + ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * (10 - (2 *
(1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) * px3) *
((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) * (-2 *
(-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) * (-2 *
(-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) + (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * (1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 *
(-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * (1/(-1 -
s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t *
(14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) + t *
((2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1))))) + t * ((8 - 12 *
(-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))) +
t * ((14 * (-s1) - 11 + t * (4 - 5 * (-s1))) +
t * (4 - 5 * (-s1)))))) + (((1/(1 + s2) * ((t -
1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * (1/(1 +
s2))) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 -
(2 * (1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 +
s2)) - 15) * ((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 +
s2) * (1 + s2))) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 +
s2)/(1 + s2))) + ((t - 1 + s2)/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((2 * (2 *
(1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) + ((6 - (2 *
(1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 + s2)/(1 +
s2)) * (1/(1 + s2))))))/((-t) * ((-s1) + (-t) * (2 *
(-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) + ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * (10 - (2 * (1 + s2) * (1 +
s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2pos.A0.A3.x.R
|
xsplineTangent.s1neg.s2pos.A0.A3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * py0 + (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 -
(2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 -
s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) -
15) * (1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) *
(1/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 -
s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) *
py1 + (((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t *
(14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1))))) + t * ((8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) - 11 + t *
(4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) * py2 + (((1/(1 +
s2) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) *
(1/(1 + s2))) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 - (2 *
(1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) + ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((2 * (2 * (1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) +
((6 - (2 * (1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))))) * py3)/((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t -
1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + t *
((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) *
(10 - (2 * (1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 +
s2)) - 15) * ((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 +
s2) * (1 + s2))) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)))) - ((-t) * ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) * py0 + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) * py1 + t * ((-s1) + t * (2 *
(-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t *
(4 - 5 * (-s1)))))) * py2 + ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * (10 - (2 *
(1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) * py3) *
((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) * (-2 *
(-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) * (-2 *
(-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) + (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * (1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 *
(-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * (1/(-1 -
s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t *
(14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) + t *
((2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1))))) + t * ((8 - 12 *
(-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))) +
t * ((14 * (-s1) - 11 + t * (4 - 5 * (-s1))) +
t * (4 - 5 * (-s1)))))) + (((1/(1 + s2) * ((t -
1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * (1/(1 +
s2))) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 -
(2 * (1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 +
s2)) - 15) * ((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 +
s2) * (1 + s2))) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 +
s2)/(1 + s2))) + ((t - 1 + s2)/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((2 * (2 *
(1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) + ((6 - (2 *
(1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 + s2)/(1 +
s2)) * (1/(1 + s2))))))/((-t) * ((-s1) + (-t) * (2 *
(-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) + ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * (10 - (2 * (1 + s2) * (1 +
s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2pos.A0.A3.y.R
|
xsplineTangent.s1neg.s2pos.A0.noA3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * px0 + (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 -
(2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 -
s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) -
15) * (1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) *
(1/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 -
s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) *
px1 + (((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t *
(14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1))))) + t * ((8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) - 11 + t *
(4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) * px2)/((-t) *
((-s1) + (-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) -
(-t) * (-s1)))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (10 - (2 * (-1 -
s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + t *
((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + 0) - ((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) *
px0 + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) * px1 + t * ((-s1) +
t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))))) * px2 + 0 * px3) * ((-t) *
((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) * (-2 * (-s1) -
(-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) -
(-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) + (-t) *
(-t) * (-2 * (-s1) - (-t) * (-s1)))) + (((1/(-1 - s2) * ((t -
1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 - (2 * (-1 -
s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
(1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) + (((-s1) +
t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) + t *
(8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1))))) +
t * ((8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))) + t * ((14 * (-s1) - 11 + t * (4 - 5 * (-s1))) +
t * (4 - 5 * (-s1)))))))/((-t) * ((-s1) + (-t) * (2 *
(-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) + 0)^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2pos.A0.noA3.x.R
|
xsplineTangent.s1neg.s2pos.A0.noA3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * py0 + (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 -
(2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 -
s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) -
15) * (1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) *
(1/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 -
s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) *
py1 + (((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t *
(14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1))))) + t * ((8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) - 11 + t *
(4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) * py2)/((-t) *
((-s1) + (-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) -
(-t) * (-s1)))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (10 - (2 * (-1 -
s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + t *
((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + 0) - ((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) *
py0 + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) * py1 + t * ((-s1) +
t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))))) * py2 + 0 * py3) * ((-t) *
((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) * (-2 * (-s1) -
(-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) -
(-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) + (-t) *
(-t) * (-2 * (-s1) - (-t) * (-s1)))) + (((1/(-1 - s2) * ((t -
1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 - (2 * (-1 -
s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
(1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) + (((-s1) +
t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) + t *
(8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1))))) +
t * ((8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))) + t * ((14 * (-s1) - 11 + t * (4 - 5 * (-s1))) +
t * (4 - 5 * (-s1)))))))/((-t) * ((-s1) + (-t) * (2 *
(-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) + 0)^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2pos.A0.noA3.y.R
|
xsplineTangent.s1neg.s2pos.noA0.A3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * px0 + (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 -
(2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 -
s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) -
15) * (1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) *
(1/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 -
s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) *
px1 + (((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t *
(14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1))))) + t * ((8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) - 11 + t *
(4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) * px2 + (((1/(1 +
s2) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) *
(1/(1 + s2))) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 - (2 *
(1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) + ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((2 * (2 * (1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) +
((6 - (2 * (1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))))) * px3)/((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t -
1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + t *
((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) *
(10 - (2 * (1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 +
s2)) - 15) * ((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 +
s2) * (1 + s2))) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)))) - ((-t) * ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) * px0 + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) * px1 + t * ((-s1) + t * (2 *
(-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t *
(4 - 5 * (-s1)))))) * px2 + ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * (10 - (2 *
(1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) * px3) *
((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) * (-2 *
(-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) * (-2 *
(-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) + (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * (1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 *
(-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * (1/(-1 -
s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t *
(14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) + t *
((2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1))))) + t * ((8 - 12 *
(-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))) +
t * ((14 * (-s1) - 11 + t * (4 - 5 * (-s1))) +
t * (4 - 5 * (-s1)))))) + (((1/(1 + s2) * ((t -
1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * (1/(1 +
s2))) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 -
(2 * (1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 +
s2)) - 15) * ((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 +
s2) * (1 + s2))) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 +
s2)/(1 + s2))) + ((t - 1 + s2)/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((2 * (2 *
(1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) + ((6 - (2 *
(1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 + s2)/(1 +
s2)) * (1/(1 + s2))))))/((-t) * ((-s1) + (-t) * (2 *
(-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) + ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * (10 - (2 * (1 + s2) * (1 +
s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2pos.noA0.A3.x.R
|
xsplineTangent.s1neg.s2pos.noA0.A3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * py0 + (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 -
(2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 -
s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) -
15) * (1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) *
(1/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 -
s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) *
py1 + (((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t *
(14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1))))) + t * ((8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) - 11 + t *
(4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) * py2 + (((1/(1 +
s2) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) *
(1/(1 + s2))) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 - (2 *
(1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) + ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((2 * (2 * (1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) +
((6 - (2 * (1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))))) * py3)/((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t -
1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + t *
((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) *
(10 - (2 * (1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 +
s2)) - 15) * ((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 +
s2) * (1 + s2))) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)))) - ((-t) * ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) * py0 + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) * py1 + t * ((-s1) + t * (2 *
(-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t *
(4 - 5 * (-s1)))))) * py2 + ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * (10 - (2 *
(1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) * py3) *
((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) * (-2 *
(-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) * (-2 *
(-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) + (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * (1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 *
(-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * (1/(-1 -
s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) +
(((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t *
(14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) + t *
((2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1))))) + t * ((8 - 12 *
(-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1)))) +
t * ((14 * (-s1) - 11 + t * (4 - 5 * (-s1))) +
t * (4 - 5 * (-s1)))))) + (((1/(1 + s2) * ((t -
1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * (1/(1 +
s2))) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 -
(2 * (1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 +
s2)) - 15) * ((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 +
s2) * (1 + s2))) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 +
s2)/(1 + s2))) + ((t - 1 + s2)/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((2 * (2 *
(1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) + ((6 - (2 *
(1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 + s2)/(1 +
s2)) * (1/(1 + s2))))))/((-t) * ((-s1) + (-t) * (2 *
(-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) + ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2)) * (10 - (2 * (1 + s2) * (1 +
s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2pos.noA0.A3.y.R
|
xsplineTangent.s1neg.s2pos.noA0.noA3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * px0 + (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 -
(2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 -
s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) -
15) * (1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) *
(1/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 -
s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) *
px1 + (((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t *
(14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1))))) + t * ((8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) - 11 + t *
(4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) * px2)/((-t) *
((-s1) + (-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) -
(-t) * (-s1)))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (10 - (2 * (-1 -
s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + t *
((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + 0) - ((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) *
px0 + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) * px1 + t * ((-s1) +
t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))))) * px2 + 0 * px3) * ((-t) *
((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) * (-2 * (-s1) -
(-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) -
(-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) + (-t) *
(-t) * (-2 * (-s1) - (-t) * (-s1)))) + (((1/(-1 - s2) * ((t -
1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 - (2 * (-1 -
s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
(1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) + (((-s1) +
t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) + t *
(8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1))))) +
t * ((8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))) + t * ((14 * (-s1) - 11 + t * (4 - 5 * (-s1))) +
t * (4 - 5 * (-s1)))))))/((-t) * ((-s1) + (-t) * (2 *
(-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) + 0)^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2pos.noA0.noA3.x.R
|
xsplineTangent.s1neg.s2pos.noA0.noA3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
((((-t) * ((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) *
(-2 * (-s1) - (-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) *
(-2 * (-s1) - (-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) +
(-t) * (-t) * (-2 * (-s1) - (-t) * (-s1))))) * py0 + (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 -
(2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 -
s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) -
15) * (1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) *
(1/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 -
s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) *
py1 + (((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t *
(14 * (-s1) - 11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1))))) + t * ((8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))) + t * ((14 * (-s1) - 11 + t *
(4 - 5 * (-s1))) + t * (4 - 5 * (-s1)))))) * py2)/((-t) *
((-s1) + (-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) -
(-t) * (-s1)))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (10 - (2 * (-1 -
s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + t *
((-s1) + t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 *
(-s1) - 11 + t * (4 - 5 * (-s1)))))) + 0) - ((-t) * ((-s1) +
(-t) * (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) *
py0 + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) * py1 + t * ((-s1) +
t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))))) * py2 + 0 * py3) * ((-t) *
((-t) * ((-t) * (-t) * (-s1) - ((-t) + (-t)) * (-2 * (-s1) -
(-t) * (-s1))) - (2 * (-s1) + (-t) * (-t) * (-2 * (-s1) -
(-t) * (-s1)))) - ((-s1) + (-t) * (2 * (-s1) + (-t) *
(-t) * (-2 * (-s1) - (-t) * (-s1)))) + (((1/(-1 - s2) * ((t -
1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 - (2 * (-1 -
s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
(1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) + (((-s1) +
t * (2 * (-s1) + t * (8 - 12 * (-s1) + t * (14 * (-s1) -
11 + t * (4 - 5 * (-s1)))))) + t * ((2 * (-s1) + t *
(8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 * (-s1))))) +
t * ((8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))) + t * ((14 * (-s1) - 11 + t * (4 - 5 * (-s1))) +
t * (4 - 5 * (-s1)))))))/((-t) * ((-s1) + (-t) * (2 *
(-s1) + (-t) * (-t) * (-2 * (-s1) - (-t) * (-s1)))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + t * ((-s1) + t * (2 * (-s1) +
t * (8 - 12 * (-s1) + t * (14 * (-s1) - 11 + t * (4 - 5 *
(-s1)))))) + 0)^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1neg.s2pos.noA0.noA3.y.R
|
xsplineTangent.s1pos.s2neg.A0.A3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(-1 - s1) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
((2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) +
((6 - (2 * (-1 - s1) * (-1 - s1))) * (1/(-1 - s1)) *
((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))))) *
px0 - ((1 - t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 *
(-s2)) + (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) +
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) *
px1 + (((1/(1 + s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 +
s1) * (1 + s1)) - 15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) *
(1 + s1))) * (1/(1 + s1)) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * (1/(1 + s1))))) *
px2 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) *
(-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * px3)/(((t - s1)/(-1 - s1)) *
((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + (1 -
t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 +
s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1))) + (t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t -
1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))))) - (((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
(10 - (2 * (-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) *
(-1 - s1)) - 15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 -
s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 -
s1))) * px0 + (1 - t) * ((-s2) + (1 - t) * (2 * (-s2) +
(1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 +
(1 - t) * (4 - 5 * (-s2)))))) * px1 + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 -
(2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) -
15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) * px2 + (t - 1) *
((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 *
(-s2) - (t - 1) * (-s2)))) * px3) * (((1/(-1 - s1) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * (10 - (2 * (-1 - s1) * (-1 - s1)) +
(2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 -
s1)) + (6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1))) + ((t - s1)/(-1 - s1)) * ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((2 * (2 * (-1 -
s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) + ((6 - (2 * (-1 -
s1) * (-1 - s1))) * (1/(-1 - s1)) * ((t - s1)/(-1 - s1)) +
(6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) *
(1/(-1 - s1)))) - ((1 - t) * ((1 - t) * ((1 - t) * ((1 -
t) * (4 - 5 * (-s2)) + (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))) + (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) -
11 + (1 - t) * (4 - 5 * (-s2))))) + (2 * (-s2) + (1 - t) *
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2)))))) + ((-s2) + (1 - t) * (2 * (-s2) +
(1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 +
(1 - t) * (4 - 5 * (-s2))))))) + (((1/(1 + s1) * ((t +
s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 + s1))) * ((t +
s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 *
(1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) - 15) * (1/(1 +
s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 + s1)) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))))) + (((-s2) + (t - 1) * (2 *
(-s2) + (t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) +
(t - 1) * ((2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2))) + (t - 1) * (((t - 1) + (t - 1)) *
(-2 * (-s2) - (t - 1) * (-s2)) - (t - 1) * (t - 1) *
(-s2)))))/(((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
((t - s1)/(-1 - s1)) * (10 - (2 * (-1 - s1) * (-1 - s1)) +
(2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 -
s1)) + (6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1))) + (1 - t) * ((-s2) + (1 - t) *
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 -
(2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) -
15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + (t - 1) * ((-s2) +
(t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2neg.A0.A3.x.R
|
xsplineTangent.s1pos.s2neg.A0.A3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(-1 - s1) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
((2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) +
((6 - (2 * (-1 - s1) * (-1 - s1))) * (1/(-1 - s1)) *
((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))))) *
py0 - ((1 - t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 *
(-s2)) + (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) +
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) *
py1 + (((1/(1 + s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 +
s1) * (1 + s1)) - 15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) *
(1 + s1))) * (1/(1 + s1)) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * (1/(1 + s1))))) *
py2 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) *
(-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * py3)/(((t - s1)/(-1 - s1)) *
((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + (1 -
t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 +
s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1))) + (t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t -
1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))))) - (((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
(10 - (2 * (-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) *
(-1 - s1)) - 15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 -
s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 -
s1))) * py0 + (1 - t) * ((-s2) + (1 - t) * (2 * (-s2) +
(1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 +
(1 - t) * (4 - 5 * (-s2)))))) * py1 + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 -
(2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) -
15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) * py2 + (t - 1) *
((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 *
(-s2) - (t - 1) * (-s2)))) * py3) * (((1/(-1 - s1) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * (10 - (2 * (-1 - s1) * (-1 - s1)) +
(2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 -
s1)) + (6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1))) + ((t - s1)/(-1 - s1)) * ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((2 * (2 * (-1 -
s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) + ((6 - (2 * (-1 -
s1) * (-1 - s1))) * (1/(-1 - s1)) * ((t - s1)/(-1 - s1)) +
(6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) *
(1/(-1 - s1)))) - ((1 - t) * ((1 - t) * ((1 - t) * ((1 -
t) * (4 - 5 * (-s2)) + (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))) + (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) -
11 + (1 - t) * (4 - 5 * (-s2))))) + (2 * (-s2) + (1 - t) *
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2)))))) + ((-s2) + (1 - t) * (2 * (-s2) +
(1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 +
(1 - t) * (4 - 5 * (-s2))))))) + (((1/(1 + s1) * ((t +
s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 + s1))) * ((t +
s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 *
(1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) - 15) * (1/(1 +
s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 + s1)) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))))) + (((-s2) + (t - 1) * (2 *
(-s2) + (t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) +
(t - 1) * ((2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2))) + (t - 1) * (((t - 1) + (t - 1)) *
(-2 * (-s2) - (t - 1) * (-s2)) - (t - 1) * (t - 1) *
(-s2)))))/(((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
((t - s1)/(-1 - s1)) * (10 - (2 * (-1 - s1) * (-1 - s1)) +
(2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 -
s1)) + (6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1))) + (1 - t) * ((-s2) + (1 - t) *
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 -
(2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) -
15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + (t - 1) * ((-s2) +
(t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2neg.A0.A3.y.R
|
xsplineTangent.s1pos.s2neg.A0.noA3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(-1 - s1) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
((2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) +
((6 - (2 * (-1 - s1) * (-1 - s1))) * (1/(-1 - s1)) *
((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))))) *
px0 - ((1 - t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 *
(-s2)) + (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) +
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) *
px1 + (((1/(1 + s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 +
s1) * (1 + s1)) - 15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) *
(1 + s1))) * (1/(1 + s1)) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * (1/(1 + s1))))) *
px2 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) *
(-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * px3)/(((t - s1)/(-1 - s1)) *
((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + (1 -
t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 +
s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1))) + (t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t -
1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))))) - (((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
(10 - (2 * (-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) *
(-1 - s1)) - 15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 -
s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 -
s1))) * px0 + (1 - t) * ((-s2) + (1 - t) * (2 * (-s2) +
(1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 +
(1 - t) * (4 - 5 * (-s2)))))) * px1 + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 -
(2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) -
15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) * px2 + (t - 1) *
((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 *
(-s2) - (t - 1) * (-s2)))) * px3) * (((1/(-1 - s1) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * (10 - (2 * (-1 - s1) * (-1 - s1)) +
(2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 -
s1)) + (6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1))) + ((t - s1)/(-1 - s1)) * ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((2 * (2 * (-1 -
s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) + ((6 - (2 * (-1 -
s1) * (-1 - s1))) * (1/(-1 - s1)) * ((t - s1)/(-1 - s1)) +
(6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) *
(1/(-1 - s1)))) - ((1 - t) * ((1 - t) * ((1 - t) * ((1 -
t) * (4 - 5 * (-s2)) + (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))) + (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) -
11 + (1 - t) * (4 - 5 * (-s2))))) + (2 * (-s2) + (1 - t) *
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2)))))) + ((-s2) + (1 - t) * (2 * (-s2) +
(1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 +
(1 - t) * (4 - 5 * (-s2))))))) + (((1/(1 + s1) * ((t +
s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 + s1))) * ((t +
s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 *
(1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) - 15) * (1/(1 +
s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 + s1)) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))))) + (((-s2) + (t - 1) * (2 *
(-s2) + (t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) +
(t - 1) * ((2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2))) + (t - 1) * (((t - 1) + (t - 1)) *
(-2 * (-s2) - (t - 1) * (-s2)) - (t - 1) * (t - 1) *
(-s2)))))/(((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
((t - s1)/(-1 - s1)) * (10 - (2 * (-1 - s1) * (-1 - s1)) +
(2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 -
s1)) + (6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1))) + (1 - t) * ((-s2) + (1 - t) *
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 -
(2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) -
15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + (t - 1) * ((-s2) +
(t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2neg.A0.noA3.x.R
|
xsplineTangent.s1pos.s2neg.A0.noA3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(-1 - s1) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
((2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) +
((6 - (2 * (-1 - s1) * (-1 - s1))) * (1/(-1 - s1)) *
((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))))) *
py0 - ((1 - t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 *
(-s2)) + (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) +
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) *
py1 + (((1/(1 + s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 +
s1) * (1 + s1)) - 15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) *
(1 + s1))) * (1/(1 + s1)) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * (1/(1 + s1))))) *
py2 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) *
(-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * py3)/(((t - s1)/(-1 - s1)) *
((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + (1 -
t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 +
s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1))) + (t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t -
1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))))) - (((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
(10 - (2 * (-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) *
(-1 - s1)) - 15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 -
s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 -
s1))) * py0 + (1 - t) * ((-s2) + (1 - t) * (2 * (-s2) +
(1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 +
(1 - t) * (4 - 5 * (-s2)))))) * py1 + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 -
(2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) -
15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) * py2 + (t - 1) *
((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 *
(-s2) - (t - 1) * (-s2)))) * py3) * (((1/(-1 - s1) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * (10 - (2 * (-1 - s1) * (-1 - s1)) +
(2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 -
s1)) + (6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1))) + ((t - s1)/(-1 - s1)) * ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((2 * (2 * (-1 -
s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) + ((6 - (2 * (-1 -
s1) * (-1 - s1))) * (1/(-1 - s1)) * ((t - s1)/(-1 - s1)) +
(6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) *
(1/(-1 - s1)))) - ((1 - t) * ((1 - t) * ((1 - t) * ((1 -
t) * (4 - 5 * (-s2)) + (14 * (-s2) - 11 + (1 - t) * (4 -
5 * (-s2)))) + (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) -
11 + (1 - t) * (4 - 5 * (-s2))))) + (2 * (-s2) + (1 - t) *
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2)))))) + ((-s2) + (1 - t) * (2 * (-s2) +
(1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 +
(1 - t) * (4 - 5 * (-s2))))))) + (((1/(1 + s1) * ((t +
s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 + s1))) * ((t +
s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 *
(1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) - 15) * (1/(1 +
s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 + s1)) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))))) + (((-s2) + (t - 1) * (2 *
(-s2) + (t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) +
(t - 1) * ((2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2))) + (t - 1) * (((t - 1) + (t - 1)) *
(-2 * (-s2) - (t - 1) * (-s2)) - (t - 1) * (t - 1) *
(-s2)))))/(((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
((t - s1)/(-1 - s1)) * (10 - (2 * (-1 - s1) * (-1 - s1)) +
(2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 -
s1)) + (6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1))) + (1 - t) * ((-s2) + (1 - t) *
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 -
(2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) -
15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + (t - 1) * ((-s2) +
(t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2neg.A0.noA3.y.R
|
xsplineTangent.s1pos.s2neg.noA0.A3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(1 + s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 +
s1) * (1 + s1)) - 15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) *
(1 + s1))) * (1/(1 + s1)) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * (1/(1 + s1))))) *
px2 - ((1 - t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 *
(-s2)) + (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) +
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) *
px1 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) *
(-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * px3)/(0 + (1 - t) * ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2))))) - (0 * px0 + (1 -
t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) *
px1 + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) *
(1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) *
px2 + (t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) *
(t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) * px3) * (((1/(1 +
s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 +
s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 +
s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 +
s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1)))) - ((1 - t) * ((1 - t) *
((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 * (-s2) - 11 +
(1 - t) * (4 - 5 * (-s2)))) + (8 - 12 * (-s2) + (1 -
t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))) +
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) + (((-s2) +
(t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) + (t - 1) *
(t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t - 1) * (((t -
1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) - (t - 1) *
(t - 1) * (-s2)))))/(0 + (1 - t) * ((-s2) + (1 - t) * (2 *
(-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) -
11 + (1 - t) * (4 - 5 * (-s2)))))) + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + (t - 1) * ((-s2) +
(t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2neg.noA0.A3.x.R
|
xsplineTangent.s1pos.s2neg.noA0.A3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(1 + s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 +
s1) * (1 + s1)) - 15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) *
(1 + s1))) * (1/(1 + s1)) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * (1/(1 + s1))))) *
py2 - ((1 - t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 *
(-s2)) + (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) +
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) *
py1 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) *
(-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * py3)/(0 + (1 - t) * ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2))))) - (0 * py0 + (1 -
t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) *
py1 + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) *
(1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) *
py2 + (t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) *
(t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) * py3) * (((1/(1 +
s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 +
s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 +
s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 +
s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1)))) - ((1 - t) * ((1 - t) *
((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 * (-s2) - 11 +
(1 - t) * (4 - 5 * (-s2)))) + (8 - 12 * (-s2) + (1 -
t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))) +
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) + (((-s2) +
(t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) + (t - 1) *
(t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t - 1) * (((t -
1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) - (t - 1) *
(t - 1) * (-s2)))))/(0 + (1 - t) * ((-s2) + (1 - t) * (2 *
(-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) -
11 + (1 - t) * (4 - 5 * (-s2)))))) + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + (t - 1) * ((-s2) +
(t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2neg.noA0.A3.y.R
|
xsplineTangent.s1pos.s2neg.noA0.noA3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(1 + s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 +
s1) * (1 + s1)) - 15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) *
(1 + s1))) * (1/(1 + s1)) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * (1/(1 + s1))))) *
px2 - ((1 - t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 *
(-s2)) + (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) +
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) *
px1 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) *
(-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * px3)/(0 + (1 - t) * ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2))))) - (0 * px0 + (1 -
t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) *
px1 + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) *
(1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) *
px2 + (t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) *
(t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) * px3) * (((1/(1 +
s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 +
s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 +
s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 +
s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1)))) - ((1 - t) * ((1 - t) *
((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 * (-s2) - 11 +
(1 - t) * (4 - 5 * (-s2)))) + (8 - 12 * (-s2) + (1 -
t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))) +
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) + (((-s2) +
(t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) + (t - 1) *
(t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t - 1) * (((t -
1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) - (t - 1) *
(t - 1) * (-s2)))))/(0 + (1 - t) * ((-s2) + (1 - t) * (2 *
(-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) -
11 + (1 - t) * (4 - 5 * (-s2)))))) + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + (t - 1) * ((-s2) +
(t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2neg.noA0.noA3.x.R
|
xsplineTangent.s1pos.s2neg.noA0.noA3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(1 + s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 +
s1) * (1 + s1)) - 15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) *
(1 + s1))) * (1/(1 + s1)) * ((t + s1)/(1 + s1)) + (6 - (2 *
(1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * (1/(1 + s1))))) *
py2 - ((1 - t) * ((1 - t) * ((1 - t) * ((1 - t) * (4 - 5 *
(-s2)) + (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))) +
(8 - 12 * (-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) *
(4 - 5 * (-s2))))) + (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) +
((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) +
(1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) *
py1 + (((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t - 1) *
(-2 * (-s2) - (t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) +
(t - 1) * (t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t -
1) * (((t - 1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) -
(t - 1) * (t - 1) * (-s2)))) * py3)/(0 + (1 - t) * ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
(t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) * (t -
1) * (-2 * (-s2) - (t - 1) * (-s2))))) - (0 * py0 + (1 -
t) * ((-s2) + (1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 *
(-s2) + (1 - t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) *
py1 + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) *
(1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) *
py2 + (t - 1) * ((-s2) + (t - 1) * (2 * (-s2) + (t - 1) *
(t - 1) * (-2 * (-s2) - (t - 1) * (-s2)))) * py3) * (((1/(1 +
s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 +
s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 +
s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 +
s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1)))) - ((1 - t) * ((1 - t) *
((1 - t) * ((1 - t) * (4 - 5 * (-s2)) + (14 * (-s2) - 11 +
(1 - t) * (4 - 5 * (-s2)))) + (8 - 12 * (-s2) + (1 -
t) * (14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))) +
(2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 *
(-s2) - 11 + (1 - t) * (4 - 5 * (-s2)))))) + ((-s2) +
(1 - t) * (2 * (-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) *
(14 * (-s2) - 11 + (1 - t) * (4 - 5 * (-s2))))))) + (((-s2) +
(t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2)))) + (t - 1) * ((2 * (-s2) + (t - 1) *
(t - 1) * (-2 * (-s2) - (t - 1) * (-s2))) + (t - 1) * (((t -
1) + (t - 1)) * (-2 * (-s2) - (t - 1) * (-s2)) - (t - 1) *
(t - 1) * (-s2)))))/(0 + (1 - t) * ((-s2) + (1 - t) * (2 *
(-s2) + (1 - t) * (8 - 12 * (-s2) + (1 - t) * (14 * (-s2) -
11 + (1 - t) * (4 - 5 * (-s2)))))) + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) + (t - 1) * ((-s2) +
(t - 1) * (2 * (-s2) + (t - 1) * (t - 1) * (-2 * (-s2) -
(t - 1) * (-s2)))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2neg.noA0.noA3.y.R
|
xsplineTangent.s1pos.s2pos.A0.A3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(-1 - s1) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
((2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) +
((6 - (2 * (-1 - s1) * (-1 - s1))) * (1/(-1 - s1)) *
((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))))) *
px0 + (((1/(-1 - s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 -
s2)/(-1 - s2)) * (1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 *
(-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * (1/(-1 - s2)) + ((6 -
(2 * (-1 - s2) * (-1 - s2))) * (1/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) * px1 + (((1/(1 + s1) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 + s1))) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 + s1)) +
(2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) +
(6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))) * px2 + (((1/(1 + s2) *
((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * (1/(1 +
s2))) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) *
((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 - (2 * (1 +
s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) + ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((2 * (2 * (1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) +
((6 - (2 * (1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))))) * px3)/(((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 -
(2 * (-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 -
s1)) - 15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) *
(-1 - s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t -
1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * (10 - (2 * (1 + s2) * (1 + s2)) +
(2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 +
s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)))) - (((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 -
(2 * (-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 -
s1)) - 15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) *
(-1 - s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) *
px0 + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) * px1 + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) *
px2 + ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) *
((t - 1 + s2)/(1 + s2)) * (10 - (2 * (1 + s2) * (1 + s2)) +
(2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2))) * px3) * (((1/(-1 - s1) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * (10 - (2 * (-1 - s1) * (-1 - s1)) +
(2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 -
s1)) + (6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1))) + ((t - s1)/(-1 - s1)) * ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((2 * (2 * (-1 -
s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) + ((6 - (2 * (-1 -
s1) * (-1 - s1))) * (1/(-1 - s1)) * ((t - s1)/(-1 - s1)) +
(6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) *
(1/(-1 - s1)))) + (((1/(-1 - s2) * ((t - 1 - s2)/(-1 -
s2)) + ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 - (2 * (-1 - s2) *
(-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t -
1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
(1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) + (((1/(1 +
s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 +
s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 +
s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 +
s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))) + (((1/(1 + s2) * ((t -
1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) *
((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 - (2 * (1 + s2) *
(1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t -
1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) + ((t - 1 +
s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((2 * (2 * (1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) +
((6 - (2 * (1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))))))/(((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 -
(2 * (-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 -
s1)) - 15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) *
(-1 - s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t -
1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * (10 - (2 * (1 + s2) * (1 + s2)) +
(2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 +
s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2pos.A0.A3.x.R
|
xsplineTangent.s1pos.s2pos.A0.A3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(-1 - s1) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
((2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) +
((6 - (2 * (-1 - s1) * (-1 - s1))) * (1/(-1 - s1)) *
((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))))) *
py0 + (((1/(-1 - s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 -
s2)/(-1 - s2)) * (1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 *
(-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * (1/(-1 - s2)) + ((6 -
(2 * (-1 - s2) * (-1 - s2))) * (1/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) * py1 + (((1/(1 + s1) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 + s1))) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 + s1)) +
(2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) +
(6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))) * py2 + (((1/(1 + s2) *
((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * (1/(1 +
s2))) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) *
((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 - (2 * (1 +
s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) + ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((2 * (2 * (1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) +
((6 - (2 * (1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))))) * py3)/(((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 -
(2 * (-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 -
s1)) - 15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) *
(-1 - s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t -
1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * (10 - (2 * (1 + s2) * (1 + s2)) +
(2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 +
s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)))) - (((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 -
(2 * (-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 -
s1)) - 15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) *
(-1 - s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) *
py0 + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) * py1 + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) *
py2 + ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) *
((t - 1 + s2)/(1 + s2)) * (10 - (2 * (1 + s2) * (1 + s2)) +
(2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2))) * py3) * (((1/(-1 - s1) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * (10 - (2 * (-1 - s1) * (-1 - s1)) +
(2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 -
s1)) + (6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1))) + ((t - s1)/(-1 - s1)) * ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((2 * (2 * (-1 -
s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) + ((6 - (2 * (-1 -
s1) * (-1 - s1))) * (1/(-1 - s1)) * ((t - s1)/(-1 - s1)) +
(6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) *
(1/(-1 - s1)))) + (((1/(-1 - s2) * ((t - 1 - s2)/(-1 -
s2)) + ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 - (2 * (-1 - s2) *
(-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t -
1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
(1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) + (((1/(1 +
s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 +
s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 +
s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 +
s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))) + (((1/(1 + s2) * ((t -
1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) *
((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 - (2 * (1 + s2) *
(1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t -
1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) + ((t - 1 +
s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((2 * (2 * (1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) +
((6 - (2 * (1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))))))/(((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 -
(2 * (-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 -
s1)) - 15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) *
(-1 - s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t -
1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * (10 - (2 * (1 + s2) * (1 + s2)) +
(2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 +
s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2pos.A0.A3.y.R
|
xsplineTangent.s1pos.s2pos.A0.noA3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(-1 - s1) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
((2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) +
((6 - (2 * (-1 - s1) * (-1 - s1))) * (1/(-1 - s1)) *
((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))))) *
px0 + (((1/(-1 - s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 -
s2)/(-1 - s2)) * (1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 *
(-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * (1/(-1 - s2)) + ((6 -
(2 * (-1 - s2) * (-1 - s2))) * (1/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) * px1 + (((1/(1 + s1) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 + s1))) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 + s1)) +
(2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) +
(6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))) * px2)/(((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 -
(2 * (-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 -
s1)) - 15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) *
(-1 - s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t -
1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
0) - (((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t -
s1)/(-1 - s1)) * (10 - (2 * (-1 - s1) * (-1 - s1)) + (2 *
(2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 - s1)) +
(6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) *
((t - s1)/(-1 - s1))) * px0 + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (10 -
(2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 -
s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2))) * px1 + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 *
(2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 -
(2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1))) * px2 + 0 * px3) * (((1/(-1 - s1) * ((t -
s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * (10 - (2 * (-1 - s1) * (-1 - s1)) +
(2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 -
s1)) + (6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1))) + ((t - s1)/(-1 - s1)) * ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((2 * (2 * (-1 -
s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) + ((6 - (2 * (-1 -
s1) * (-1 - s1))) * (1/(-1 - s1)) * ((t - s1)/(-1 - s1)) +
(6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) *
(1/(-1 - s1)))) + (((1/(-1 - s2) * ((t - 1 - s2)/(-1 -
s2)) + ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 - (2 * (-1 - s2) *
(-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t -
1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
(1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) + (((1/(1 +
s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 +
s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 +
s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 +
s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))))/(((t - s1)/(-1 - s1)) *
((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 + s1) *
(1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t +
s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1))) + 0)^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2pos.A0.noA3.x.R
|
xsplineTangent.s1pos.s2pos.A0.noA3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(-1 - s1) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * ((t - s1)/(-1 - s1)) + ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) *
((2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) +
((6 - (2 * (-1 - s1) * (-1 - s1))) * (1/(-1 - s1)) *
((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * (1/(-1 - s1))))) *
py0 + (((1/(-1 - s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 -
s2)/(-1 - s2)) * (1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 *
(-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * (1/(-1 - s2)) + ((6 -
(2 * (-1 - s2) * (-1 - s2))) * (1/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) * py1 + (((1/(1 + s1) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 + s1))) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 + s1)) +
(2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) +
(6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))) * py2)/(((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 -
(2 * (-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 -
s1)) - 15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) *
(-1 - s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t -
1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
0) - (((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((t -
s1)/(-1 - s1)) * (10 - (2 * (-1 - s1) * (-1 - s1)) + (2 *
(2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 - s1)) +
(6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) *
((t - s1)/(-1 - s1))) * py0 + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * (10 -
(2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 -
s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2))) * py1 + ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * (10 - (2 * (1 + s1) * (1 + s1)) + (2 *
(2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) + (6 -
(2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1))) * py2 + 0 * py3) * (((1/(-1 - s1) * ((t -
s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * (1/(-1 - s1))) *
((t - s1)/(-1 - s1)) + ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 -
s1)) * (1/(-1 - s1))) * (10 - (2 * (-1 - s1) * (-1 - s1)) +
(2 * (2 * (-1 - s1) * (-1 - s1)) - 15) * ((t - s1)/(-1 -
s1)) + (6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 -
s1)) * ((t - s1)/(-1 - s1))) + ((t - s1)/(-1 - s1)) * ((t -
s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * ((2 * (2 * (-1 -
s1) * (-1 - s1)) - 15) * (1/(-1 - s1)) + ((6 - (2 * (-1 -
s1) * (-1 - s1))) * (1/(-1 - s1)) * ((t - s1)/(-1 - s1)) +
(6 - (2 * (-1 - s1) * (-1 - s1))) * ((t - s1)/(-1 - s1)) *
(1/(-1 - s1)))) + (((1/(-1 - s2) * ((t - 1 - s2)/(-1 -
s2)) + ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 - (2 * (-1 - s2) *
(-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t -
1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
(1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) + (((1/(1 +
s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 +
s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 +
s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 +
s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))))/(((t - s1)/(-1 - s1)) *
((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1)) * (10 - (2 *
(-1 - s1) * (-1 - s1)) + (2 * (2 * (-1 - s1) * (-1 - s1)) -
15) * ((t - s1)/(-1 - s1)) + (6 - (2 * (-1 - s1) * (-1 -
s1))) * ((t - s1)/(-1 - s1)) * ((t - s1)/(-1 - s1))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 + s1) *
(1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t +
s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1))) + 0)^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2pos.A0.noA3.y.R
|
xsplineTangent.s1pos.s2pos.noA0.A3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(-1 - s2) * ((t - 1 - s2)/(-1 - s2)) + ((t -
1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * ((t - 1 - s2)/(-1 -
s2)) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * (1/(-1 - s2)) + ((6 -
(2 * (-1 - s2) * (-1 - s2))) * (1/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) * px1 + (((1/(1 + s1) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 + s1))) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 + s1)) +
(2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) +
(6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))) * px2 + (((1/(1 + s2) *
((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * (1/(1 +
s2))) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) *
((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 - (2 * (1 +
s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) + ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((2 * (2 * (1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) +
((6 - (2 * (1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))))) * px3)/(0 + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 + s1) *
(1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t +
s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1))) + ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * (10 - (2 *
(1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)))) - (0 *
px0 + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) * px1 + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) *
px2 + ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) *
((t - 1 + s2)/(1 + s2)) * (10 - (2 * (1 + s2) * (1 + s2)) +
(2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2))) * px3) * (((1/(-1 - s2) *
((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 - (2 * (-1 -
s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
(1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2)))) + (((1/(1 +
s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 +
s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 +
s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 +
s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))) + (((1/(1 + s2) * ((t -
1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) *
((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 - (2 * (1 + s2) *
(1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t -
1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) + ((t - 1 +
s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((2 * (2 * (1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) +
((6 - (2 * (1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))))))/(0 + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
(10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) *
(-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 *
(-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 + s1) *
(1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t +
s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1))) + ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * (10 - (2 *
(1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2pos.noA0.A3.x.R
|
xsplineTangent.s1pos.s2pos.noA0.A3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(-1 - s2) * ((t - 1 - s2)/(-1 - s2)) + ((t -
1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * ((t - 1 - s2)/(-1 -
s2)) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * (1/(-1 - s2)) + ((6 -
(2 * (-1 - s2) * (-1 - s2))) * (1/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) * py1 + (((1/(1 + s1) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 + s1))) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 + s1)) +
(2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) +
(6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))) * py2 + (((1/(1 + s2) *
((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * (1/(1 +
s2))) * ((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) *
((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 - (2 * (1 +
s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) + ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((2 * (2 * (1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) +
((6 - (2 * (1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))))) * py3)/(0 + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 + s1) *
(1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t +
s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1))) + ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * (10 - (2 *
(1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)))) - (0 *
py0 + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) * py1 + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) *
py2 + ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) *
((t - 1 + s2)/(1 + s2)) * (10 - (2 * (1 + s2) * (1 + s2)) +
(2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t - 1 + s2)/(1 +
s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t - 1 + s2)/(1 +
s2)) * ((t - 1 + s2)/(1 + s2))) * py3) * (((1/(-1 - s2) *
((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) * (1/(-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 - (2 * (-1 -
s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) - 15) *
(1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) * (1/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 -
s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2)))) + (((1/(1 +
s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 +
s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 +
s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 +
s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))) + (((1/(1 + s2) * ((t -
1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * (1/(1 + s2))) *
((t - 1 + s2)/(1 + s2)) + ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))) * (10 - (2 * (1 + s2) *
(1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) * ((t -
1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))) + ((t - 1 +
s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 +
s2)) * ((2 * (2 * (1 + s2) * (1 + s2)) - 15) * (1/(1 + s2)) +
((6 - (2 * (1 + s2) * (1 + s2))) * (1/(1 + s2)) * ((t - 1 +
s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) * ((t -
1 + s2)/(1 + s2)) * (1/(1 + s2))))))/(0 + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
(10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) *
(-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 *
(-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 + s1) *
(1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t +
s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1))) + ((t - 1 + s2)/(1 + s2)) * ((t -
1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2)) * (10 - (2 *
(1 + s2) * (1 + s2)) + (2 * (2 * (1 + s2) * (1 + s2)) - 15) *
((t - 1 + s2)/(1 + s2)) + (6 - (2 * (1 + s2) * (1 + s2))) *
((t - 1 + s2)/(1 + s2)) * ((t - 1 + s2)/(1 + s2))))^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2pos.noA0.A3.y.R
|
xsplineTangent.s1pos.s2pos.noA0.noA3.x <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(-1 - s2) * ((t - 1 - s2)/(-1 - s2)) + ((t -
1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * ((t - 1 - s2)/(-1 -
s2)) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * (1/(-1 - s2)) + ((6 -
(2 * (-1 - s2) * (-1 - s2))) * (1/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) * px1 + (((1/(1 + s1) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 + s1))) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 + s1)) +
(2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) +
(6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))) * px2)/(0 + ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 -
s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 -
(2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 + s1) * (1 + s1)) +
(2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) +
(6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1))) + 0) - (0 * px0 + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
(10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) *
(-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 *
(-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) * px1 + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) * px2 + 0 * px3) * (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 -
(2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 -
s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) -
15) * (1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) *
(1/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 -
s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2)))) +
(((1/(1 + s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) *
(1/(1 + s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 *
(1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) -
15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 +
s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) - 15) * (1/(1 +
s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * (1/(1 + s1))))))/(0 +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t -
1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
0)^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2pos.noA0.noA3.x.R
|
xsplineTangent.s1pos.s2pos.noA0.noA3.y <- function(px0, px1, px2, px3, py0, py1, py2, py3, s1, s2, t) {
(((((1/(-1 - s2) * ((t - 1 - s2)/(-1 - s2)) + ((t -
1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * ((t - 1 - s2)/(-1 -
s2)) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) +
(6 - (2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((2 *
(2 * (-1 - s2) * (-1 - s2)) - 15) * (1/(-1 - s2)) + ((6 -
(2 * (-1 - s2) * (-1 - s2))) * (1/(-1 - s2)) * ((t - 1 -
s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * (1/(-1 - s2))))) * py1 + (((1/(1 + s1) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * (1/(1 + s1))) *
((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * (1/(1 + s1))) * (10 - (2 * (1 + s1) * (1 + s1)) +
(2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) +
(6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) -
15) * (1/(1 + s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) *
((t + s1)/(1 + s1)) * (1/(1 + s1))))) * py2)/(0 + ((t - 1 -
s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 -
s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 -
(2 * (-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) + ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 + s1) * (1 + s1)) +
(2 * (2 * (1 + s1) * (1 + s1)) - 15) * ((t + s1)/(1 + s1)) +
(6 - (2 * (1 + s1) * (1 + s1))) * ((t + s1)/(1 + s1)) * ((t +
s1)/(1 + s1))) + 0) - (0 * py0 + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
(10 - (2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) *
(-1 - s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 *
(-1 - s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2))) * py1 + ((t + s1)/(1 + s1)) *
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * (10 - (2 * (1 +
s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) - 15) *
((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 + s1))) * ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1))) * py2 + 0 * py3) * (((1/(-1 -
s2) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 - s2)) *
(1/(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) + ((t - 1 - s2)/(-1 -
s2)) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2))) * (10 -
(2 * (-1 - s2) * (-1 - s2)) + (2 * (2 * (-1 - s2) * (-1 -
s2)) - 15) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 - s2) *
(-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 -
s2))) + ((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) *
((t - 1 - s2)/(-1 - s2)) * ((2 * (2 * (-1 - s2) * (-1 - s2)) -
15) * (1/(-1 - s2)) + ((6 - (2 * (-1 - s2) * (-1 - s2))) *
(1/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) + (6 - (2 * (-1 -
s2) * (-1 - s2))) * ((t - 1 - s2)/(-1 - s2)) * (1/(-1 - s2)))) +
(((1/(1 + s1) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 + s1)) *
(1/(1 + s1))) * ((t + s1)/(1 + s1)) + ((t + s1)/(1 +
s1)) * ((t + s1)/(1 + s1)) * (1/(1 + s1))) * (10 - (2 *
(1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 + s1)) -
15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) * (1 +
s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 +
s1)) * ((2 * (2 * (1 + s1) * (1 + s1)) - 15) * (1/(1 +
s1)) + ((6 - (2 * (1 + s1) * (1 + s1))) * (1/(1 +
s1)) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * (1/(1 + s1))))))/(0 +
((t - 1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2)) * ((t -
1 - s2)/(-1 - s2)) * (10 - (2 * (-1 - s2) * (-1 - s2)) +
(2 * (2 * (-1 - s2) * (-1 - s2)) - 15) * ((t - 1 - s2)/(-1 -
s2)) + (6 - (2 * (-1 - s2) * (-1 - s2))) * ((t -
1 - s2)/(-1 - s2)) * ((t - 1 - s2)/(-1 - s2))) + ((t +
s1)/(1 + s1)) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1)) *
(10 - (2 * (1 + s1) * (1 + s1)) + (2 * (2 * (1 + s1) * (1 +
s1)) - 15) * ((t + s1)/(1 + s1)) + (6 - (2 * (1 + s1) *
(1 + s1))) * ((t + s1)/(1 + s1)) * ((t + s1)/(1 + s1))) +
0)^2)
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/R/xsplineTangent.s1pos.s2pos.noA0.noA3.y.R
|
pdf("edges-tests.pdf", compress=FALSE)
library(vwline)
grid.offsetBezier(c(.2, .4, .6, .8), c(.1, .3, .3, .1),
w=c(0, .1, .1, 0), name="b1")
grid.offsetBezier(c(.2, .4, .6, .8), c(.1, .3, .3, .1) + .3,
w=widthSpline(c(0, .1, .1, 0)), name="b2")
grid.offsetBezier(c(.2, .4, .6, .8), c(.1, .3, .3, .1) + .6,
w=BezierWidth(c(0, .1, .1, 0)), name="b3")
dots <- function(x) {
pts <- edgePoints(grid.get(x), unit(1:5, "cm"), .2, .1, dir="backwards")
grid.circle(pts$x, pts$y, r=unit(1, "mm"), gp=gpar(fill=grey(1:5/5)))
}
dots("b1")
dots("b2")
dots("b3")
dev.off()
savedPDF <- system.file("regression-tests", "edges-tests.save.pdf",
package="vwline")
diff <- tools::Rdiff("edges-tests.pdf", savedPDF)
if (diff != 0L) {
## If differences found, generate images of the differences and error out
system("pdfseparate edges-tests.pdf edges-test-pages-%d.pdf")
system(paste0("pdfseparate ", savedPDF, " edges-model-pages-%d.pdf"))
modelFiles <- list.files(pattern="edges-model-pages-.*")
N <- length(modelFiles)
for (i in 1:N) {
system(paste0("compare edges-model-pages-", i, ".pdf ",
"edges-test-pages-", i, ".pdf ",
"edges-diff-pages-", i, ".png"))
}
stop("Regression testing detected differences")
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/inst/regression-tests/edges.R
|
pdf("endsjoins-tests.pdf", compress=FALSE)
library(vwline)
pts <- function(x, y, col="grey") {
if (length(x)) {
grid.points(x, y, default.units="in", size=unit(2, "mm"), pch=16,
gp=gpar(col=col))
}
}
lines <- function(x, y, col="grey") {
if (length(x)) {
grid.lines(x, y, default.units="in", gp=gpar(col=col))
}
}
simpleLine <- function(x, y, w) {
pushViewport(viewport(layout=grid.layout(2, 2)))
pushViewport(viewport(layout.pos.row=1, layout.pos.col=1))
pts(x, y)
lines(x, y)
grid.vwline(x, y, w, default.units="in", debug=TRUE, gp=gpar(col="black"))
popViewport()
pushViewport(viewport(layout.pos.row=1, layout.pos.col=2))
pts(x, y)
lines(x, y)
grid.vwline(x, y, w, default.units="in",
gp=gpar(col="black", fill=rgb(0,0,0,.2)),
linejoin="round", lineend="round")
popViewport()
pushViewport(viewport(layout.pos.row=2, layout.pos.col=1))
pts(x, y)
lines(x, y)
grid.vwline(x, y, w, default.units="in",
gp=gpar(col="black", fill=rgb(0,0,0,.2)),
linejoin="mitre", lineend="mitre")
popViewport()
pushViewport(viewport(layout.pos.row=2, layout.pos.col=2))
pts(x, y)
lines(x, y)
grid.vwline(x, y, w, default.units="in",
gp=gpar(col="black", fill=rgb(0,0,0,.2)),
linejoin="bevel", lineend="square")
popViewport()
popViewport()
}
## Non-variable line width (different line endings)
grid.newpage()
scale <- .5
pushViewport(viewport(layout=grid.layout(2, 2)))
x <- scale*c(1, 2)
y <- scale*c(1, 2)
w <- scale*c(1, 1)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=1))
simpleLine(x, y, w)
popViewport()
x <- scale*c(1, 2)
y <- scale*c(2, 1)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=2))
simpleLine(x, y, w)
popViewport()
x <- scale*c(1, 2)
y <- scale*c(1, 1)
pushViewport(viewport(layout.pos.row=2, layout.pos.col=1))
simpleLine(x, y, w)
popViewport()
x <- scale*c(1, 1)
y <- scale*c(1, 2)
pushViewport(viewport(layout.pos.row=2, layout.pos.col=2))
simpleLine(x, y, w)
popViewport()
## Simple line segment horiz/vert round/square/mitre (and mitre-limit)
grid.newpage()
scale <- .5
pushViewport(viewport(layout=grid.layout(2, 2)))
x <- scale*c(1, 2)
y <- scale*c(1, 1)
w <- scale*c(.5, 1)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=1))
simpleLine(x, y, w)
popViewport()
x <- scale*c(2, 1)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=2))
simpleLine(x, y, w)
popViewport()
x <- scale*c(1, 1)
y <- scale*c(1, 2)
pushViewport(viewport(layout.pos.row=2, layout.pos.col=1))
simpleLine(x, y, w)
popViewport()
y <- scale*c(2, 1)
pushViewport(viewport(layout.pos.row=2, layout.pos.col=2))
simpleLine(x, y, w)
popViewport()
## Simple single corner, left width != right width (different line joins/ends)
## end width decreasing
grid.newpage()
scale <- .5
pushViewport(viewport(layout=grid.layout(2, 2)))
x <- scale*c(1, 2, 3)
y <- scale*c(1, 1, 2)
w <- scale*c(.5, 1, .1)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=1))
simpleLine(x, y, list(left=.5*w, right=.25*rev(w)))
popViewport()
x <- scale*c(3, 2, 1)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=2))
simpleLine(x, y, list(left=.5*w, right=.25*rev(w)))
popViewport()
x <- scale*c(1, 1, 2)
y <- scale*c(1, 2, 3)
pushViewport(viewport(layout.pos.row=2, layout.pos.col=1))
simpleLine(x, y, list(left=.5*w, right=.25*rev(w)))
popViewport()
y <- scale*c(3, 2, 1)
pushViewport(viewport(layout.pos.row=2, layout.pos.col=2))
simpleLine(x, y, list(left=.5*w, right=.25*rev(w)))
popViewport()
## Simple single corner, left width != right width (different line joins/ends)
## end width increasing
grid.newpage()
scale <- .5
pushViewport(viewport(layout=grid.layout(2, 2)))
x <- scale*c(1, 2, 3)
y <- scale*c(1, 1, 2)
w <- scale*c(1, .1, .5)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=1))
simpleLine(x, y, list(left=.5*w, right=.25*rev(w)))
popViewport()
x <- scale*c(3, 2, 1)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=2))
simpleLine(x, y, list(left=.5*w, right=.25*rev(w)))
popViewport()
x <- scale*c(1, 1, 2)
y <- scale*c(1, 2, 3)
pushViewport(viewport(layout.pos.row=2, layout.pos.col=1))
simpleLine(x, y, list(left=.5*w, right=.25*rev(w)))
popViewport()
y <- scale*c(3, 2, 1)
pushViewport(viewport(layout.pos.row=2, layout.pos.col=2))
simpleLine(x, y, list(left=.5*w, right=.25*rev(w)))
popViewport()
## Crazy inner corners
grid.newpage()
scale <- .5
pushViewport(viewport(layout=grid.layout(2, 2)))
## Inner edges stick out
x <- scale*c(1, 2, 3)
y <- scale*c(1, 1.5, 1)
w <- scale*c(.2, 2, .2)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=1))
simpleLine(x, y, w)
popViewport()
## One inner edge sticks out
x <- scale*c(1, 2, 3)
y <- scale*c(1, 1.5, 1)
w <- scale*c(.2, 1.5, 1.5)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=2))
simpleLine(x, y, w)
popViewport()
## One inner edge MISSES other
x <- scale*c(1, 2, 3)
y <- scale*c(1, 1.5, 1)
w <- scale*c(.2, 2, 2)
pushViewport(viewport(layout.pos.row=2, layout.pos.col=1))
simpleLine(x, y, w)
popViewport()
## One inner edge MISSES other (reverse orientation)
x <- scale*rev(c(1, 2, 3))
y <- scale*c(1, 1.5, 1)
w <- scale*c(.2, 2, 2)
pushViewport(viewport(layout.pos.row=2, layout.pos.col=2))
simpleLine(x, y, w)
popViewport()
grid.newpage()
scale <- .5
pushViewport(viewport(layout=grid.layout(2, 2)))
## Psycho case
x <- scale*c(1, 1, 1.5)
y <- scale*c(2, 1.5, .5)
w <- scale*c(1, .2, 0)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=1))
simpleLine(x, y, w)
popViewport()
## Square end becomes mitre
x <- scale*c(1, 1.2)
y <- scale*c(1, 1)
w <- scale*c(.3, 1.5)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=2))
simpleLine(x, y, w)
popViewport()
## One outer edge MISSES other
x <- scale*c(1.5, 2, 3)
y <- scale*c(1, 1.5, 1)
w <- scale*c(2, .5, .5)
pushViewport(viewport(layout.pos.row=2, layout.pos.col=1))
simpleLine(x, y, w)
popViewport()
## One outer edge MISSES other (reverse orientation)
x <- scale*c(3, 2.5, 1.5)
y <- scale*c(1, 1.5, 1)
w <- scale*c(2, .5, .5)
pushViewport(viewport(layout.pos.row=2, layout.pos.col=2))
simpleLine(x, y, w)
popViewport()
## Crazy line
grid.newpage()
scale <- .3
x <- (1 + c(1, 3, 5, 7, 9, 9))*scale
y <- (1 + c(2, 4, 4, 5, 6, 2))*scale
w <- 2*c(.5, 1, .5, .2, .7, 0)*scale
pushViewport(viewport(layout=grid.layout(3, 2)))
pushViewport(viewport(layout.pos.row=1, layout.pos.col=1))
pts(x, y)
lines(x, y)
popViewport()
pushViewport(viewport(layout.pos.row=2, layout.pos.col=1))
grid.vwline(x, y, w, default.units="in", debug=TRUE, gp=gpar(col="black"))
popViewport()
pushViewport(viewport(layout.pos.row=1, layout.pos.col=2))
pts(x, y)
lines(x, y)
grid.vwline(x, y, w, default.units="in",
gp=gpar(col="black", fill=rgb(0,0,0,.2)),
linejoin="round", lineend="round")
popViewport()
pushViewport(viewport(layout.pos.row=2, layout.pos.col=2))
pts(x, y)
lines(x, y)
grid.vwline(x, y, w, default.units="in",
gp=gpar(col="black", fill=rgb(0,0,0,.2)),
linejoin="mitre", lineend="mitre")
popViewport()
pushViewport(viewport(layout.pos.row=3, layout.pos.col=2))
pts(x, y)
lines(x, y)
grid.vwline(x, y, w, default.units="in",
gp=gpar(col="black", fill=rgb(0,0,0,.2)),
linejoin="bevel", lineend="square")
popViewport()
## Crazy line (stepWidth)
grid.newpage()
scale <- .3
x <- (1 + c(1, 3, 5, 7, 9, 9))*scale
y <- (1 + c(2, 4, 4, 5, 6, 2))*scale
w <- 2*c(.5, 1, .5, .2, .7, 0)*scale
pushViewport(viewport(layout=grid.layout(3, 2)))
pushViewport(viewport(layout.pos.row=1, layout.pos.col=1))
pts(x, y)
lines(x, y)
popViewport()
pushViewport(viewport(layout.pos.row=2, layout.pos.col=1))
grid.vwline(x, y, w, default.units="in", stepWidth=TRUE,
debug=TRUE, gp=gpar(col="black"))
popViewport()
pushViewport(viewport(layout.pos.row=1, layout.pos.col=2))
pts(x, y)
lines(x, y)
grid.vwline(x, y, w, default.units="in", stepWidth=TRUE,
gp=gpar(col="black", fill=rgb(0,0,0,.2)),
linejoin="round", lineend="round")
popViewport()
pushViewport(viewport(layout.pos.row=2, layout.pos.col=2))
pts(x, y)
lines(x, y)
grid.vwline(x, y, w, default.units="in", stepWidth=TRUE,
gp=gpar(col="black", fill=rgb(0,0,0,.2)),
linejoin="mitre", lineend="mitre")
popViewport()
pushViewport(viewport(layout.pos.row=3, layout.pos.col=2))
pts(x, y)
lines(x, y)
grid.vwline(x, y, w, default.units="in", stepWidth=TRUE,
gp=gpar(col="black", fill=rgb(0,0,0,.2)),
linejoin="bevel", lineend="square")
popViewport()
## Tests of corners
## 'x' and 'y' should be three values
## 'owidths' should be nine values
testCorners <- function(x, y, leftwidth, midwidth, rightwidth) {
pushViewport(viewport(layout=grid.layout(3, 3)))
for (i in 1:3) {
for (j in 1:3) {
pushViewport(viewport(layout.pos.row=i, layout.pos.col=j))
grid.rect(gp=gpar(col="grey"))
wi <- (i-1)*3 + j
simpleLine(x, y, c(leftwidth[wi], midwidth[wi], rightwidth[wi]))
popViewport()
}
}
popViewport()
}
grid.newpage()
scale <- .25
x <- scale*c(1, 2, 3)
y <- scale*c(1, 1, .5)
mw <- scale*rep(.3, 9)
lw <- scale*seq(.1, .9, .1)
rw <- scale*seq(.1, .9, .1)
testCorners(x, y, lw, mw, rw)
grid.newpage()
scale <- .25
x <- scale*c(1, 2, 3)
y <- scale*c(1, 1, .5)
mw <- scale*rep(1.5, 9)
lw <- scale*seq(.1, .9, .1)
rw <- scale*seq(.1, .9, .1)
testCorners(x, y, lw, mw, rw)
grid.newpage()
scale <- .25
x <- scale*c(1, 2, 3)
y <- scale*c(1, 1, .5)
mw <- scale*rep(.3, 9)
lw <- scale*seq(.1, .9, .1)
rw <- scale*seq(.9, .1, -.1)
testCorners(x, y, lw, mw, rw)
## Test mitre join becoming bevel join
grid.newpage()
x <- c(.1, .15, .2)
y <- c(.4, .5, .4)
w <- unit(rep(5, 3), "mm")
grid.vwline(x, y, w, linejoin="mitre")
grid.text("within mitre limit (4)", x=.15, y=.55, just="left", rot=90)
x <- c(.3, .35, .4)
y <- c(.3, .7, .3)
grid.vwline(x, y, w, linejoin="mitre")
grid.text("exceeds mitre limit (4)", x=.35, y=.25)
x <- c(.5, .55, .6)
y <- c(.4, .5, .4)
grid.vwline(x, y, w, linejoin="mitre", mitrelimit=1)
grid.text("exceeds mitre limit (1)", x=.55, y=.55, just="left", rot=90)
x <- c(.7, .75, .8)
y <- c(.3, .7, .3)
grid.vwline(x, y, w, linejoin="mitre", mitrelimit=10)
grid.text("within mitre limit (10)", x=.75, y=.25)
## Tests for sharp corner, large change in width, stepWidth=TRUE
## 'len' is length of second segment
## 'width' is width of second segment
drawLine <- function(len, width, debug=FALSE, rev=FALSE) {
x <- c(.2, .6, .6)
y <- c(.2, .8, .8 - len)
w <- c(.1, width, 0)
if (rev) {
x <- rev(x)
y <- rev(y)
w <- c(width, .1, 0)
}
if (debug) {
grid.vwline(x, y, w, stepWidth=TRUE, debug=TRUE, linejoin="mitre",
gp=gpar(col="black"))
} else {
grid.vwline(x, y, w, stepWidth=TRUE, linejoin="mitre",
gp=gpar(col="black", fill=rgb(0,0,0,.2)))
}
}
drawPage <- function(params, debug=FALSE, rev=FALSE) {
N <- nrow(params)
dims <- n2mfrow(N)
grid.newpage()
pushViewport(viewport(layout=grid.layout(dims[1], dims[2], respect=TRUE)))
for (i in 1:N) {
row <- (i - 1) %/% dims[2] + 1
col <- (i - 1) %% dims[2] + 1
pushViewport(viewport(layout.pos.col=col, layout.pos.row=row))
drawLine(params[i,1], params[i,2], debug, rev)
popViewport()
}
}
params <- rbind(c(.03, .05),
c(.1, .05), # rt edge of 2nd seg entirely within 1st seg
c(.1, .1), # rt edge of 2nd seg entirely within 1st seg
c(.1, .4), # rt edge of 2nd seg entirely wrong side of 1st seg
c(.3, .4), # rt edge of 2nd seg ends within 1st seg
c(.4, .4), # rt edge of 2nd seg ends within 1st seg
c(.7, .8), # rt edge of 2nd seg intersects start end of 1st seg
c(.7, .9), # rt edge of 1st seg entirely within 2nd seg
## (sane case)
c(.4, .1) # rt edge of 2nd seg intersects rt edge of 1st seg
)
drawPage(params, debug=TRUE)
drawPage(params, debug=FALSE)
drawPage(params, debug=TRUE, rev=TRUE)
drawPage(params, debug=FALSE, rev=TRUE)
grid.newpage()
## offsetBezier corners
grid.offsetBezier(c(1:7/8), c(.1, .2, .2, .1, .2, .2, .1),
w=unit(1:7/8, "cm"),
lineend="round")
## NOTE that the mitre ends exceed the mitrelimit (so are just square)
grid.offsetBezier(c(1:7/8), c(.1, .2, .2, .1, .2, .2, .1) + .2,
w=unit(1:7/8, "cm"),
linejoin="mitre",
lineend="mitre")
grid.offsetBezier(c(1:7/8), c(.1, .2, .2, .1, .2, .2, .1) + .4,
w=unit(1:7/8, "cm"),
linejoin="bevel",
lineend="square")
library(vwline)
grid.newpage()
## MitreLimit will "blunt" extensions
grid.offsetBezier(c(.1, .15, .3, .4, .5, .65, .7),
c(.1, .2, .2, .1, .2, .2, .1) + .2,
w=BezierWidth(unit(1:7/8, "cm")),
linejoin="extend",
lineend="extend",
gp=gpar(col="black"))
grid.offsetBezier(c(.1, .15, .3, .4, .5, .65, .7),
c(.1, .2, .2, .1, .2, .2, .1) + .2,
w=BezierWidth(unit(1:7/8, "cm")),
linejoin="mitre",
lineend="mitre",
gp=gpar(col=NA, fill=rgb(0,0,0,.2)))
## Curl at join is such that outside edges do not meet
grid.offsetBezier(c(.1, .15, .35, .4, .45, .65, .7),
c(.1, .2, .2, .1, .2, .2, .1) + .6,
w=BezierWidth(unit(1:7/8, "cm")),
linejoin="extend",
lineend="extend",
gp=gpar(col="black"))
grid.offsetBezier(c(.1, .15, .35, .4, .45, .65, .7),
c(.1, .2, .2, .1, .2, .2, .1) + .6,
w=BezierWidth(unit(1:7/8, "cm")),
linejoin="mitre",
lineend="mitre",
gp=gpar(col=NA, fill=rgb(0,0,0,.2)))
grid.newpage()
## Relax mitrelimit
grid.offsetBezier(c(.1, .15, .3, .4, .5, .65, .7),
c(.1, .2, .2, .1, .2, .2, .1) + .2,
w=BezierWidth(unit(1:7/8, "cm")),
linejoin="extend",
lineend="extend",
mitrelimit=40,
gp=gpar(col="black"))
grid.offsetBezier(c(.1, .15, .3, .4, .5, .65, .7),
c(.1, .2, .2, .1, .2, .2, .1) + .2,
w=BezierWidth(unit(1:7/8, "cm")),
linejoin="mitre",
lineend="mitre",
mitrelimit=30,
gp=gpar(col=NA, fill=rgb(0,0,0,.2)))
## Curl at join is such that outside edges do not meet
grid.offsetBezier(c(.1, .15, .35, .4, .45, .65, .7),
c(.1, .2, .2, .1, .2, .2, .1) + .6,
w=BezierWidth(unit(1:7/8, "cm")),
linejoin="extend",
lineend="extend",
mitrelimit=40,
gp=gpar(col="black"))
grid.offsetBezier(c(.1, .15, .35, .4, .45, .65, .7),
c(.1, .2, .2, .1, .2, .2, .1) + .6,
w=BezierWidth(unit(1:7/8, "cm")),
linejoin="mitre",
lineend="mitre",
mitrelimit=30,
gp=gpar(col=NA, fill=rgb(0,0,0,.2)))
dev.off()
savedPDF <- system.file("regression-tests", "endsjoins-tests.save.pdf",
package="vwline")
diff <- tools::Rdiff("endsjoins-tests.pdf", savedPDF)
if (diff != 0L) {
## If differences found, generate images of the differences and error out
system("pdfseparate endsjoins-tests.pdf endsjoins-test-pages-%d.pdf")
system(paste0("pdfseparate ", savedPDF, " endsjoins-model-pages-%d.pdf"))
modelFiles <- list.files(pattern="endsjoins-model-pages-.*")
N <- length(modelFiles)
for (i in 1:N) {
system(paste0("compare endsjoins-model-pages-", i, ".pdf ",
"endsjoins-test-pages-", i, ".pdf ",
"endsjoins-diff-pages-", i, ".png"))
}
stop("Regression testing detected differences")
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/inst/regression-tests/endsjoins.R
|
pdf("methods-tests.pdf", compress=FALSE)
## Generate a variety of variable-width shapes with different methods
library(vwline)
N <- 10
grid.newpage()
heights <- unit(rep(1, N+1), c("lines", rep("null", N)))
pushViewport(viewport(layout=grid.layout(N+1, 6, heights=heights)))
pushViewport(viewport(layout.pos.row=1, layout.pos.col=1),
viewport(width=.8, height=.8))
grid.text("vwcurve", gp=gpar(fontfamily="mono", cex=.7))
popViewport(2)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=2),
viewport(width=.8, height=.8))
grid.text("vwXspline", gp=gpar(fontfamily="mono", cex=.7))
popViewport(2)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=3),
viewport(width=.8, height=.8))
grid.text("vwline", gp=gpar(fontfamily="mono", cex=.7))
popViewport(2)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=4),
viewport(width=.8, height=.8))
grid.text("brushXspline", gp=gpar(fontfamily="mono", cex=.7))
popViewport(2)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=5),
viewport(width=.8, height=.8))
grid.text("offsetXspline", gp=gpar(fontfamily="mono", cex=.7))
popViewport(2)
pushViewport(viewport(layout.pos.row=1, layout.pos.col=6),
viewport(width=.8, height=.8))
grid.text("offsetBezier", gp=gpar(fontfamily="mono", cex=.7))
popViewport(2)
testLine <- function(x, y, w, row,
...,
vwcurveArgs=list(),
vwXsplineArgs=list(),
vwlineArgs=list(),
brushXsplineArgs=list(brush=verticalBrush),
offsetXsplineArgs=list(),
offsetBezierArgs=list()) {
pushViewport(viewport(layout.pos.row=row, layout.pos.col=1),
viewport(width=.8, height=.8))
do.call(grid.vwcurve,
c(list(x=x, y=y, w=w), vwcurveArgs, list(...)))
popViewport(2)
pushViewport(viewport(layout.pos.row=row, layout.pos.col=2),
viewport(width=.8, height=.8))
do.call(grid.vwXspline,
c(list(x=x, y=y, w=w), vwXsplineArgs, list(...)))
popViewport(2)
pushViewport(viewport(layout.pos.row=row, layout.pos.col=3),
viewport(width=.8, height=.8))
do.call(grid.vwline,
c(list(x=x, y=y, w=w), vwlineArgs, list(...)))
popViewport(2)
pushViewport(viewport(layout.pos.row=row, layout.pos.col=4),
viewport(width=.8, height=.8))
## brushXspline ignores 'lineend'
dotargs <- list(...)
dotargs$lineend <- NULL
do.call(grid.brushXspline,
c(list(x=x, y=y, w=w), brushXsplineArgs, dotargs))
popViewport(2)
pushViewport(viewport(layout.pos.row=row, layout.pos.col=5),
viewport(width=.8, height=.8))
do.call(grid.offsetXspline,
c(list(x=x, y=y, w=w), offsetXsplineArgs, list(...)))
popViewport(2)
pushViewport(viewport(layout.pos.row=row, layout.pos.col=6),
viewport(width=.8, height=.8))
do.call(grid.offsetBezier,
c(list(x=x, y=y, w=w), offsetBezierArgs, list(...)))
popViewport(2)
}
testLine(0:3/3, rep(.5, 4), unit(rep(1, 4), "mm"), row=2)
testLine(0:3/3, rep(.5, 4), unit(1:4, "mm"), row=3)
testLine(c(0, 0, 1, 1, .6, .4), c(.2, 1, 1, .2, 0, 0),
unit(c(1:3, 3:1), "mm"), open=FALSE, row=4)
testLine(0:3/3, c(.8, .2, .8, .2), unit(1:4, "mm"), row=5, lineend="round",
brushXsplineArgs=list(brush=circleBrush()))
dev.off()
savedPDF <- system.file("regression-tests", "methods-tests.save.pdf",
package="vwline")
diff <- tools::Rdiff("methods-tests.pdf", savedPDF)
if (diff != 0L) {
## If differences found, generate images of the differences and error out
system("pdfseparate methods-tests.pdf methods-test-pages-%d.pdf")
system(paste0("pdfseparate ", savedPDF, " methods-model-pages-%d.pdf"))
modelFiles <- list.files(pattern="methods-model-pages-.*")
N <- length(modelFiles)
for (i in 1:N) {
system(paste0("compare methods-model-pages-", i, ".pdf ",
"methods-test-pages-", i, ".pdf ",
"methods-diff-pages-", i, ".png"))
}
stop("Regression testing detected differences")
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/inst/regression-tests/test-methods.R
|
pdf("widths-tests.pdf", compress=FALSE)
library(vwline)
grid.offsetBezier(c(.2, .4, .6, .8), c(.1, .3, .3, .1),
w=c(0, .1, .1, 0))
grid.offsetBezier(c(.2, .4, .6, .8), c(.1, .3, .3, .1) + .3,
w=widthSpline(c(0, .1, .1, 0)))
grid.offsetBezier(c(.2, .4, .6, .8), c(.1, .3, .3, .1) + .6,
w=BezierWidth(c(0, .1, .1, 0)))
dev.off()
savedPDF <- system.file("regression-tests", "widths-tests.save.pdf",
package="vwline")
diff <- tools::Rdiff("widths-tests.pdf", savedPDF)
if (diff != 0L) {
## If differences found, generate images of the differences and error out
system("pdfseparate widths-tests.pdf widths-test-pages-%d.pdf")
system(paste0("pdfseparate ", savedPDF, " widths-model-pages-%d.pdf"))
modelFiles <- list.files(pattern="widths-model-pages-.*")
N <- length(modelFiles)
for (i in 1:N) {
system(paste0("compare widths-model-pages-", i, ".pdf ",
"widths-test-pages-", i, ".pdf ",
"widths-diff-pages-", i, ".png"))
}
stop("Regression testing detected differences")
}
|
/scratch/gouwar.j/cran-all/cranData/vwline/inst/regression-tests/widths.R
|
################################################################################
#
# cache
#
################################################################################
SYMB_CACHE_FOUND <- "[cache was found]"
SYMB_CACHE_SAVED <- "[cache was saved]"
SYMB_CACHE_LOAD <- "[cache was loaded]"
should_I_check_cache <- function(cache = TRUE) {
return((exists("GlobalCacheOption",
envir = rlang::global_env()
) && get("GlobalCacheOption") == T) && cache)
}
na_if_null <- function(value) {
if (is.null(value)) {
return(NA)
}
return(value)
}
check_package_installed <- function(package = "testthat") {
.check <- FALSE
try({
.check <- rlang::is_installed(package)
})
return(.check)
}
get_input_from_user <- function(prompt = "Enter any number : ", as.int = T, default.when.testing = 1) {
if (check_package_installed("testthat") && testthat::is_testing()) {
return(default.when.testing)
}
var <- readline(prompt = prompt)
if (as.int) {
var <- as.integer(var)
}
var
}
get_user_choice_cache_folder <- function() {
msg1 <- '
While requesting from data sources if you like to use more efficient requests you may
choose cache = T in that case vyos package saves the result of the requests to a temporary
folder or any folder you may like.
if you like to define another folder manually you may do so by
options("VYOS_cache_folder" = "./caches_vyos" )
'
.blue_force(msg1)
msg2 <- "
If you approve the script will create a caches folder in your current working folder
1 - I approve a `caches_vyos` folder in my current working folder
2 - I would like to go with a temporary folder for this session
[{tempdir()}]
3 - No, I do not like any cache option I prefer making a new request every time.
"
.blue_force(msg2)
ans <- get_input_from_user("?", default.when.testing = 1)
ans
}
which_cache_folder <- function(ans = 1) {
list_a <- list(
"1" = "./caches_vyos",
"2" = tempdir(),
"3" = "null"
)
if (!toString(ans) %in% names(list_a)) {
return("null")
}
list_a[[toString(ans)]]
}
# =============================================================get_cache_folder
get_cache_folder <- function(forget = FALSE) {
folder <- getOption("VYOS_cache_folder_session")
if (isFALSE(forget) && !is.null(folder)) {
return(folder)
}
ans <- get_user_choice_cache_folder()
cache_folder <- which_cache_folder(ans)
options("VYOS_cache_folder_session" = cache_folder)
if (cache_folder_is_valid(cache_folder)) {
return(
file.path(cache_folder)
)
}
NA
}
# ==============================================================================
# this will check users choice only if cache option is True when get_series
# function was called.
# User will be asked for a location to save cache data.
# either current work folder or a temporary folder or none will be used as a location
# to save caches if current folder was approved caches_vyos folder will be created to save data.
# ================================================= check_users_choice_if_cache=
check_users_choice_if_cache <- function(cache = FALSE) {
if (isFALSE(cache) || !is.null(getOption("VYOS_cache_folder_asked"))) {
return(inv(character()))
}
get_cache_folder(T)
options("VYOS_cache_folder_asked" = "true")
}
cache_folder_is_valid <- function(folder = "null") {
if (to_string(folder) == "null") {
return(FALSE)
}
.check <- is.character(folder) && length(folder) == 1
inv(.check)
}
#--------------------------------------------------------------------save_cache
save_cache <- function(name, data) {
name <- vector_patch_cache_name(name)
cache_folder <- get_cache_folder()
if (!cache_folder_is_valid(cache_folder)) {
return(data)
}
create_dir_if_not(cache_folder)
saved <- false
try({
saveRDS(data, file.path(cache_folder, name_format_cache(name)))
saved <- true
})
if (saved) {
cache_message_conditional(SYMB_CACHE_SAVED)
}
data
}
hash_func <- function(name) {
g <- paste0(name, collapse = "_")
name2 <- digest::digest(g)
name2
}
returning_cache_looks_good <- function(..., .cache = T) {
cache_name <- create_cache_name_from_params(...)
cache_opt <- should_I_check_cache(.cache)
if (cache_opt && check_cache(cache_name)) {
return(T)
}
return(F)
}
load_cache_params <- function(..., .cache = T) {
cache_name <- create_cache_name_from_params(...)
return(load_cache(cache_name))
}
create_cache_name_from_params <- function(...) {
dots <- rlang::list2(...)
v <- unlist(dots)
h <- hash_func(v)
h
}
vector_patch_cache_name <- function(name) {
v_ersion <- "v" # version[["_version"]]
g <- paste0(name, collapse = "_", v_ersion)
name2 <- digest::digest(g)
name2
}
cache_name_hash <- function(name) {
name <- vector_patch_cache_name(name)
}
check_cache <- function(name) {
cache_folders <- get_cache_folder()
if (!cache_folder_is_valid(cache_folders)) {
return(false)
}
name <- cache_name_hash(name)
sh_name_ <- substr(name, 1, 5)
.green("checking cache {sh_name_}")
for (folder in cache_folders) {
if (file.exists(file.path(folder, name_format_cache(name)))) {
cache_message_conditional(SYMB_CACHE_FOUND)
return(true)
}
}
return(false)
}
check_cache_comp <- function(cache_name, .cache = F) {
.cache && check_cache(cache_name)
}
check_cache2 <- function(name, .cache = T) {
opt_ <- should_I_check_cache(.cache)
opt_ && check_cache(name)
}
cache_message_conditional <- function(symbl = "[saved]") {
if (check_verbose_option()) {
success(symbl)
}
}
#--------------------------------------------------------------------load_cache
load_cache <- function(name) {
cache_folders <- get_cache_folder()
if (!cache_folder_is_valid(cache_folders)) {
return(NA)
}
name <- vector_patch_cache_name(name)
for (folder in cache_folders) {
if (file.exists(file.path(folder, name_format_cache(name)))) {
okunan <- NA
try({
okunan <- readRDS(file.path(folder, name_format_cache(name)))
cache_message_conditional(SYMB_CACHE_LOAD)
return(okunan)
})
return(okunan)
}
}
}
# check_cache ...
#--------------------------------------------------------------------gunluk_cache
monthly_cache <- function() {
return(format(as.POSIXct(Sys.time()), "%Y_%m"))
}
weekly_cache <- function() {
return(sprintf(
"%s_%s", format(as.POSIXct(Sys.time()), "%Y"),
lubridate::isoweek(lubridate::ymd(Sys.Date()))
))
}
daily_cache <- function() {
return(format(as.POSIXct(Sys.time()), "%Y_%m_%d"))
}
hourly_cache <- function() {
return(format(as.POSIXct(Sys.time()), "%Y_%m_%d[%H]"))
}
minutely_cache <- function() {
return(format(as.POSIXct(Sys.time()), "%Y_%m_%d[%H%M]"))
}
default_cache_period <- weekly_cache
#------------------------------------------------------------ name_format_cache
name_format_cache <- function(name) {
period <- default_cache_period()
paste(name, period, "CACHE.RData", sep = "_")
}
#------------------------------------------------------------ check_cache
cache_name_format <- function(func, ID = "_") {
if (is.function(func)) {
func <- quote(func)
}
paste(func, ID, sep = "_")
}
create_folder_safe <- function(folder) {
folder <- file.path(folder)
if (!dir.exists(folder)) {
.green(
"folder was created... {folder}"
)
try({
dir.create(folder, recursive = TRUE)
})
}
}
# ===============================================================create_dir_if_not
create_dir_if_not <- function(folder) {
create_folder_safe(folder)
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/00_cache.R
|
#' Sets the cache folder or changes it if it was already set to save caches.
#'
#' @param folder Folder to set as a cache folder. The default value is NULL,
#' which triggers the check_users_choice_if_cache function that provides some
#' options to the user to use it as a cache folder, a temporary one, or disable caching.
#' @param verbose Boolean. If TRUE, it provides information when the
#' cache folder is set. Otherwise, it only prints a warning when there is an error.
#' @return No return value, called for side effects
#' @export
#'
#' @examples
#' change_cache_folder("my_cache_folder", verbose = TRUE)
change_cache_folder <- function(folder = null, verbose = FALSE) {
if (is.null(folder)) {
return(get_cache_folder(forget = TRUE))
}
options("VYOS_cache_folder_session" = folder)
if (verbose) {
success_force("cache folder was set [{folder }]")
}
inv(NULL)
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/00_cache_export.R
|
null <- NULL
false <- F
true <- T
CURRENT_VERSION <- "1.0.2"
get_current_package_vers <- function() {
CURRENT_VERSION
}
globalVariables(c(
"nums", "everything", "Tarih",
"fnc_str", "tarih", ".", "base"
))
#' template_test
#' creates a string template for testing and example purposes
#'
#' @return a string template that includes ID examples from different sources
#'
#' @export
#'
#' @examples
#' template_test()
template_test <- function() {
"
UNRATE #fred (series)
bie_abreserv #evds (table)
TP.AB.B1 #evds (series)
"
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/00_globals.R
|
create_params_list <- function(dots) {
dots$version <- get_current_package_vers()
dots$cache_name <- create_cache_name_from_list(dots)
dots
}
date_to_str_1 <- function(.date) {
sprintf(
"%s-%s-%s",
lubridate::day(.date),
lubridate::month(.date),
lubridate::year(.date)
)
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/00_vyos_utils.R
|
check_early <- function() {
devtools::check()
}
get_hash <- function(n = 50) {
a <- do.call(paste0, replicate(3, sample(LETTERS, n, TRUE), FALSE))
paste0(a, sprintf("%04d", sample(9999, n, TRUE)), sample(LETTERS, n, TRUE))
}
is_empty_df <- function(df) {
is.data.frame(df) && (nrow(df) == 0)
}
dynamic_exists <- function(varName = "xxy") {
exists(rlang::sym(aaa <- varName), envir = rlang::global_env())
}
as_numeric <- function(vec) {
suppressWarnings(as.numeric(vec))
}
is_testing_ <- function() {
identical(Sys.getenv("TESTTHAT"), "true")
}
to_string <- function(item) {
if (is.null(item)) {
return("null")
}
if (is_vyos_GETPREP(item)) {
return(g("\n
==========================================================
(Object) vyos_GETPREP ('{x$index}')
==========================================================\n
"))
}
toString(item)
}
add_class <- function(item, class_names) {
classes <- class(item)
class(item) <- c(class_names, classes)
class(item) <- unique(class(item))
item
}
try_or_default <- function(.expr, env = rlang::caller_env(), .default = null) {
res_val <- "NA_default"
try(
{
res_val <- rlang::eval_tidy(.expr, env = env)
},
silent = T
)
if (is.character(res_val) && res_val == "NA_default") {
return(.default)
}
return(res_val)
}
get_print_tibble <- function(x) {
a <- utils::capture.output(print(x))
paste0(a, collapse = "\n")
}
assign_ <- function(name, data) {
# assign(name , data , envir = rlang::global_env())
}
hash_func <- function(v) {
g <- paste0(v, collapse = "_")
name. <- digest::digest(g)
name.
}
g <- glue::glue
get_safe <- function(item, env = rlang::global_env(), default = F) {
sonuc <- default
try(silent = T, {
sonuc <- get(item, envir = env)
})
sonuc
}
is_false_false <- function(smt) {
isFALSE(smt)
}
is_ <- function(x, y) {
identical(x, y)
}
all_false <- function(...) {
sonuc <- any(...)
return(inv(is_false_false(sonuc)))
}
is_bad <- function(item = NA) {
if (is.character(item)) {
return(length(item) == 0)
}
if (is.list(item) || (length(item) > 0 && !is.na(item) && !is_false_false(item))) {
return(false)
}
is_false_false(item) || is.null(item) || is.na(item)
}
inv <- function(...) {
invisible(...)
}
gwrap <- function(..., env = rlang::caller_env(), color = crayon::blue) {
.f <- function(...) {
x <- glue::glue(..., .envir = env)
color(x)
}
.f(...)
}
enumerate <- function(items = c("a", "b", "c")) {
rlist::list.zip(
index = seq(len(items)),
value = items
)
}
len <- function(what) {
if ("data.frame" %in% class(what)) {
return(nrow(what))
}
if (is.list(what)) {
return(length(names(what)))
}
length(what)
}
assert <- function(...) {
stopifnot(...)
}
gsubs <- function(patterns = c("aa", "bb"), replacements = c("", ""), string = "asdasdaabb", fixed = T) {
..f <- function() {
replacements <- c("", " ")
replacements2 <- c("")
patterns <- c("o", "e")
string <- "SomeString"
assert(gsubs(patterns, replacements, string) == "Sm String")
assert(gsubs(patterns, replacements2, string) == "SmString")
}
if (length(patterns) > 1 && length(replacements) == 1) {
replacements <- rep(replacements, length(patterns))
}
for (item in enumerate(patterns)) {
replacement <- replacements[[item$index]]
if (is.character(replacement)) {
string <- gsub(item$value, replacements[[item$index]], string)
}
}
string
}
# ================================================================= join
join <- function(items, sep = ",") {
paste0(items, collapse = sep)
}
sp_trim <- function(x) {
comment <-
trimws(x,
which = c("both", "left", "right"),
whitespace = "[ \t\r\n]"
)
comment
}
read <- function(file_name) {
content <- read.delim2(file_name, header = FALSE)
paste0(content$V1, collapse = "\n")
}
create_cache_name_from_list <- function(dots) {
v <- unlist(dots)
h <- hash_func(v)
}
success <- function(...) {
args <- list(...)
for (item in args) {
cat(crayon::green$bold(paste("\n", item)))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/01_sp_utils.R
|
API_List <- function() {
fred <- list(
name = "fred",
api_key_name = "FRED_API_KEY",
url = "https://api.stlouisfed.org/",
observations_url = "fred/series/observations",
series_fnc = get_params_fred_fnc,
responseFnc = response_fnc_fred,
check_api_key_fnc = function() check_api_key_was_set("fred"),
requires_proxy = F
)
evds <- list(
name = "evds",
api_key_name = "EVDS_API_KEY",
url = "https://evds2.tcmb.gov.tr/",
observations_url = "service/evds/",
series_fnc = get_params_evds_fnc,
responseFnc = response_fnc_evds,
check_api_key_fnc = function() check_api_key_was_set("evds"),
requires_proxy = FALSE
)
evds_datagroup <- list(
name = "evds_datagroup",
api_key_name = "EVDS_API_KEY",
url = "https://evds2.tcmb.gov.tr/",
observations_url = "service/evds/",
series_fnc = get_params_evds_datagroup_fnc,
responseFnc = response_fnc_evds,
check_api_key_fnc = function() check_api_key_was_set("evds"),
requires_proxy = FALSE
)
list(
fred = fred,
evds = evds,
evds_datagroup = evds_datagroup
)
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/API_list.R
|
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
as_tibblex <- function(df) {
.Call(`_vyos_as_tibblex`, df)
}
lag_df_c <- function(df2, lag_list) {
.Call(`_vyos_lag_df_c`, df2, lag_list)
}
lag_df2_c <- function(df2, lag_list) {
.Call(`_vyos_lag_df2_c`, df2, lag_list)
}
remove_column_cpp <- function(df, column) {
.Call(`_vyos_remove_column_cpp`, df, column)
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/RcppExports.R
|
check_web_connection <- function(url = "http://ww.google.com") {
response <- request_httr2_helper(url, cache = FALSE)
conn_ok <- is_response(response) && response$status_code == 200
return(conn_ok)
}
check_connection_evds <- function() {
check_web_connection("https://evds2.tcmb.gov.tr")
}
check_connection_fred <- function() {
check_web_connection("https://fred.stlouisfed.org/docs/api/fred/")
}
check_connection_google <- function() {
check_web_connection("https://www.google.com")
}
check_connection_documentation <- function() {
check_web_connection("https://spvyos.github.io/vyos/")
}
check_list_connections <- function(verbose = TRUE) {
cons <- list(
google = check_connection_google,
evds = check_connection_evds,
fred = check_connection_fred
)
result <- purrr::map(cons, function(x) x())
g <- glue::glue
display_res <- function(res) {
if (res) {
return(crayon::green("[+]"))
}
return(crayon::red("[-]"))
}
template <- g("
========== [only basic connection was checked] ================================
The API key will be verified once a successful internet connection has been confirmed.
google : { display_res( result$google) }
evds : { display_res( result$evds ) }
fred : { display_res( result$fred ) }
================================================================================
")
if (verbose) {
cat(template)
}
return(all(purrr::map_vec(result, function(x) isTRUE(x))))
}
if_api_key_fails_check_internet_connection <- function(verbose = TRUE) {
connection_works <- check_list_connections(verbose)
return(connection_works)
}
api_key_name_format <- function(source_name = "evds") {
paste0(source_name, "__APIKEY")
}
format_message_set_api_key <- function(source_name = "evds") {
msg <- glue::glue('\n
============================================================
# usage example
set_api_key( "xyz123456789" , "{source_name}" )
============================================================\n
\n')
}
check_api_key_works <- function(source_name = "evds",
key = "..",
.test = F) {
liste <- list(
evds = quick_check_evds,
fred = quick_check_fred
)
fnc <- liste[[source_name]]
g <- glue::glue
if (is.function(fnc)) {
res <- fnc(key)
if (res) {
.blue_force(g("\n
=========================================================
api key for [{source_name}] was tested successfully.
=========================================================\n
"))
return(inv(true))
}
}
result <- if_api_key_fails_check_internet_connection(verbose = TRUE)
if (!result || .test) {
message("\n
It appears there might be a connection issue. Consider saving your API keys when
a connection is available\n
")
Sys.sleep(2)
stop()
}
message_api_key_fails(source_name, key)
Sys.sleep(2)
stop()
}
message_api_key_fails <- function(source_name = "evds",
key = "..") {
g <- glue::glue
msg <- "\n\r
=========================================================
api key `{key}` for [{source_name}] does NOT work.
Check your api key for and set
{format_message_set_api_key(source_name)}
=========================================================\n\r"
message(g(msg))
}
replace_if_null <- function(x, value) {
if (is.null(x)) {
return(value)
}
x
}
show_usage <- function(func_name = "set_api_key",
source_name = "evds",
call. = "..") {
.blue_force("
======================================
{call.}
call has an error
======================================
")
source_name <- replace_if_null(source_name, "evds")
msg <- format_message_set_api_key(source_name)
message(msg)
}
#' set_api_key
#'
#' @param key api key of the source
#' @param source_name evds or fred
#' @param option choice of later usage. env or file should be given to
#' save api key for later use. Default is env which
#' saves api key as environment variable.
#' if `env` default value is selected it will save api key
#' as an environment variable
#' if `file` was selected it will save api key to current folder.
#' @param ... for future versions
#' @return
#' The function has no return value.
#' @export
#'
#' @examples
#' \dontrun{
#'
#' set_api_key("ABCDEFGHIJKLMOP", "evds", "env")
#' set_api_key("ABCDEFGHIJKLMOP", "fred", "env")
#' set_api_key("ABCDEFGHIJKLMOP", "fred", "file")
#' }
set_api_key <- function(key = null,
source_name = null,
option = c("env", "file"),
...) {
if (is.null(key) || is.null(source_name)) {
show_usage(
"set_api_key",
source_name,
deparse(match.call())
)
stop()
}
# check_required(key)
option <- match.arg(option)
g <- glue::glue
check_api_key_works(source_name, key)
if (identical(option, "env")) {
key_name <- api_key_name_format(source_name)
if (is_(source_name, "evds")) {
Sys.setenv("evds__APIKEY" = toString(key))
} else {
Sys.setenv("fred__APIKEY" = toString(key))
}
# .Internal(Sys.setenv(key_name, toString(key)))
via <- g("
by setting environment variable with key `{key_name}`
")
success_force(g("
APIKEY for [{source_name}] was set {via}
"))
}
if (identical(option, "file")) {
file_name <- default_file_name_for_api_keys(source_name)
key_name <- api_key_name_format(source_name)
folder_api_key <- get_folder_api_key()
create_dir_if_not(folder_api_key)
content <- glue::glue("{key_name}={key}\n\r")
cat(content, file = file.path(folder_api_key, file_name))
via <- g("
by creating a file called `{file_name}`
")
success_force(g("
APIKEY for [{source_name}] was set {via}
"))
}
}
key_looks_okay_general <- function(value) {
is.character(value) && nchar(value) > 5
}
is_a_char <- function(smt) {
is.character(smt)
}
get_api_key_from_file <- function(source_name) {
file_name <- default_file_name_for_api_keys(source_name)
folder_api_key <- get_folder_api_key()
file_name_full <- file.path(folder_api_key, file_name)
if (!file.exists(file_name_full)) {
return(F)
}
content <- read(file_name_full)
value <- stringr::str_split_1(content, "=")[[2]]
value <- sp_trim(value)
value <- gsubs(c("\n", "\r"), "", value)
inv(value)
}
get_folder_api_key <- function() {
file.path("APIKEYS")
}
get_api_key <- function(source_name = "evds") {
key_name <- api_key_name_format(source_name)
# env
value <- Sys.getenv(key_name)
if (key_looks_okay_general(value)) {
return(value)
}
# file
value <- get_api_key_from_file(source_name)
if (key_looks_okay_general(value)) {
return(value)
}
message_api_key(source_name)
}
check_api_key_was_set <- function(source_name = "evds") {
key_looks_okay_general(get_api_key(source_name))
}
default_file_name_for_api_keys <- function(source_name = "evds") {
file_name <- sprintf("KEEP-IT-SECRET-APIKEY-%s.txt", source_name)
file_name
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/api_keys.R
|
check_data <- function(.data, dots_params) {
if (!(is.data.frame(.data$evds_data) || !is.data.frame(.data$fred_data))) {
call. <- ifelse(is.null(dots_params$call.), deparse(match.call()), dots_params$call.)
msg <- "
!error :
=====================================
call : [{ call. }]
=====================================
"
message(glue::glue(msg))
# data
# stop()
}
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/checks_data.R
|
# =================================================================
# color functions
# crayon + glue => .blue(" pi number is { pi }")
# =================================================================
color_fnc_create <- function(color = crayon::green, force = FALSE) {
function(...) {
x <- glue::glue(..., .envir = rlang::caller_env())
if (force || check_verbose_option()) {
cat(color(x))
}
}
}
.green <- color_fnc_create(crayon::green)
success_force <- color_fnc_create(crayon::green, force = TRUE)
.red <- color_fnc_create(crayon::red)
.bold <- color_fnc_create(crayon::bold)
.cyan <- color_fnc_create(crayon::cyan)
.yellow <- color_fnc_create(crayon::yellow)
.blue <- color_fnc_create(crayon::blue)
.blue_force <- color_fnc_create(crayon::blue, force = TRUE)
.magenta <- color_fnc_create(crayon::magenta)
.silver <- color_fnc_create(crayon::silver)
test_colors <- function() {
pid_ <- 15465L
msg <- "...pid -> { pid_ } \n\r\n\r"
cat("\n\r Testing colors ...\n\r\n\r")
color_fncs <- c(.bold, .cyan, .blue, .yellow, .green)
for (.f in color_fncs) {
.f(formatC(msg, width = 50))
}
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/colors.R
|
# ....................................................... create_evds_url
create_evds_url <- function(type = c(
"subject",
"datagroups",
"info_api"
),
subject_num = 5,
table_name = "bie_altingr",
key = null) {
domain <- "https://evds2.tcmb.gov.tr/service/evds"
type <- match.arg(type)
api_key_evds <- key
if (is.null(key)) {
api_key_evds <- get_api_key("evds")
}
g <- glue::glue
liste <- list(
subject = g("{domain}/categories/key={api_key_evds}&type=json"),
datagroups = g("{domain}/datagroups/key={api_key_evds}&mode=2&code={subject_num}&type=json"),
info_api = g("{domain}/serieList/key={api_key_evds}&type=json&code={table_name}")
)
liste[[type]]
}
get_evds_table_names_with_subject_num <- function(subject_num = 5,
cache = F) {
url <- create_evds_url("datagroups", subject_num)
response <- request_httr2_helper(url, cache)
if (!is_response(response)) {
return(false)
}
contentList <- response %>% httr2::resp_body_json()
result <- convert_list_df_evds2(contentList)
result
}
# ....................................................... get_evds_table_info_api
get_evds_subject_list_api <- function(cache = T) {
url <- create_evds_url("subject")
response <- request_httr2_helper(url, cache)
if (!is_response(response)) {
return(false)
}
response %>%
httr2::resp_body_json() %>%
convert_list_df_evds2()
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/evds_forward.R
|
# ................................................... add_errors_list_evds
add_errors_list_evds <- function(table_name) {
message_debug(table_name)
}
get_name_verbose_option <- function() {
"vyos_VERBOSE"
}
set_option_verbose <- function() {
options("vyos_VERBOSE" = T)
inv(character())
}
debug_message <- function(...) {
.opt <- getOption(get_name_verbose_option())
if (is.null(.opt) || is_false_false(.opt)) {
return(inv(character()))
}
message(...)
}
# ............................................................. get_evds_table_api
get_evds_table_api <- function(table_name = "bie_altingr",
cache = F,
na.remove = F) {
df <- try_or_default({
get_evds_table_api_helper(table_name, cache)
})
if (is_bad(df) || is_empty_df(df)) {
msg <- g("{ table_name} - Not DF ")
add_errors_list_evds(msg)
debug_message(msg)
return(null)
}
if (is.data.frame(df) && !nrow(df)) {
add_errors_list_evds(g("{ table_name} - nrow : 0 "))
return(null)
}
df <- try_this_or(df, evds_date_ops, table_name)
df <- try_this_or(df, convert_df_numeric_helper)
df <- try_this_or(df, remove_column, "YEARWEEK")
df <- try_this_or(df, remove_column, "UNIXTIME")
rehber <- get_evds_table_info_api(table_name)
if (is_false_false(rehber)) {
rehber <- NULL
}
df <- try_this_or(df, remove_na_safe)
df <- structure(df, rehber = rehber)
return(df)
}
# get_data_evds<-function(table_name = "bie_altingr" ,
# start_date =default_start_date() ,
# cache = T ){
# get_evds_table_api( table_name = table_name ,
# start_date = start_date ,
# cache = cache )
# }
# ............................................................. get_evds_table_api_helper
get_evds_table_api_helper <- function(table_name = "bie_altingr", cache = F) {
..f <- function() {
table_name <- "bie_altingr"
cache <- F
}
currentObj <- get_api_with_source("evds_datagroup")
currentObj$cache <- cache
cache_name <- cache_name_format(get_evds_table_api, paste(table_name, sep = "_"))
if (cache && check_cache(cache_name)) {
return(load_cache(cache_name))
}
currentObj$datagroup <- table_name
should_I_wait_for_request("evds")
gelen <- requestNow(currentObj)
if (is_false_false(die_if_bad_response(gelen, currentObj))) {
return(false)
}
contentList <- gelen %>% httr2::resp_body_json()
suppressWarnings(
df <- convert_list_df_evds2(contentList$items)
)
if (is.data.frame(df)) {
save_cache(cache_name, df)
}
df
}
# ............................................................. get_evds_table_info_api
get_evds_table_info_api <- function(table_name = "bie_altingr", cache = T) {
url <- create_evds_url("info_api",
table_name = table_name
)
gelen <- request_httr2_helper(url, cache)
if (!is_response(gelen)) {
return(false)
}
gelen %>%
httr2::resp_body_json() %>%
convert_list_df_evds2()
}
# ............................................................. try_convert_date
try_convert_date <- function(x = "1950-1") {
failed <- T
try({
x <- try_convert_date_helper(x)
failed <- F
})
if (failed) {
assign_("dbg_try_convert_date_failed", x)
}
x
}
try_convert_date_helper <- function(x = "1950-1") {
a <- stringr::str_split_1(x, "-")
if (length(a) < 2) {
return(x)
}
year <- as.numeric(a[[1]])
month <- as.numeric(a[[2]])
res <- as.Date(ISOdate(
year = year,
month = month,
day = 1
))
res
}
vec_try_convert_date <- Vectorize(try_convert_date)
evds_weekly_date_patch <- function(df) {
if (!evds_data_looks_weekly(df)) {
return(df)
}
v <- unlist(df$Tarih)
df$date <- lubridate::dmy(v)
df
}
evds_data_looks_weekly <- function(df) {
"YEARWEEK" %in% colnames(df)
}
evds_date_ops <- function(df, table_name) {
v <- unlist(df$Tarih)
v1 <- purrr::map(v, try_convert_date)
df$date <- df$Tarih
rehber <- get_evds_table_info_api(table_name)
frekans <- rehber$FREQUENCY_STR[[1]]
ucaylik_f <- function(x) {
# x : 2023 - Q2
v <- stringr::str_split_1(x, "-")
year <- as.numeric(v[[1]])
month <- as.numeric(gsub("Q", "", v[[2]]))
lubridate::make_date(year, month, 1)
}
if (grepl(" AYL", frekans)) { # is_(frekans , "UC AYLIK" ) utf-8 problem
df$date <- purrr::map_vec(df$Tarih, function(x) ucaylik_f(x))
df %>% dplyr::select(date, everything())
df
} else {
if (evds_data_looks_weekly(df)) {
df <- evds_weekly_date_patch(df)
} else {
try({
df$date <- v1 |> do.call(what = c)
})
}
}
df <- df |> dplyr::select(date, everything(), Tarih)
return(df)
}
#
try_this_or <- function(df, func, ...) {
gelenler <- list(...)
df2 <- df
try({
if (!length(gelenler)) {
df2 <- func(df)
} else {
df2 <- func(df, ...)
}
})
return(df2)
}
test_try_this_or <- function() {
a1_f <- function(a, b) {
a + b
}
a2_f <- function(a, b, c) {
a + b + c
}
try_this_or(10, a2_f, b = 18, 109)
try_this_or(10, a2_f, b = 18, 109, 50)
try_this_or(10, a1_f, 5)
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/evds_table_api.R
|
#' Dummy examples to check build step
#'
#' @description
#' This page checks some examples on build process to avoid missing
#'
#' @name vyos-build-checks
#' @keywords internal
#'
#'
#' @examples
#'
#' obj <- get_series(template_test(), debug = TRUE)
#' x <- print(obj)
#' if (!inherits(x, "vyos_GETPREP")) {
#' stop()
#' }
#'
NULL
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/examples_for_build_step.R
|
#' Creates an excel file from a data.frame or a list of data.frame or from
#' vyos_GETPREP object.
#' @description
#' The excel() function creates an excel file according to the object given.
#' data.frame or List of data frame or vyos_GETPREP object can be passed..
#' @param dfs object or list of data frame to write
#' @param file_name file name to save
#' @param folder folder to save file
#' @param .debug for internal use
#' @param env environment
#' @param ... for future versions
#' @return it returns object or list of data frame back
#' @export
#' @examples
#' \dontrun{
#' excel(data.frame(a = 1:3), file_name = "test1.xlsx", folder = ".")
#' }
excel <- function(
dfs = null,
file_name = null,
folder = null,
.debug = FALSE,
env = rlang::caller_env(),
...) {
obj <- excel_internal(
dfs = dfs,
file_name = file_name,
folder = folder,
.debug = .debug,
env = env,
...
)
inv(obj)
}
check_rehber <- function(df = NULL) {
rehber <- attr(df, "rehber")
df2 <- df
if (is.data.frame(rehber)) {
df2 <- list(data = df, rehber = rehber)
}
df2
}
excel2 <- function(df, ...) {
rehber <- attr(df, "rehber")
if (is.data.frame(rehber)) {
df2 <- list(data = df, rehber = rehber)
}
excel(df2, ...)
}
filter_list_df <- function(liste) {
purrr::keep(liste, function(x) inherits(x, "data.frame"))
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/excel.R
|
message_debug <- function(msg, ...) {
dbg_option <- getOption("vyos_debug")
if (isFALSE(dbg_option)) {
return(invisible(T))
}
message(...)
.blue("[dbg]->
{msg}")
}
excel_internal <- function(
dfs = null,
file_name = "d1.xlsx",
folder = null,
.debug = T,
env = rlang::caller_env(),
...) {
message_func <- message_debug
if (is_vyos_GETPREP(dfs)) {
# Dispatch
obj <- dfs
listx <- list()
for (num in seq(nrow(obj$lines))) {
.name <- obj$lines$index[[num]]
.data <- obj$lines$data[[num]]
if (is.data.frame(.data)) {
listx[[.name]] <- .data
}
}
dfs_ <- c(list(combined = obj$data), listx)
excel(dfs_, folder = folder, file_name = file_name)
return(obj)
}
if (inherits(dfs, "data.frame") && !nrow(dfs)) {
listex <- list(file_name = file_name, dfs = dfs)
# assign_("DBG_excel_listex" , listex )
message_func("Empty data.frame(0)")
message_func("-->")
message_func(file_name)
message_func("\n\r\n\r")
return(invisible(1))
}
if (!inherits(dfs, "list") && !inherits(dfs, "data.frame")) {
assign_("dbg_excel", dfs)
message_func("excel function requires data.frame or list of data.frames(1)")
return(invisible(1))
}
if (!len(dfs)) {
assign_("dbg_excel", dfs)
message_func("excel function requires data.frame or list of data.frames(2)")
return(invisible(2))
}
if (is.list(dfs) && !is.data.frame(dfs)) {
if (!all(unlist(purrr::map(dfs, \(x) inherits(x, "data.frame"))))) {
dfs <- filter_list_df(dfs)
if (!len(dfs)) {
message_func("excel function requires data.frame or list of data.frames(3)")
return(invisible(3))
}
}
}
dfs <- check_rehber(dfs)
if (is.null(folder)) {
folder <- "."
}
create_dir_if_not(folder)
if (is.null(file_name)) {
file_name <- "UnnamedFileVyos.xlsx"
}
if (!grepl("xlsx", file_name)) {
file_name <- paste0(file_name, ".xlsx")
}
core_file_name <- stringr::str_split_1(file_name, ".xlsx")[[1]]
ok <- F
try({
file_name <- file.path(folder, file_name)
writexl::write_xlsx(dfs, file_name)
ok <- T
.blue("folder: {folder}\n\r")
success_force(glue::glue(" \n\r\n\r [excel] writing [ { core_file_name }] \n\r\n\r"))
})
# .......................................................... hash
if (isFALSE(ok)) {
file_name_backup <- sprintf("%s-%s", core_file_name, get_hash(5)[[1]])
file_name_backup <- file.path(folder, file_name_backup)
.blue("folder: {folder}\n\r")
success_force(glue::glue(" \n\r\n\r [excel] writing [ { file_name_backup }] \n\r\n\r"))
}
# ..........................................................
invisible(dfs)
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/excel_internal.R
|
#' print.vyos_GETPREP
#' Generic method for S3 vyos_GETPREP object
#' @param x S3 vyos_GETPREP object
#' @param ... further arguments passed to or from other methods.
#'
#' @return S3 vyos_GETPREP object
#' @export
#'
#' @examples
#' \dontrun{
#'
#' obj <- get_series(template_test())
#' print(obj)
#' }
print.vyos_GETPREP <- function(x, ...) {
g <- glue::glue
start_date <- to_string(x$start_date)
end_date <- to_string(x$end_date)
tb <- get_print_tibble(x$lines)
tb2 <- ifelse(is.data.frame(x$data), get_print_tibble(x$data), "[no data]")
str1 <- "obj$lines$data"
str2 <- "obj$data"
template <- "\n
======================================vyos_GETPREP=======
status : {x$status }
index : {x$index }
start_date : {start_date}
end_date : {end_date}
status [{x$status }]
lines$data
===================
! each line corresponds to a different set of func and data
data can be reached as below
--> { crayon::red( str1 )}
{tb}
data
===================
(combined) data
a combined data frame will be constructed
combined data can be reached as
--> { crayon::red( str2 ) }
{tb2}
=========================================================\n
"
.blue_force(template)
inv(x)
}
combine_df <- function(x, ...) {
# a$lines$data
df <- combine_dfs_by_date2(x$lines$data)
df <- remove_columns(df, "YEARWEEK")
df
}
combine_dfs_by_date2 <- function(liste) {
combined <- NULL
for (item in liste) {
item2 <- item
if (is.data.frame(item2)) {
if (!is.data.frame(combined)) {
combined <- item2
} else {
combined <- dplyr::right_join(combined, item2, by = "date")
}
}
}
tibble::as_tibble(combined)
}
# ............................................................. get_data_all
get_data_all <- function(x) {
get_f <- function(fnc_str) {
evds_table_fnc <- function(row) {
get_evds_table_api(row$index,
# for table requests of evds start_date not required
cache = x$cache,
na.remove = x$na.remove
)
}
evds_series_fnc <- function(row) {
# freq
attr(row$index, "source") <- row$source
attr(row$index, "base") <- row$base
get_series_from_source_ABS_evds_patch(row$index,
start_date = x$start_date,
cache = x$cache,
freq = x$freq
)
}
fred_series_fnc <- function(row) {
get_series_fred(row$index,
start_date = x$start_date,
cache = x$cache
)
}
liste <- list(
fred_series_fnc = fred_series_fnc,
evds_table_fnc = evds_table_fnc,
evds_series_fnc = evds_series_fnc
)
liste[[fnc_str]]
}
v_get_f <- Vectorize(get_f)
y <- x$lines %>% dplyr::mutate(fnc = v_get_f(fnc_str))
data. <- list()
for (row in seq(nrow(y))) {
fnc <- y$fnc[[row]]
if (is.function(fnc)) {
DATA <- "null"
try({
DATA <- fnc(y[row, ])
})
DATA <- post_process_data_main(DATA, x)
if (is.null(DATA)) {
data.[[row]] <- "null"
} else {
data.[[row]] <- DATA
}
} else {
data.[[row]] <- "null"
}
}
y$data <- data.
y
}
post_process_data_main <- function(DATA, x) {
try({
DATA <- limit_years_of_data(DATA, x)
})
if (isTRUE(x$na.remove)) {
try({
DATA <- remove_na_safe(DATA)
})
}
DATA
}
# ............................................................. run.vyos_GETPREP
gets <- function(x, ...) {
#
# Since API keys are required to request data from both sources present in this package, while testing
# only mock results will be provided to the user or to the testing machine or just a prepared object which
# could be examine which sources are figured out for the fiven IDs by user if the .example parameter is TRUE.
# Because otherwise it will break with requiring API keys for the source(s) user provided as index ID.
#
#
x <- assign_data_funcs(x)
x$lines <- get_data_all(x)
x$status <- "completed"
x$data <- combine_df(x)
x
}
registerS3method("print", "vyos_GETPREP", print.vyos_GETPREP, envir = rlang::global_env())
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/generics.R
|
get_series_from_source <- function(seriesID = "TP.KREHACBS.A2",
debug = T,
source_ = "evds",
cache = T,
asvector = F) {
## request Main
currentObj <- get_api_with_source(source_)
currentObj$cache <- should_I_check_cache(cache)
currentObj$seriesID <- seriesID
should_I_wait_for_request(source_)
gelen <- requestNow(currentObj)
if (isFALSE(
die_if_bad_response(gelen, currentObj)
)
) {
return(false)
}
utils::capture.output(df <- currentObj$responseFnc(gelen, currentObj))
if (asvector) {
v1 <- convertResponseVector_general(df, currentObj)
return(v1)
}
df <- structure(df, "serie_code" = seriesID, "seriesID" = seriesID)
colnames(df) <- c("date", seriesID)
return(invisible(df))
}
get_series_from_source_ABS_evds_patch <-
function(seriesID,
start_date = default_start_date(),
cache = F,
freq = null) {
source_ <- "evds"
## request Main
currentObj <- get_api_with_source(source_)
currentObj$source <- source_
currentObj$cache <- should_I_check_cache(cache)
currentObj$seriesID <- seriesID
currentObj$start_date <- start_date
# patch **********************
currentObj$freq <- freq
should_I_wait_for_request(source_)
gelen <- requestNow(currentObj)
if (isFALSE(
die_if_bad_response(gelen, currentObj)
)
) {
return(false)
}
utils::capture.output(df <- currentObj$responseFnc(gelen, currentObj))
df <- structure(df, "serie_code" = seriesID, "seriesID" = seriesID)
colnames(df) <- c("date", seriesID)
return(invisible(df))
}
get_series_evds <- function(seriesID = "TP.KREHACBS.A3",
start_date = default_start_date(),
...,
debug = T,
cache = T) {
if (looks_like_template(seriesID)) {
message("NOTIMPLEMENTED")
message("get_series_evds")
stop()
} else {
sonuc <- get_series_from_source(seriesID, debug, "evds", cache)
}
limit_start_date(sonuc, start_date)
}
get_series_fred <- function(seriesID = "UNRATE",
start_date = default_start_date(),
...,
debug = T,
cache = T) {
sonuc <- get_series_from_source(seriesID, debug, "fred", cache)
limit_start_date(sonuc, start_date)
}
convert_result_list_to_data_frame_general <- function(result_list, v) {
df <- combine_dfs_by_date2(result_list)
df <- df %>% dplyr::arrange(tarih)
colnames(df) <- v
df
}
get_api_with_source <- function(source_ = "evds_datagroup") {
api_list <- API_List()
currentObj <- api_list[[source_]]
die_if_not_api_key(currentObj)
currentObj
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/get_data_api_abstract.R
|
correct_if_vector <- function(template) {
if (looks_like_template(template)) {
return(template)
}
join(template, "\n")
}
get_lines_index <- function(template = template_test(), min_char_ID = 3) {
template <- correct_if_vector(template)
items <- stringr::str_split_1(template, "\n")
x <- items[nchar(sp_trim(items)) >= min_char_ID]
indexes <- sapply(x, FUN = remove_aciklama)
comments <- sapply(x, FUN = get_comments)
source_ <- sapply(x, FUN = get_comments_source)
base_ <- sapply(x, FUN = guess_base_format)
structure(indexes,
comments = comments,
source = source_,
base = base_
)
}
get_lines_as_df <- function(template = template_test(), min_char_ID = 3) {
a <- get_lines_index(template = template, min_char_ID = min_char_ID)
df <- data.frame(
index = a,
source = attr(a, "source"),
base = attr(a, "base"),
comments = attr(a, "comments")
)
tibble::as_tibble(df)
}
includes <- function(obj, item) {
grepl(item, obj)
}
never_empty <- function(result, default = " ") {
if (length(result) == 0) {
result <- c(default)
}
unlist(result)
}
get_comments <- function(line = "ID #asdf#@fred#asdf") {
comment <- unlist(stringr::str_split(line, "#"))
result <- comment[-1]
never_empty(result, " ")
}
get_comments_source <- function(line) {
comments <- unlist(stringr::str_split(line, "#"))
comments <- sp_trim(comments)
if (any(includes(comments, "@fred"))) {
return("fred")
}
if (any(includes(comments, "@evds"))) {
return("evds")
}
guess_source_format(comments[[1]])
}
guess_base_format <- function(gosterge = "asdasd-asdads") {
source_name <- guess_source_format(gosterge)
if (is_(source_name, "evds")) {
if (grepl("bie_", gosterge)) {
return("table")
}
return("series")
}
if (is_(source_name, "fred")) {
return("series")
}
return("unknown_format_unknown_source")
}
guess_source_format <- function(gosterge = "asdasd-asdads") {
evds_m <- grepl("_", gosterge) || grepl(".", gosterge, fixed = T) || grepl("bie_", gosterge)
fred_m <- evds_m == F # third source here
if (evds_m) {
return("evds")
}
if (fred_m) {
return("fred")
}
return("no_source")
}
remove_aciklama <- function(x) {
b <- unlist(stringr::str_split(x, "#"))[[1]]
comment <- get_comments(x)
result <-
trimws(b,
which = c("both", "left", "right"),
whitespace = "[ \t\r\n]"
)
structure(result, comment = comment)
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/get_lines_index.R
|
is_vyos_GETPREP <- function(x) {
inherits(x, "vyos_GETPREP")
}
choose_fnc_for_source <- function(source = "evds", base = "series") {
fnc_str <- "null"
if (source == "evds" & base == "series") {
fnc_str <- "evds_series_fnc"
}
if (source == "evds" & base == "table") {
fnc_str <- "evds_table_fnc"
}
if (source == "fred") {
fnc_str <- "fred_series_fnc"
}
fnc_str
}
vec_choose_fnc_for_source <- Vectorize(choose_fnc_for_source)
assign_data_funcs <- function(dots_params) {
df <- dots_params$lines %>% dplyr::mutate(fnc_str = "null")
df <- df %>% dplyr::mutate(fnc_str = vec_choose_fnc_for_source(source, base))
dots_params$lines <- df
dots_params
}
default_start_date <- function() {
lubridate::ymd("2000/01/01")
}
default_end_date <- function() {
lubridate::ymd("2100/01/01")
}
check_verbose_if_diff_change <- function(verbose = TRUE) {
if (is.null(verbose)) {
return()
}
current_verbose <- check_verbose_option()
if (verbose != current_verbose) {
if (verbose) {
verbose_on()
} else {
verbose_off()
}
}
}
get_series_prepare <- function(index = null,
start_date = default_start_date(),
end_date = default_end_date(),
freq = null,
cache = FALSE,
na.remove = TRUE,
verbose = NULL,
...,
source = c("multi", "evds", "fred"),
base = c("multi", "series", "table")) {
if (is.null(index)) {
# index <- template_test()
msg <- "
index should be given to request data from sources.
see README file or type `?get_series` for documentation and examples.
"
stop(msg, call. = F)
}
# check if change necessary
check_verbose_if_diff_change(verbose)
lines <- get_lines_as_df(index)
lines$freq <- rep(to_string(freq), nrow(lines))
call. <- deparse(match.call())
dots_params <- create_params_list(c(as.list(environment()), list(...)))
dots_params$status <- "ready_to_run"
dots_params <- add_class(dots_params, "vyos_GETPREP")
dots_params
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/get_series.R
|
#' Requests data from multiple data sources.
#'
#' The `get_series()` function retrieves data from various sources, including the EDDS API and FRED API at this version.
#' When multiple indexes are provided as a character vector or string template, the function individually
#' requests each item from the corresponding sources, discerning the source from the item's format.
#' The function combines data frames when there are common frequencies and returns both a combined data frame and
#' individual data frames for each requested item.
#'
#' @param index A character vector or string representing the index to be retrieved.
#' @param start_date Limits the start date of the data.
#' @param end_date Limits the end date of the data.
#' @param freq Frequency of the data (rarely needed).
#' @param cache If FALSE, a new request will be made; if TRUE, cached data will be used.
#' @param na.remove If TRUE, NA values are removed only if all columns are NA.
#' @param verbose If TRUE, prints information during the process; if FALSE, silently does its job.
#' default is NULL which implies applying default verbose option. If this function is called with
#' a TRUE or FALSE value it changes global verbose option for `vyos` package.
#' If verbose option is FALSE it gives a warning only if something goes wrong.
#' @param ... Additional parameters for future versions.
#' @param debug Debug option for development.
#' @param source Source such as "evds" or "fred" for internal use at this version.
#' @param base Table or series on the source for internal use at this version.
#' @return An S3 object, vyos_GETPREP, which has generic functions such as print and excel.
#' The `print` generic provides hints to the user on how to use requested data,
#' such as creating output with the `excel` function or examining requested data in the global environment.
#'
#' @export
#' @examples
#' \dontrun{
#' o <- get_series(template_test())
#' excel(o)
#' object <- get_series("UNRATE", start_date = "2000/01/01", na.remove = TRUE)
#' excel(object)
#' }
get_series <- function(index = NULL,
start_date = default_start_date(),
end_date = default_end_date(),
freq = NULL,
cache = FALSE,
na.remove = TRUE,
verbose = NULL,
...,
source = c("multi", "evds", "fred"), # for internal use
base = c("multi", "series", "table"), # for internal use
debug = FALSE) {
check_users_choice_if_cache(cache)
obj <- get_series_prepare(
index = index,
source = source,
base = base,
start_date = start_date,
end_date = end_date,
freq. = freq,
cache = cache,
na.remove = na.remove,
verbose = verbose
)
if (debug) {
return(obj)
}
obj <- gets(obj)
obj
}
|
/scratch/gouwar.j/cran-all/cranData/vyos/R/get_series_export.R
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.