blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 986
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 23
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 145
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 122
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
666ef08cccd76e68fe441bd9f85e1f06ff4ad67b | 58febce6be896835382f03b21162f0090b3fcb0a | /leetcode/weekly/284.cpp | c0653f590a2784ebefa62880d32a94b92435cde8 | [
"Apache-2.0"
] | permissive | bvbasavaraju/competitive_programming | 5e63c0710b02476ecb499b2087ddec674fdb049f | bc17ec49b601aac62fa94449927fd64b620352d7 | refs/heads/master | 2022-10-31T15:17:00.151024 | 2022-10-23T09:14:52 | 2022-10-23T09:14:52 | 216,365,719 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,976 | cpp | /****************************************************
Date: Mar 13th, 2022
Successful submissions : 2
Time expiration : 0
Memory exhausted : 1
Not Solved : 1
Wrong Answer/ Partial result : 0
link: https://leetcode.com/contest/weekly-contest-284
****************************************************/
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <limits.h>
using namespace std;
/*
Q: 2200. Find All K-Distant Indices in an Array
*/
class Solution1_t
{
public:
vector<int> findKDistantIndices(vector<int>& nums, int key, int k)
{
int l = nums.size();
vector<int> key_idxs;
for(int i = 0; i < l; ++i)
{
if(nums[i] == key)
{
key_idxs.push_back(i);
}
}
vector<bool> idxs(l, false);
for(int idx : key_idxs)
{
for(int i = 0; i < l; ++i)
{
if(abs(i-idx) <= k)
{
idxs[i] = true;
}
}
}
vector<int> ans;
for(int i = 0; i < l; ++i)
{
if(idxs[i] == true)
{
ans.push_back(i);
}
}
return ans;
}
};
/*
Q: 2201. Count Artifacts That Can Be Extracted - memory exhausted at first due to silly mistake of grid size!!. then resolved it!!
*/
class Solution2_t
{
public:
int digArtifacts(int n, vector<vector<int>>& artifacts, vector<vector<int>>& dig)
{
vector< vector<int> > grid(n, vector<int>(n, 0)); // here instead of taking as n, I took min(n*n, 100000)
for(vector<int>& d : dig)
{
grid[d[0]][d[1]] = 1;
}
int ans = 0;
for(vector<int> a : artifacts)
{
bool canExtract = true;
for(int i = a[0]; i <= a[2] && canExtract; ++i)
{
for(int j = a[1]; j <= a[3]; ++j)
{
if(grid[i][j] == 0)
{
canExtract = false;
break;
}
}
}
if(canExtract)
{
ans++;
}
}
return ans;
}
};
/*
Q: 2202. Maximize the Topmost Element After K Moves
*/
class Solution3_t
{
public:
int maximumTop(vector<int>& nums, int k)
{
int l = nums.size();
if((l <= 1) && (k%2 != 0))
{
return -1;
}
if(k == 0)
{
return nums[0];
}
priority_queue<int> pq;
int range_ = min(l, k-1);
for(int i = 0; i < range_; ++i)
{
pq.push(nums[i]);
}
int ans = pq.empty() ? -1 : pq.top();
if((ans > 0) && (k < l))
{
ans = max(ans, nums[k]);
}
if((l > 1) && (k <= 1))
{
ans = max(ans, nums[k]);
}
return ans;
}
};
/*
Q: 2203. Minimum Weighted Subgraph With the Required Paths
*/
class Solution4_t
{
public:
long long minimumWeight(int n, vector<vector<int>>& edges, int src1, int src2, int dest)
{
}
}; | [
"bv.basavaraju@gmail.com"
] | bv.basavaraju@gmail.com |
80779feac60a101db45507a8cbd2da3af303ced3 | 1700078e3b4b82774bb4f89fc9d616e35040e9f6 | /examples/Teensy40_ESP8266Shield/Teensy40_ESP8266Shield.ino | 23caddbd0332a0b74f579de9548a283872070273 | [
"MIT"
] | permissive | khoih-prog/Blynk_Esp8266AT_WM | d73209ec85e71ffc585e63aca0c88bd42c8cd449 | 51821665b32b1f38a0c0a7fc1772e860f6e8fa56 | refs/heads/master | 2022-03-05T04:37:35.166849 | 2022-02-09T01:18:26 | 2022-02-09T01:18:26 | 241,050,420 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 4,242 | ino | /****************************************************************************************************************************
Teensy40_ESP8266Shield.ino
For Teensy using ESP8266 WiFi Shield
Blynk_Esp8266AT_WM is a library for the Mega, Teensy, SAM DUE and SAMD boards (https://github.com/khoih-prog/Blynk_Esp8266AT_WM)
to enable easy configuration/reconfiguration and autoconnect/autoreconnect of WiFi/Blynk
Based on and Modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases
Built by Khoi Hoang https://github.com/khoih-prog/Blynk_Esp8266AT_WM
Licensed under MIT license
*****************************************************************************************************************************/
#include "defines.h"
#if USE_BLYNK_WM
#include "Credentials.h"
#include "dynamicParams.h"
#define BLYNK_PIN_FORCED_CONFIG V10
#define BLYNK_PIN_FORCED_PERS_CONFIG V20
// Use button V10 (BLYNK_PIN_FORCED_CONFIG) to forced Config Portal
BLYNK_WRITE(BLYNK_PIN_FORCED_CONFIG)
{
if (param.asInt())
{
Serial.println( F("\nCP Button Hit. Rebooting") );
// This will keep CP once, clear after reset, even you didn't enter CP at all.
Blynk.resetAndEnterConfigPortal();
}
}
// Use button V20 (BLYNK_PIN_FORCED_PERS_CONFIG) to forced Persistent Config Portal
BLYNK_WRITE(BLYNK_PIN_FORCED_PERS_CONFIG)
{
if (param.asInt())
{
Serial.println( F("\nPersistent CP Button Hit. Rebooting") );
// This will keep CP forever, until you successfully enter CP, and Save data to clear the flag.
Blynk.resetAndEnterConfigPortalPersistent();
}
}
#endif
ESP8266 wifi(&EspSerial);
void heartBeatPrint()
{
static int num = 1;
if (Blynk.connected())
{
Serial.print("B");
}
else
{
Serial.print("F");
}
if (num == 80)
{
Serial.println();
num = 1;
}
else if (num++ % 10 == 0)
{
Serial.print(" ");
}
}
void check_status()
{
#define STATUS_CHECK_INTERVAL 20000L
static unsigned long checkstatus_timeout = STATUS_CHECK_INTERVAL;
// Send status report every STATUS_REPORT_INTERVAL (20) seconds: we don't need to send updates frequently if there is no status change.
if ((millis() > checkstatus_timeout) /*|| (checkstatus_timeout == 0)*/)
{
// report status to Blynk
heartBeatPrint();
checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;
}
}
void setup()
{
// Debug console
Serial.begin(115200);
while (!Serial);
delay(200);
Serial.print(F("\nStart Teensy_ESP8266Shield on ")); Serial.println(BOARD_NAME);
Serial.println(BLYNK_ESP8266AT_WM_VERSION);
Serial.println(ESP_AT_LIB_VERSION);
// initialize serial for ESP module
EspSerial.begin(ESP8266_BAUD);
#if USE_BLYNK_WM
Serial.println(DOUBLERESETDETECTOR_GENERIC_VERSION);
Serial.println(F("Start Blynk_ESP8266AT_WM"));
// Optional to change default AP IP(192.168.4.1) and channel(10)
//Blynk.setConfigPortalIP(IPAddress(192, 168, 200, 1));
// Personalized portal_ssid and password
Blynk.setConfigPortal(portal_ssid, portal_password);
//Blynk.setConfigPortal("Teensy_WM", "MyTeensy_PW");
Blynk.setConfigPortalChannel(0);
Blynk.begin(wifi);
#else
Serial.print(F("Start Blynk no WM with BlynkServer = "));
Serial.print(BlynkServer);
Serial.print(F(" and Token = "));
Serial.println(auth);
Blynk.begin(auth, wifi, ssid, pass, BlynkServer.c_str(), BLYNK_SERVER_HARDWARE_PORT);
#endif
}
#if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS)
void displayCredentials()
{
Serial.println("\nYour stored Credentials :");
for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++)
{
Serial.println(String(myMenuItems[i].displayName) + " = " + myMenuItems[i].pdata);
}
}
void displayCredentialsInLoop()
{
static bool displayedCredentials = false;
if (!displayedCredentials)
{
for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++)
{
if (!strlen(myMenuItems[i].pdata))
{
break;
}
if ( i == (NUM_MENU_ITEMS - 1) )
{
displayedCredentials = true;
displayCredentials();
}
}
}
}
#endif
void loop()
{
Blynk.run();
check_status();
#if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS)
displayCredentialsInLoop();
#endif
}
| [
"noreply@github.com"
] | khoih-prog.noreply@github.com |
8e5ae0ba29d2138f8aca06ceb14ab71828fc5362 | 847e8aca4c265bbc41c1021654372a396380a462 | /A3_Police/language_f_police/cfgPatches.hpp | dcc5942b2d544e4e2398c6c0f8da8d8f9aeeebc5 | [] | no_license | senicluxus/A3_Police | fc37aac6de30fc49fa8cd20a6a9edae00dbcf7a4 | 860a38be419a02a47a134a8ab3d4b74e2fde4c32 | refs/heads/main | 2023-06-15T11:27:30.488969 | 2021-07-01T21:09:11 | 2021-07-01T21:09:11 | 382,157,108 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 400 | hpp | class CfgPatches
{
class A3_Police_Language_F_Police
{
author = $STR_A3_A_AveryTheKitty;
name = "Arma 3 Police - Texts and Translations";
url = "https://steamcommunity.com/sharedfiles/filedetails/?id=2225865544";
requiredAddons[] = {A3_Police_Data_F_Police};
requiredVersion = 0.1;
units[] = {/* Auto-compiled by pboProject */};
weapons[] = {/* Auto-compiled by pboProject */};
};
}; | [
"senicluxus@gmail.com"
] | senicluxus@gmail.com |
006ee2413eea0048e7c2c2f6503e50c513d8612b | 125aadd932577dea65634b86692769faca9ef97a | /thirdparty/ezEngine/Foundation/Reflection/Implementation/ReflectionUtils.cpp | 19325f07aeeae5bccecdd6da9cdd710628375238 | [] | no_license | Manuzor/LispCpp | f4a5904c0d528fee75c79d1703f71a58aed94a1e | d51d5a6b0356bb213d9994c8b782e00799fc025d | refs/heads/master | 2021-01-25T09:59:27.752495 | 2014-10-28T22:51:11 | 2014-10-28T22:54:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,253 | cpp | #include <Foundation/PCH.h>
#include <Foundation/Reflection/ReflectionUtils.h>
namespace
{
struct GetValueFunc
{
template <typename T>
EZ_FORCE_INLINE void operator()()
{
m_Result = static_cast<const ezTypedMemberProperty<T>*>(m_pProp)->GetValue(m_pObject);
}
const ezAbstractMemberProperty* m_pProp;
const void* m_pObject;
ezVariant m_Result;
};
struct SetValueFunc
{
template <typename T>
EZ_FORCE_INLINE void operator()()
{
static_cast<ezTypedMemberProperty<T>*>(m_pProp)->SetValue(m_pObject, m_pValue->Get<T>());
}
ezAbstractMemberProperty* m_pProp;
void* m_pObject;
const ezVariant* m_pValue;
};
}
ezVariant ezReflectionUtils::GetMemberPropertyValue(const ezAbstractMemberProperty* pProp, const void* pObject)
{
if (pProp != nullptr)
{
GetValueFunc func;
func.m_pProp = pProp;
func.m_pObject = pObject;
ezVariant::DispatchTo(func, pProp->GetPropertyType()->GetVariantType());
return func.m_Result;
}
return ezVariant();
}
void ezReflectionUtils::SetMemberPropertyValue(ezAbstractMemberProperty* pProp, void* pObject, const ezVariant& value)
{
if (pProp != nullptr)
{
SetValueFunc func;
func.m_pProp = pProp;
func.m_pObject = pObject;
func.m_pValue = &value;
ezVariant::DispatchTo(func, pProp->GetPropertyType()->GetVariantType());
}
}
ezAbstractMemberProperty* ezReflectionUtils::GetMemberProperty(const ezRTTI* pRtti, ezUInt32 uiPropertyIndex)
{
if (pRtti == nullptr)
return nullptr;
const ezArrayPtr<ezAbstractProperty*>& props = pRtti->GetProperties();
if (uiPropertyIndex < props.GetCount())
{
ezAbstractProperty* pProp = props[uiPropertyIndex];
if (pProp->GetCategory() == ezAbstractProperty::Member)
return static_cast<ezAbstractMemberProperty*>(pProp);
}
return nullptr;
}
ezAbstractMemberProperty* ezReflectionUtils::GetMemberProperty(const ezRTTI* pRtti, const char* szPropertyName)
{
if (pRtti == nullptr)
return nullptr;
if (ezAbstractProperty* pProp = pRtti->FindPropertyByName(szPropertyName))
{
if (pProp->GetCategory() == ezAbstractProperty::Member)
return static_cast<ezAbstractMemberProperty*>(pProp);
}
return nullptr;
}
| [
"mjmaier@gmx.de"
] | mjmaier@gmx.de |
7e566a48d32f24053a484761419a4863ae385a91 | 0e4c9cf77219cde772f1d21cf30bf5c8e7b9a3b4 | /437.PathSumIII/MarkCSIE/PathSumIII/main.cpp | d1d39e8780628e972a6848b7dff8900065a70d18 | [] | no_license | LeetCodeBreaker/LeetCode | be25aa3ac2176083440dd27ce15c532e99e85e61 | 00a5ee2fc9ad38f34bb37ed64820a286057ff728 | refs/heads/master | 2021-01-17T03:48:36.961178 | 2020-06-07T15:24:49 | 2020-06-07T15:24:49 | 37,640,193 | 5 | 2 | null | 2015-07-15T15:29:21 | 2015-06-18T05:52:36 | C | UTF-8 | C++ | false | false | 1,504 | cpp | #include <iostream>
// Definition for a binary tree node.
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
};
class Solution
{
public:
int pathSum(const TreeNode* root, const int &sum)
{
if (root == nullptr)
{
return 0;
}
return (root->val == sum)
+ pathSum(root->left, sum) + pathSum(root->right, sum)
+ pathSumRoot(root->left, sum - root->val) + pathSumRoot(root->right, sum - root->val);
// TODO: O(n) solution ??
}
int pathSumRoot(const TreeNode* root, const int &sum)
{
if (root == nullptr)
{
return 0;
}
return (root->val == sum)
+ pathSumRoot(root->left, sum - root->val) + pathSumRoot(root->right, sum - root->val);
}
};
int main()
{
TreeNode* test = new TreeNode(10);
test->left = new TreeNode(5);
test->right = new TreeNode(-3);
test->left->left = new TreeNode(3);
test->left->right = new TreeNode(2);
test->right->right = new TreeNode(11);
test->left->left->left = new TreeNode(3);
test->left->left->right = new TreeNode(-2);
test->left->right->right = new TreeNode(1);
Solution solution;
std::cout << solution.pathSum(test, 8) << std::endl;
delete test->left->right->right;
delete test->left->left->right;
delete test->left->left->left;
delete test->right->right;
delete test->left->right;
delete test->left->left;
delete test->right;
delete test->left;
delete test;
return 0;
}
| [
"markcsie@gmail.com"
] | markcsie@gmail.com |
a631cc5eefacd3539d84f004049a18bf1c087094 | 25ed526bb3961c406d843a3b3bdc5cc8871548fc | /cli/src/cli_command.cpp | 2583bdf67e08096fd33301cf52e384a504ac78c8 | [
"MIT"
] | permissive | kravtsun/au-sd | a31ce5900bd61e638e9aca9544be7e8f1bbcdafe | 23522ef932ccab76c6cb74faf6b9ce7dd438d6fc | refs/heads/master | 2020-04-06T03:58:21.776648 | 2017-05-23T20:41:53 | 2017-05-23T20:41:53 | 83,093,236 | 0 | 1 | null | 2017-06-08T21:27:43 | 2017-02-25T00:04:44 | C++ | UTF-8 | C++ | false | false | 208 | cpp | #include "cli_command.h"
namespace cli {
Command::Command(std::istream &is, std::ostream &os, const Command::ParamsListType ¶ms)
: is_(is)
, os_(os)
, params_(params)
{}
} // namespace cli
| [
"kravtsun@cvisionlab.com"
] | kravtsun@cvisionlab.com |
3bfa7af1c3160e63b3cf95caa9d5f8a446a4298a | 07ab8948c7dcf9ab6c76d93425ea377ada6be7b1 | /BRACU ACM Student Chapter/Online Workshop on Programming Skills DAY 02 ( C++ ) BRACU Number Theory/E.cpp | 352257b26972efaaec46794882582fe55d880e97 | [] | no_license | tanviranindo/Contest | 269ef5a17a64edff2e6ee61df5e5df1296093f51 | 68cc8070074cc1a076dde9c0454cbcace265d597 | refs/heads/master | 2023-04-22T11:15:15.711816 | 2021-04-29T19:27:34 | 2021-04-29T19:27:34 | 258,791,450 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 424 | cpp | #include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
if (b == 0) return a;
else return gcd(b, a % b);
}
int main()
{
int N;
while(scanf("%d",&N)!=0)
{
int G=0;
if(N==0) break;
for(int i=1; i<N; i++)
{
for(int j=i+1; j<=N; j++)
{
G+=gcd(i,j);
}
}
cout << G << endl;
}
return 0;
}
| [
"tanviranindo@gmail.com"
] | tanviranindo@gmail.com |
826e231707c56fc367b5f7fa22126bdf1e55ed9b | c762444f01a7d53361b2f8d22d8845b0a802d8d9 | /vtr@2780988/blifexplorer/src/clockconfig.cpp | b8a040d328c80ad344ca6b1b711f6ad81eb34f66 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"MIT-Modern-Variant"
] | permissive | xibo-sun/VTR_with_Yosys | ef12ff0ee649e9376063a011cbcdf1208ee02094 | 2d8ef88fa8e6c9c66489e81f50f37dede6b1bb30 | refs/heads/master | 2023-02-23T10:27:58.243842 | 2023-02-11T00:51:35 | 2023-02-11T00:51:35 | 227,647,186 | 0 | 1 | MIT | 2023-02-11T00:51:37 | 2019-12-12T16:15:57 | C | UTF-8 | C++ | false | false | 1,201 | cpp | #include "clockconfig.h"
#include "ui_clockconfig.h"
ClockConfig::ClockConfig(QWidget *parent) :
QDialog(parent),
ui(new Ui::ClockConfig)
{
ui->setupUi(this);
}
ClockConfig::~ClockConfig()
{
delete ui;
}
void ClockConfig::on_buttonBox_accepted()
{
//set the ratios in Odin. :)
int i = 0;
for(i = 0;i<clocks.length();i++){
QString ratText = ui->tableWidget->item(i,1)->text();
int rat = ratText.toInt();
set_clock_ratio(rat,
clocks.at(i)->getOdinRef());
}
}
void ClockConfig::on_buttonBox_rejected()
{
// do nothing for now.
}
void ClockConfig::passClockList(QList<LogicUnit *> clocklist)
{
clocks = clocklist;
int i = 0;
ui->tableWidget->setRowCount(clocklist.length());
for(i = 0;i<clocklist.length();i++){
int rat = get_clock_ratio(clocks.at(i)->getOdinRef());
QString ratString;
ratString.setNum(rat);
QTableWidgetItem *clockName = new QTableWidgetItem(clocks.at(i)->getName());
QTableWidgetItem *clockRatio = new QTableWidgetItem(ratString);
ui->tableWidget->setItem(i,0,clockName);
ui->tableWidget->setItem(i,1,clockRatio);
}
}
| [
"sun@localhost.localdomain"
] | sun@localhost.localdomain |
f1349227ee496ad519179bb705d0d88705cfe6e5 | 38c10c01007624cd2056884f25e0d6ab85442194 | /third_party/WebKit/Source/core/paint/ScrollbarPainter.h | e0e619a9c681f0c0614ddaf8bd1fbadd710f5172 | [
"BSD-3-Clause",
"LGPL-2.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-1.0-or-later",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"MIT",
"Apache-2.0"
] | permissive | zenoalbisser/chromium | 6ecf37b6c030c84f1b26282bc4ef95769c62a9b2 | e71f21b9b4b9b839f5093301974a45545dad2691 | refs/heads/master | 2022-12-25T14:23:18.568575 | 2016-07-14T21:49:52 | 2016-07-23T08:02:51 | 63,980,627 | 0 | 2 | BSD-3-Clause | 2022-12-12T12:43:41 | 2016-07-22T20:14:04 | null | UTF-8 | C++ | false | false | 980 | h | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ScrollbarPainter_h
#define ScrollbarPainter_h
#include "platform/heap/Handle.h"
#include "platform/scroll/Scrollbar.h"
namespace blink {
class GraphicsContext;
class IntRect;
class LayoutPoint;
class LayoutRect;
class LayoutScrollbar;
class LayoutScrollbarPart;
class ScrollbarPainter {
STACK_ALLOCATED();
WTF_MAKE_NONCOPYABLE(ScrollbarPainter);
public:
explicit ScrollbarPainter(const LayoutScrollbar& layoutScrollbar) : m_layoutScrollbar(&layoutScrollbar) { }
void paintPart(GraphicsContext*, ScrollbarPart, const IntRect&);
static void paintIntoRect(const LayoutScrollbarPart&, GraphicsContext*, const LayoutPoint& paintOffset, const LayoutRect&);
private:
RawPtrWillBeMember<const LayoutScrollbar> m_layoutScrollbar;
};
} // namespace blink
#endif // ScrollbarPainter_h
| [
"zeno.albisser@hemispherian.com"
] | zeno.albisser@hemispherian.com |
c72b4012e80a65b4f1747b396ef9c624dcc84d32 | 087a0db88dee2c805d7999d43683b3e63e6623b5 | /Source/AnimalEffect/Environment/Tree.h | 82c2a18539619447d1b13d3ba934690fc7d46b0c | [] | no_license | Cobryis/AnimalEffect | 5bd061e87f93f2e74b489364e5d7869166c8c54b | 6ab38abe62c32fb8efe2fb6a63a973a1a17ee960 | refs/heads/master | 2023-01-05T05:16:22.550053 | 2020-10-17T16:15:48 | 2020-10-17T16:15:48 | 268,434,064 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 817 | h | // Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Data/AEDataAsset.h"
#include "WorldGrid/WorldGridInterface.h"
#include "GameFramework/Actor.h"
#include "Tree.generated.h"
UCLASS()
class ANIMALEFFECT_API UTreeAsset : public UAEMetaAsset
, public IWorldGridInterface
{
GENERATED_BODY()
UPROPERTY(EditDefaultsOnly, Category = "World Grid", meta = (ClampMin = 1, ClampMax = 2))
int32 Size = 1;
public:
// BEGIN IWorldGridInterface
FGridVector GetWorldGridSize() const { return FGridVector(Size); }
// END IWorldGridInterface
};
UCLASS()
class ANIMALEFFECT_API ATree : public AActor
{
GENERATED_BODY()
public:
ATree();
void OnAxeHit(APawn* HitInstigator);
private:
UPROPERTY(BlueprintReadOnly, Category = "Health", meta = (AllowPrivateAccess = true))
int32 Health;
};
| [
"cobryis@gmail.com"
] | cobryis@gmail.com |
10b58fd0526b4f042758d76f78318c6c90c8fc89 | 4e2d90ef3b17872ea3f4fc16832fb8815ffef985 | /LongestPelindromeSubstring.cpp | 7c1ce9177d02216663e41dfc75ea21e507a8c2ea | [] | no_license | shyam2797/DynamicProgramming | 16230065535dde0d86cb8eb078248b1ae03cdb7e | 8a7d4b2dde3c8c80c9e54f791c057a822fa74de1 | refs/heads/master | 2022-12-11T10:00:48.295336 | 2020-09-05T17:32:57 | 2020-09-05T17:32:57 | 290,374,350 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 785 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int arr[]= {5,3,2,6,4,4,6,2,1,2,1,2,1,2,1,2,1,2};
int Size=sizeof(arr)/sizeof(arr[0]);
int S[Size][Size],Max=1;
for(int i=0; i<Size; i++)
{
S[i][i]=1;
}
for(int i=0; i<Size-1; i++)
{
if(arr[i]=arr[i+1])
{
S[i][i+1]=1;
Max=2;
}
else
{
S[i][i+1]=0;
}
}
for(int k=2; k<Size; k++)
{
for(int i=0; i<Size-k; i++)
{
int j=i+k;
if(arr[i]==arr[j] && S[i+1][j-1])
{
S[i][j]=1;
Max=k+1;
}
else
{
S[i][j]=0;
}
}
}
cout<<Max<<endl;
return 0;
}
| [
"shyamsaini2797@example.com"
] | shyamsaini2797@example.com |
d39cfb39fea6084e55aec45a3703d83675d0b57d | 2dcd0ab0570b507ee2b6233cb7d72ae1897875c6 | /TopCoder/SRM464Div1/ColorfulDecoration.cpp | 17c38f4461fa4d2bae685df4f44d22f20168406a | [] | no_license | ngmq/CompetitiveProgramming | 7db2f62f95e662a725571a82667e11099c65a75f | 2f13534dd5e28c2bb061bad4df1c88948197420b | refs/heads/master | 2022-02-11T02:33:46.541303 | 2022-01-30T21:33:40 | 2022-01-30T21:33:40 | 37,407,532 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,551 | cpp | #line 2 "ColorfulDecoration.cpp"
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <sstream>
// #include <map>
#include <set>
//#include <deque>
#include <queue>
#include <stack>
// #include <cstdlib>
// #include <climits>
// #include <functional>
// #include <ctime>
#include <cmath>
//#include <bitset>
// #include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define inf 1e9 + 1
#define linf 1e18
#define BASE 1000000
#define EPS 1e-10
#define PI acos(-1)
#define pii pair<int,int>
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define ms(x,val) memset(x, val, sizeof(x))
#define pb(x) push_back(x)
#define make_unique(x) sort(ALL(x)) ; x.erase( unique(ALL(x)), x.end()) ;
#define dbg(x) do { cout << #x << " = " << x << endl; } while(0)
#define mp(x, y) make_pair(x, y)
#ifdef HOME
#define DBG(x, ...) printf(x, __VA_ARGS__)
#else
#define DBG(x, ...)
#endif
/*** IMPLEMENTATION ***/
bool exitInput = false;
int ntest = 1, itest = 1 ;
// const int dx[4] =
// {
// 0, 0, -1, 1
// };
// const int dy[4] =
// {
// 1, -1, 0, 0
// };
// const int dx[8] = {-2, -1, -1, +0, +0, +1, +1, +2};
// const int dy[8] = {+0, -1, +1, -2, +2, -1, +1, +0};
/** Knight Move **/
// const int dx[8] = {+1, +2, +2, +1, -1, -2, -2, -1};
// const int dy[8] = {+2, +1, -1, -2, -2, -1, +1, +2};
const char * directions[4] =
{
"NE", "SE", "SW", "NW"
};
const ll Mod = 1000000000LL + 7;
const int maxn = 50 + 2;
const int maxv = 100000+ 5;
const int maxe = 600000 + 5;
const int root = 1;
bool is_overlap(int _size, int x0, int y0, int x1, int y1)
{
// x0, y0 now is on the left of x1, y1
if(_size <= abs(x1 - x0))
return false;
if(_size <= abs(y1 - y0))
return false;
return true;
}
int n, ans[maxn], ax[maxn], ay[maxn], bx[maxn], by[maxn];
int x[maxn], y[maxn];
bool conflict[maxn][2][maxn][2], canBe[maxn][2];
int setBy[maxn];
void build_conflict(int _size)
{
ms(conflict, false);
int i, j;
for(i = 0; i < n; ++i)
{
for(j = i + 1; j < n; ++j)
{
// 0-0
x[i] = ax[i];
y[i] = ay[i];
x[j] = ax[j];
y[j] = ay[j];
if(is_overlap(_size, x[i], y[i], x[j], y[j]))
{
conflict[i][0][j][0] = true;
conflict[j][0][i][0] = true;
}
// 0-1
x[i] = ax[i];
y[i] = ay[i];
x[j] = bx[j];
y[j] = by[j];
if(is_overlap(_size, x[i], y[i], x[j], y[j]))
{
conflict[i][0][j][1] = true;
conflict[j][1][i][0] = true;
}
// 1-0
x[i] = bx[i];
y[i] = by[i];
x[j] = ax[j];
y[j] = ay[j];
if(is_overlap(_size, x[i], y[i], x[j], y[j]))
{
conflict[i][1][j][0] = true;
conflict[j][0][i][1] = true;
}
// 1-1
x[i] = bx[i];
y[i] = by[i];
x[j] = bx[j];
y[j] = by[j];
if(is_overlap(_size, x[i], y[i], x[j], y[j]))
{
conflict[i][1][j][1] = true;
conflict[j][1][i][1] = true;
}
}
}
}
bool dfs(int u)
{
//visit[u] = 1;
int v;
//printf("u = %d, ans = %d\n", u, ans[u]);
bool ok = true;
for(v = 0; v < n; ++v)
{
if(u == v)
continue;
//printf("INSIDE (u = %d, ans[u] = %d) v = %d, ans = %d\n", u, ans[u], v, ans[v]);
if(ans[v] != -1 && conflict[u][ans[u]][v][ans[v]])
{
//printf("--- GOT FALSE 1 ---\n");
return false;
}
if(ans[v] == -1)
{
if(conflict[u][ans[u]][v][0] && conflict[u][ans[u]][v][1])
{
//printf("--- GOT FALSE 2 ---\n");
return false;
}
if(conflict[u][ans[u]][v][0])
{
ans[v] = 1;
//printf("--- ASSIGN 1 ---\n");
ok &= dfs(v);
}
else
if(conflict[u][ans[u]][v][1])
{
ans[v] = 0;
//printf("--- ASSIGN 0 ---\n");
ok &= dfs(v);
}
}
}
return ok;
}
//void build_canBe()
//{
// int i, j;
// bool ok;
// for(i = 0; i < n; ++i)
// {
// for(j = 0; j <= 1; ++j)
// {
// ms(ans, -1);
// ans[i] = j;
// ok = dfs(i);
// canBe[i][j] = ok;
// }
// }
//}
//
bool isok()
{
// let's find the impossible!
int i;
bool ok;
for(i = 0; i < n; ++i)
{
ms(ans, -1);
ans[i] = 0;
ok = dfs(i);
//printf("i = %d, try 0, ok = %d\n", i, ok);
if(ok)
continue;
// ok = false now
ms(ans, -1);
ans[i] = 1;
ok = dfs(i);
//printf("i = %d, try 1, ok = %d\n", i, ok);
if(!ok)
return false;
}
return true;
}
class ColorfulDecoration
{
public:
int getMaximum(vector <int> xa, vector <int> ya, vector <int> xb, vector <int> yb)
{
n = xa.size();
int i;
for(i = 0; i < n; ++i)
{
ax[i] = xa[i];
ay[i] = ya[i];
bx[i] = xb[i];
by[i] = yb[i];
}
int lo = 0, hi = 1000000000, mid, res = -1;
//cerr << "start" << endl;
while(lo <= hi)
{
mid = (lo + hi) / 2;
//mid = 25;
build_conflict(mid);
//build_canBe();
bool ok = isok();
if(ok)
{
res = mid;
lo = mid + 1;
}
else
{
hi = mid - 1;
}
}
return res;
}
// BEGIN CUT HERE
public:
void run_test(int Case)
{
if ((Case == -1) || (Case == 0)) test_case_0();
if ((Case == -1) || (Case == 1)) test_case_1();
if ((Case == -1) || (Case == 2)) test_case_2();
if ((Case == -1) || (Case == 3)) test_case_3();
if ((Case == -1) || (Case == 4)) test_case_4();
if ((Case == -1) || (Case == 5)) test_case_5();
if ((Case == -1) || (Case == 6)) test_case_6();
}
private:
template <typename T> string print_array(const vector<T> &V)
{
ostringstream os;
os << "{ ";
for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\",";
os << " }";
return os.str();
}
void verify_case(int Case, const int &Expected, const int &Received)
{
cerr << "Test Case #" << Case << "...";
if (Expected == Received) cerr << "PASSED" << endl;
else
{
cerr << "FAILED" << endl;
cerr << "\tExpected: \"" << Expected << '\"' << endl;
cerr << "\tReceived: \"" << Received << '\"' << endl;
}
}
void test_case_0()
{
int Arr0[] = { 10, 0, 7 };
vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0])));
int Arr1[] = { 0, 19, 6 };
vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0])));
int Arr2[] = { 20, 10, 25 };
vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0])));
int Arr3[] = { 20, 35, 25 };
vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0])));
int Arg4 = 19;
verify_case(0, Arg4, getMaximum(Arg0, Arg1, Arg2, Arg3));
}
void test_case_1()
{
int Arr0[] = { 464, 20 };
vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0])));
int Arr1[] = { 464, 10 };
vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0])));
int Arr2[] = { 464, 3 };
vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0])));
int Arr3[] = { 464, 16 };
vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0])));
int Arg4 = 461;
verify_case(1, Arg4, getMaximum(Arg0, Arg1, Arg2, Arg3));
}
void test_case_2()
{
int Arr0[] = { 0, 0, 1, 1 };
vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0])));
int Arr1[] = { 0, 0, 1, 1 };
vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0])));
int Arr2[] = { 1, 1, 0, 0 };
vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0])));
int Arr3[] = { 1, 1, 0, 0 };
vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0])));
int Arg4 = 0;
verify_case(2, Arg4, getMaximum(Arg0, Arg1, Arg2, Arg3));
}
void test_case_3()
{
int Arr0[] = { 0, 3, 0, 5, 6 };
vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0])));
int Arr1[] = { 1, 6, 0, 8, 5 };
vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0])));
int Arr2[] = { 6, 1, 7, 4, 7 };
vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0])));
int Arr3[] = { 5, 9, 2, 8, 9 };
vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0])));
int Arg4 = 3;
verify_case(3, Arg4, getMaximum(Arg0, Arg1, Arg2, Arg3));
}
void test_case_4()
{
int Arr0[] = { 1000000000, 0 };
vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0])));
int Arr1[] = { 0, 1000000000 };
vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0])));
int Arr2[] = { 0, 1000000000 };
vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0])));
int Arr3[] = { 0, 1000000000 };
vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0])));
int Arg4 = 1000000000;
verify_case(4, Arg4, getMaximum(Arg0, Arg1, Arg2, Arg3));
}
void test_case_5()
{
int Arr0[] = {10058581, 154753346, 768596011, 537736881, 284951555, 4937767, 551743985, 318153081, 419225035, 209414991, 875163789, 993489591, 638970392, 167678236, 107787858, 580531103, 746599417, 504755671, 950094063, 29100387, 798226506, 11045518, 254991679, 113367501, 668164141, 829862837, 535607577, 68808662, 137243450, 742513443, 750893439, 667989764, 658327080, 909258562, 60066869, 685961927, 19032057, 411758916, 456563278, 133339457, 445054711, 1029969, 635150159, 361326595, 736766227, 96400772, 520693118, 623847331, 300737412, 35274927};
vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0])));
int Arr1[] = {925029818, 174517079, 1646413, 12773433, 691741493, 793087250, 258279708, 836968051, 48330553, 793820349, 265494765, 866228504, 108721269, 770210579, 591514618, 96403021, 610542722, 251614373, 250008568, 140755255, 828757170, 62984621, 651467852, 665271796, 821974756, 306278680, 840014662, 620053298, 944986353, 986049530, 490524582, 844988170, 105332032, 182087247, 989992648, 874583277, 824621693, 49528275, 933382757, 257971427, 204752946, 952234819, 271878226, 477692114, 234014860, 112319589, 480817107, 671488583, 892760055, 827330102};
vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0])));
int Arr2[] = {628888517, 193031190, 535906415, 42867534, 167612121, 425611047, 886995918, 990144636, 150418989, 579353, 269960467, 494671373, 603257354, 765045560, 919959627, 577389078, 700549546, 10406870, 527143207, 429777297, 452008066, 127836989, 400033681, 848851349, 52232933, 152404806, 963174080, 851166587, 327738049, 314562898, 372932500, 788625051, 647329123, 392311216, 261978133, 189202952, 760652464, 999484367, 54033136, 666650344, 992256916, 837243271, 343785416, 230764677, 369881548, 589608044, 869827643, 828157988, 576868010, 69499080};
vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0])));
int Arr3[] = {712821565, 724002276, 329872441, 11023068, 787396438, 837417619, 430819152, 638473998, 324578903, 41506913, 475461330, 231415948, 266062185, 852007510, 126429367, 895567, 714844332, 328045595, 272031980, 814375651, 20064823, 819066301, 533190570, 793917341, 711620607, 675647486, 419771932, 624922671, 321510647, 729744143, 582662379, 642821200, 722168329, 368164291, 474824653, 88800309, 687375246, 223691516, 682482322, 740559665, 380311110, 378513747, 155034303, 811291915, 785428352, 960361916, 980089755, 265371065, 117859704, 391568364};
vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0])));
int Arg4 = 59036900;
verify_case(5, Arg4, getMaximum(Arg0, Arg1, Arg2, Arg3));
}
void test_case_6()
{
int Arr0[] = {460288319, 779682586, 57549982, 892491035, 855980632, 39873201, 564204779, 40797169, 996017294, 793397316, 178863385, 815429399, 986325123, 738879415, 445840859, 881687895, 311307452, 426849377, 256767017, 817927291, 404698207, 460498577, 127010635, 730964706, 769892278, 794829316, 200250021, 464490039, 993204685, 930249611, 151261182, 657447719, 845965156, 799233336, 355065638, 53124524, 459453728, 400358200, 328695600, 216329975, 601443522, 296449957, 394750273, 751289667, 442495276, 631252002, 354929146, 493480072, 81865111, 966820394};
vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0])));
int Arr1[] = {700258555, 768611547, 23182312, 703265792, 122503807, 329858657, 992888856, 902521388, 997217570, 595647214, 249631153, 658662853, 910369085, 865136942, 512805590, 127768967, 381099470, 138281814, 863344115, 344982872, 33906353, 637406307, 777498936, 463011050, 25067728, 579454321, 155180179, 518714274, 927324589, 416560471, 554840777, 746008583, 274140415, 607072850, 331279055, 865222919, 848834210, 543698364, 348393101, 100425865, 274208821, 866950453, 942412728, 844810671, 733444032, 273574507, 548243114, 382075282, 196204939, 34747516};
vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0])));
int Arr2[] = {54225977, 777144615, 607737925, 193832014, 321051841, 779879239, 866364788, 953325227, 613549825, 986133293, 178672498, 44508670, 117509241, 973341406, 338841336, 267846265, 602584410, 721507992, 50735787, 30250953, 76918304, 600772458, 117011272, 749973757, 445533394, 467012319, 874469996, 882646156, 373749207, 653108693, 935202302, 710366318, 221521522, 12835437, 865919037, 516168808, 313276634, 749673754, 361734756, 932790885, 355272691, 730530561, 982873797, 204245127, 616891046, 864189983, 4650283, 937642301, 387034552, 142010052};
vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0])));
int Arr3[] = {819822075, 24258334, 907008183, 658748664, 584541773, 538398539, 927552505, 242689766, 291850643, 847114095, 553822930, 104085827, 726423399, 965977934, 91727563, 99107951, 353266151, 541597667, 131547004, 594223181, 654909489, 705462653, 582093325, 814290532, 809182289, 244406740, 464556657, 671864130, 363304843, 952081259, 182749677, 268390922, 799048311, 565037010, 965963644, 74536582, 950884204, 543555719, 469655036, 879117090, 585560113, 847096429, 802304582, 12770098, 469619244, 302675677, 976217038, 914416981, 945807374, 336879059};
vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0])));
int Arg4 = 53342408;
verify_case(6, Arg4, getMaximum(Arg0, Arg1, Arg2, Arg3));
}
// END CUT HERE
};
// BEGIN CUT HERE
int main()
{
freopen("topcoder.txt", "w", stdout);
ColorfulDecoration ___test;
___test.run_test(-1);
// system("pause");
}
// END CUT HERE
| [
"noreply@github.com"
] | ngmq.noreply@github.com |
46186900bf2abfd869da2de1ec9c879abaed685a | 313fe96e1535a693484f363190749ab936eba063 | /shell/platform/common/cpp/client_wrapper/encodable_value_unittests.cc | 6784fa4b775f2c011fcbc4f538afab0528ba09e8 | [
"BSD-3-Clause"
] | permissive | nynny/engine_new | 082d4939fe9d0ad0deca86d2dd7ffe7eb49ee804 | 8156268f098ab6ccadad78de6296675d48adefc0 | refs/heads/master | 2020-05-14T13:45:16.264267 | 2019-04-17T04:44:05 | 2019-04-17T04:58:37 | 181,820,370 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,483 | cc | // Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/encodable_value.h"
#include <limits>
#include "gtest/gtest.h"
namespace flutter {
// Verifies that value.type() is |type|, and that of all the Is* methods, only
// the one that matches the type is true.
void VerifyType(EncodableValue& value,
EncodableValue::EncodableValue::Type type) {
EXPECT_EQ(value.type(), type);
EXPECT_EQ(value.IsNull(), type == EncodableValue::Type::kNull);
EXPECT_EQ(value.IsBool(), type == EncodableValue::Type::kBool);
EXPECT_EQ(value.IsInt(), type == EncodableValue::Type::kInt);
EXPECT_EQ(value.IsLong(), type == EncodableValue::Type::kLong);
EXPECT_EQ(value.IsDouble(), type == EncodableValue::Type::kDouble);
EXPECT_EQ(value.IsString(), type == EncodableValue::Type::kString);
EXPECT_EQ(value.IsByteList(), type == EncodableValue::Type::kByteList);
EXPECT_EQ(value.IsIntList(), type == EncodableValue::Type::kIntList);
EXPECT_EQ(value.IsLongList(), type == EncodableValue::Type::kLongList);
EXPECT_EQ(value.IsDoubleList(), type == EncodableValue::Type::kDoubleList);
EXPECT_EQ(value.IsList(), type == EncodableValue::Type::kList);
EXPECT_EQ(value.IsMap(), type == EncodableValue::Type::kMap);
}
TEST(EncodableValueTest, Null) {
EncodableValue value;
VerifyType(value, EncodableValue::Type::kNull);
}
TEST(EncodableValueTest, Bool) {
EncodableValue value(false);
VerifyType(value, EncodableValue::Type::kBool);
EXPECT_FALSE(value.BoolValue());
value = true;
EXPECT_TRUE(value.BoolValue());
}
TEST(EncodableValueTest, Int) {
EncodableValue value(42);
VerifyType(value, EncodableValue::Type::kInt);
EXPECT_EQ(value.IntValue(), 42);
value = std::numeric_limits<int32_t>::max();
EXPECT_EQ(value.IntValue(), std::numeric_limits<int32_t>::max());
}
TEST(EncodableValueTest, LongValueFromInt) {
EncodableValue value(std::numeric_limits<int32_t>::max());
EXPECT_EQ(value.LongValue(), std::numeric_limits<int32_t>::max());
}
TEST(EncodableValueTest, Long) {
EncodableValue value(42l);
VerifyType(value, EncodableValue::Type::kLong);
EXPECT_EQ(value.LongValue(), 42);
value = std::numeric_limits<int64_t>::max();
EXPECT_EQ(value.LongValue(), std::numeric_limits<int64_t>::max());
}
TEST(EncodableValueTest, Double) {
EncodableValue value(3.14);
VerifyType(value, EncodableValue::Type::kDouble);
EXPECT_EQ(value.DoubleValue(), 3.14);
value = std::numeric_limits<double>::max();
EXPECT_EQ(value.DoubleValue(), std::numeric_limits<double>::max());
}
TEST(EncodableValueTest, String) {
std::string hello("Hello, world!");
EncodableValue value(hello);
VerifyType(value, EncodableValue::Type::kString);
EXPECT_EQ(value.StringValue(), hello);
value = "Goodbye";
EXPECT_EQ(value.StringValue(), "Goodbye");
}
TEST(EncodableValueTest, UInt8List) {
std::vector<uint8_t> data = {0, 2};
EncodableValue value(data);
VerifyType(value, EncodableValue::Type::kByteList);
std::vector<uint8_t>& list_value = value.ByteListValue();
list_value.push_back(std::numeric_limits<uint8_t>::max());
EXPECT_EQ(list_value[0], 0);
EXPECT_EQ(list_value[1], 2);
ASSERT_EQ(list_value.size(), 3u);
EXPECT_EQ(data.size(), 2u);
EXPECT_EQ(list_value[2], std::numeric_limits<uint8_t>::max());
}
TEST(EncodableValueTest, Int32List) {
std::vector<int32_t> data = {-10, 2};
EncodableValue value(data);
VerifyType(value, EncodableValue::Type::kIntList);
std::vector<int32_t>& list_value = value.IntListValue();
list_value.push_back(std::numeric_limits<int32_t>::max());
EXPECT_EQ(list_value[0], -10);
EXPECT_EQ(list_value[1], 2);
ASSERT_EQ(list_value.size(), 3u);
EXPECT_EQ(data.size(), 2u);
EXPECT_EQ(list_value[2], std::numeric_limits<int32_t>::max());
}
TEST(EncodableValueTest, Int64List) {
std::vector<int64_t> data = {-10, 2};
EncodableValue value(data);
VerifyType(value, EncodableValue::Type::kLongList);
std::vector<int64_t>& list_value = value.LongListValue();
list_value.push_back(std::numeric_limits<int64_t>::max());
EXPECT_EQ(list_value[0], -10);
EXPECT_EQ(list_value[1], 2);
ASSERT_EQ(list_value.size(), 3u);
EXPECT_EQ(data.size(), 2u);
EXPECT_EQ(list_value[2], std::numeric_limits<int64_t>::max());
}
TEST(EncodableValueTest, DoubleList) {
std::vector<double> data = {-10.0, 2.0};
EncodableValue value(data);
VerifyType(value, EncodableValue::Type::kDoubleList);
std::vector<double>& list_value = value.DoubleListValue();
list_value.push_back(std::numeric_limits<double>::max());
EXPECT_EQ(list_value[0], -10.0);
EXPECT_EQ(list_value[1], 2.0);
ASSERT_EQ(list_value.size(), 3u);
EXPECT_EQ(data.size(), 2u);
EXPECT_EQ(list_value[2], std::numeric_limits<double>::max());
}
TEST(EncodableValueTest, List) {
EncodableList encodables = {
EncodableValue(1),
EncodableValue(2.0),
EncodableValue("Three"),
};
EncodableValue value(encodables);
VerifyType(value, EncodableValue::Type::kList);
EncodableList& list_value = value.ListValue();
EXPECT_EQ(list_value[0].IntValue(), 1);
EXPECT_EQ(list_value[1].DoubleValue(), 2.0);
EXPECT_EQ(list_value[2].StringValue(), "Three");
// Ensure that it's a modifiable copy of the original array.
list_value.push_back(EncodableValue(true));
ASSERT_EQ(list_value.size(), 4u);
EXPECT_EQ(encodables.size(), 3u);
EXPECT_EQ(value.ListValue()[3].BoolValue(), true);
}
TEST(EncodableValueTest, Map) {
EncodableMap encodables = {
{EncodableValue(), EncodableValue(std::vector<int32_t>{1, 2, 3})},
{EncodableValue(1), EncodableValue(10000l)},
{EncodableValue("two"), EncodableValue(7)},
};
EncodableValue value(encodables);
VerifyType(value, EncodableValue::Type::kMap);
EncodableMap& map_value = value.MapValue();
EXPECT_EQ(map_value[EncodableValue()].IsIntList(), true);
EXPECT_EQ(map_value[EncodableValue(1)].LongValue(), 10000l);
EXPECT_EQ(map_value[EncodableValue("two")].IntValue(), 7);
// Ensure that it's a modifiable copy of the original map.
map_value[EncodableValue(true)] = EncodableValue(false);
ASSERT_EQ(map_value.size(), 4u);
EXPECT_EQ(encodables.size(), 3u);
EXPECT_EQ(map_value[EncodableValue(true)].BoolValue(), false);
}
TEST(EncodableValueTest, EmptyTypeConstructor) {
EXPECT_TRUE(EncodableValue(EncodableValue::Type::kNull).IsNull());
EXPECT_EQ(EncodableValue(EncodableValue::Type::kBool).BoolValue(), false);
EXPECT_EQ(EncodableValue(EncodableValue::Type::kInt).IntValue(), 0);
EXPECT_EQ(EncodableValue(EncodableValue::Type::kLong).LongValue(), 0l);
EXPECT_EQ(EncodableValue(EncodableValue::Type::kDouble).DoubleValue(), 0.0);
EXPECT_EQ(EncodableValue(EncodableValue::Type::kString).StringValue().size(),
0u);
EXPECT_EQ(
EncodableValue(EncodableValue::Type::kByteList).ByteListValue().size(),
0u);
EXPECT_EQ(
EncodableValue(EncodableValue::Type::kIntList).IntListValue().size(), 0u);
EXPECT_EQ(
EncodableValue(EncodableValue::Type::kLongList).LongListValue().size(),
0u);
EXPECT_EQ(EncodableValue(EncodableValue::Type::kDoubleList)
.DoubleListValue()
.size(),
0u);
EXPECT_EQ(EncodableValue(EncodableValue::Type::kList).ListValue().size(), 0u);
EXPECT_EQ(EncodableValue(EncodableValue::Type::kMap).MapValue().size(), 0u);
}
// Tests that the < operator meets the requirements of using EncodableValue as
// a map key.
TEST(EncodableValueTest, Comparison) {
EncodableList values = {
// Null
EncodableValue(),
// Bool
EncodableValue(true),
EncodableValue(false),
// Int
EncodableValue(-7),
EncodableValue(0),
EncodableValue(100),
// Long
EncodableValue(-7l),
EncodableValue(0l),
EncodableValue(100l),
// Double
EncodableValue(-7.0),
EncodableValue(0.0),
EncodableValue(100.0),
// String
EncodableValue("one"),
EncodableValue("two"),
// ByteList
EncodableValue(std::vector<uint8_t>{0, 1}),
EncodableValue(std::vector<uint8_t>{0, 10}),
// IntList
EncodableValue(std::vector<int32_t>{0, 1}),
EncodableValue(std::vector<int32_t>{0, 100}),
// LongList
EncodableValue(std::vector<int64_t>{0, 1l}),
EncodableValue(std::vector<int64_t>{0, 100l}),
// DoubleList
EncodableValue(std::vector<int64_t>{0, 1l}),
EncodableValue(std::vector<int64_t>{0, 100l}),
// List
EncodableValue(EncodableList{EncodableValue(), EncodableValue(true)}),
EncodableValue(EncodableList{EncodableValue(), EncodableValue(1.0)}),
// Map
EncodableValue(EncodableMap{{EncodableValue(), EncodableValue(true)},
{EncodableValue(7), EncodableValue(7.0)}}),
EncodableValue(
EncodableMap{{EncodableValue(), EncodableValue(1.0)},
{EncodableValue("key"), EncodableValue("value")}}),
};
for (size_t i = 0; i < values.size(); ++i) {
const auto& a = values[i];
for (size_t j = 0; j < values.size(); ++j) {
const auto& b = values[j];
if (i == j) {
// Identical objects should always be equal.
EXPECT_FALSE(a < b);
EXPECT_FALSE(b < a);
} else {
// All other comparisons should be consistent, but the direction doesn't
// matter.
EXPECT_NE(a < b, b < a);
}
}
// Different non-collection objects with the same value should be equal;
// different collections should always be unequal regardless of contents.
bool is_collection = a.IsByteList() || a.IsIntList() || a.IsLongList() ||
a.IsDoubleList() || a.IsList() || a.IsMap();
EncodableValue copy(a);
bool is_equal = !(a < copy || copy < a);
EXPECT_EQ(is_equal, !is_collection);
}
}
// Tests that structures are deep-copied.
TEST(EncodableValueTest, DeepCopy) {
EncodableList encodables = {
EncodableValue(EncodableMap{
{EncodableValue(), EncodableValue(std::vector<int32_t>{1, 2, 3})},
{EncodableValue(1), EncodableValue(10000l)},
{EncodableValue("two"), EncodableValue(7)},
}),
EncodableValue(EncodableList{
EncodableValue(),
EncodableValue(),
EncodableValue(
EncodableMap{{EncodableValue("a"), EncodableValue("b")}}),
}),
};
EncodableValue value(encodables);
ASSERT_TRUE(value.IsList());
// Spot-check innermost collection values.
EXPECT_EQ(value.ListValue()[0].MapValue()[EncodableValue("two")].IntValue(),
7);
EXPECT_EQ(value.ListValue()[1]
.ListValue()[2]
.MapValue()[EncodableValue("a")]
.StringValue(),
"b");
// Modify those values in the original structure.
encodables[0].MapValue()[EncodableValue("two")] = EncodableValue();
encodables[1].ListValue()[2].MapValue()[EncodableValue("a")] = 99;
// Re-check innermost collection values to ensure that they haven't changed.
EXPECT_EQ(value.ListValue()[0].MapValue()[EncodableValue("two")].IntValue(),
7);
EXPECT_EQ(value.ListValue()[1]
.ListValue()[2]
.MapValue()[EncodableValue("a")]
.StringValue(),
"b");
}
} // namespace flutter
| [
"noreply@github.com"
] | nynny.noreply@github.com |
c7b84a23caaac034ad82eeb9440017c024e550f8 | ceb020fee45a01645f0b2adc118483c6cf296226 | /NumberOfRecentCalls.cpp | 0038ca0482fd2397e7635d425182074c7deaeba0 | [] | no_license | anaypaul/LeetCode | 6423c4ca1b0d147206c06ebb86c9e558a85077f2 | 667825d32df2499301184d486e3a674291c0ca0b | refs/heads/master | 2021-09-28T06:05:21.256702 | 2020-10-12T04:01:46 | 2020-10-12T04:01:46 | 153,226,092 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 957 | cpp | class RecentCounter {
public:
queue<int> q;
RecentCounter() {
}
int ping(int t) {
int x = 1;
if(t- q.front() <= 3000){
x += q.size();
q.push(t);
}else{
while(t- q.front()>3000 && !q.empty()){
q.pop();
}
x += q.size();
q.push(t);
}
return x;
}
};
/**
* Your RecentCounter object will be instantiated and called as such:
* RecentCounter* obj = new RecentCounter();
* int param_1 = obj->ping(t);
*/
//new submission
class RecentCounter {
public:
queue<int> q;
RecentCounter() {
}
int ping(int t) {
q.push(t);
while(t-q.front() > 3000){
q.pop();
}
return q.size();
}
};
/**
* Your RecentCounter object will be instantiated and called as such:
* RecentCounter* obj = new RecentCounter();
* int param_1 = obj->ping(t);
*/ | [
"anay.paul2@gmail.com"
] | anay.paul2@gmail.com |
f8eadff15cd63296cd1ba6b8e5fd626989aa42e5 | 1d17c354e4f0c60a40b0d9a180d6c55df7d11e38 | /jni/libutils/jni/StreamingZipInflater.cpp | 8730878ad4b4f7fa21668bc07d12ae4f7d22b1dd | [
"Apache-2.0"
] | permissive | goodev/droidide | f217efc6754f510049a1976d4418f33a31babf89 | d23e6fb4add430c4b81e31697f011878dec64dde | refs/heads/master | 2020-04-12T18:59:59.956614 | 2014-10-03T11:55:28 | 2014-10-03T11:55:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,288 | cpp | /*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_NDEBUG 1
#define LOG_TAG "szipinf"
#include <utils/Log.h>
#include <utils/FileMap.h>
#include <utils/StreamingZipInflater.h>
#include <string.h>
#include <stddef.h>
#include <assert.h>
static inline size_t min_of(size_t a, size_t b) { return (a < b) ? a : b; }
using namespace android;
/*
* Streaming access to compressed asset data in an open fd
*/
StreamingZipInflater::StreamingZipInflater(int fd, off_t compDataStart,
size_t uncompSize, size_t compSize) {
mFd = fd;
mDataMap = NULL;
mInFileStart = compDataStart;
mOutTotalSize = uncompSize;
mInTotalSize = compSize;
mInBufSize = StreamingZipInflater::INPUT_CHUNK_SIZE;
mInBuf = new uint8_t[mInBufSize];
mOutBufSize = StreamingZipInflater::OUTPUT_CHUNK_SIZE;
mOutBuf = new uint8_t[mOutBufSize];
initInflateState();
}
/*
* Streaming access to compressed data held in an mmapped region of memory
*/
StreamingZipInflater::StreamingZipInflater(FileMap* dataMap, size_t uncompSize) {
mFd = -1;
mDataMap = dataMap;
mOutTotalSize = uncompSize;
mInTotalSize = dataMap->getDataLength();
mInBuf = (uint8_t*) dataMap->getDataPtr();
mInBufSize = mInTotalSize;
mOutBufSize = StreamingZipInflater::OUTPUT_CHUNK_SIZE;
mOutBuf = new uint8_t[mOutBufSize];
initInflateState();
}
StreamingZipInflater::~StreamingZipInflater() {
// tear down the in-flight zip state just in case
::inflateEnd(&mInflateState);
if (mDataMap == NULL) {
delete [] mInBuf;
}
delete [] mOutBuf;
}
void StreamingZipInflater::initInflateState() {
LOGD("Initializing inflate state");
memset(&mInflateState, 0, sizeof(mInflateState));
mInflateState.zalloc = Z_NULL;
mInflateState.zfree = Z_NULL;
mInflateState.opaque = Z_NULL;
mInflateState.next_in = (Bytef*)mInBuf;
mInflateState.next_out = (Bytef*) mOutBuf;
mInflateState.avail_out = mOutBufSize;
mInflateState.data_type = Z_UNKNOWN;
mOutLastDecoded = mOutDeliverable = mOutCurPosition = 0;
mInNextChunkOffset = 0;
mStreamNeedsInit = true;
if (mDataMap == NULL) {
::lseek(mFd, mInFileStart, SEEK_SET);
mInflateState.avail_in = 0; // set when a chunk is read in
} else {
mInflateState.avail_in = mInBufSize;
}
}
/*
* Basic approach:
*
* 1. If we have undelivered uncompressed data, send it. At this point
* either we've satisfied the request, or we've exhausted the available
* output data in mOutBuf.
*
* 2. While we haven't sent enough data to satisfy the request:
* 0. if the request is for more data than exists, bail.
* a. if there is no input data to decode, read some into the input buffer
* and readjust the z_stream input pointers
* b. point the output to the start of the output buffer and decode what we can
* c. deliver whatever output data we can
*/
ssize_t StreamingZipInflater::read(void* outBuf, size_t count) {
uint8_t* dest = (uint8_t*) outBuf;
size_t bytesRead = 0;
size_t toRead = min_of(count, size_t(mOutTotalSize - mOutCurPosition));
while (toRead > 0) {
// First, write from whatever we already have decoded and ready to go
size_t deliverable = min_of(toRead, mOutLastDecoded - mOutDeliverable);
if (deliverable > 0) {
if (outBuf != NULL) memcpy(dest, mOutBuf + mOutDeliverable, deliverable);
mOutDeliverable += deliverable;
mOutCurPosition += deliverable;
dest += deliverable;
bytesRead += deliverable;
toRead -= deliverable;
}
// need more data? time to decode some.
if (toRead > 0) {
// if we don't have any data to decode, read some in. If we're working
// from mmapped data this won't happen, because the clipping to total size
// will prevent reading off the end of the mapped input chunk.
if (mInflateState.avail_in == 0) {
int err = readNextChunk();
if (err < 0) {
LOGE("Unable to access asset data: %d", err);
if (!mStreamNeedsInit) {
::inflateEnd(&mInflateState);
initInflateState();
}
return -1;
}
}
// we know we've drained whatever is in the out buffer now, so just
// start from scratch there, reading all the input we have at present.
mInflateState.next_out = (Bytef*) mOutBuf;
mInflateState.avail_out = mOutBufSize;
/*
LOGD("Inflating to outbuf: avail_in=%u avail_out=%u next_in=%p next_out=%p",
mInflateState.avail_in, mInflateState.avail_out,
mInflateState.next_in, mInflateState.next_out);
*/
int result = Z_OK;
if (mStreamNeedsInit) {
LOGD("Initializing zlib to inflate");
result = inflateInit2(&mInflateState, -MAX_WBITS);
mStreamNeedsInit = false;
}
if (result == Z_OK) result = ::inflate(&mInflateState, Z_SYNC_FLUSH);
if (result < 0) {
// Whoops, inflation failed
LOGE("Error inflating asset: %d", result);
::inflateEnd(&mInflateState);
initInflateState();
return -1;
} else {
if (result == Z_STREAM_END) {
// we know we have to have reached the target size here and will
// not try to read any further, so just wind things up.
::inflateEnd(&mInflateState);
}
// Note how much data we got, and off we go
mOutDeliverable = 0;
mOutLastDecoded = mOutBufSize - mInflateState.avail_out;
}
}
}
return bytesRead;
}
int StreamingZipInflater::readNextChunk() {
assert(mDataMap == NULL);
if (mInNextChunkOffset < mInTotalSize) {
size_t toRead = min_of(mInBufSize, mInTotalSize - mInNextChunkOffset);
if (toRead > 0) {
ssize_t didRead = ::read(mFd, mInBuf, toRead);
//LOGD("Reading input chunk, size %08x didread %08x", toRead, didRead);
if (didRead < 0) {
// TODO: error
LOGE("Error reading asset data");
return didRead;
} else {
mInNextChunkOffset += didRead;
mInflateState.next_in = (Bytef*) mInBuf;
mInflateState.avail_in = didRead;
}
}
}
return 0;
}
// seeking backwards requires uncompressing fom the beginning, so is very
// expensive. seeking forwards only requires uncompressing from the current
// position to the destination.
off_t StreamingZipInflater::seekAbsolute(off_t absoluteInputPosition) {
if (absoluteInputPosition < mOutCurPosition) {
// rewind and reprocess the data from the beginning
if (!mStreamNeedsInit) {
::inflateEnd(&mInflateState);
}
initInflateState();
read(NULL, absoluteInputPosition);
} else if (absoluteInputPosition > mOutCurPosition) {
read(NULL, absoluteInputPosition - mOutCurPosition);
}
// else if the target position *is* our current position, do nothing
return absoluteInputPosition;
}
| [
"Administrator@USER-J9L630860H"
] | Administrator@USER-J9L630860H |
bc5604be5579e165c533ea525cbb0b2802d058b2 | eebfd60a94004abd8d2459c2f6bb0b74018dc5f7 | /src/amg_solvers.cpp | c8952188b8f4523f40af5ca65654cea9d1e2872e | [] | no_license | kahnon/Poisson2D-amg-lib | b072bf15f15bd5834f3167fa64fa7fc5bb7cf4fd | d7cac64edb9899d65e8ee524b6183c9fe23a7491 | refs/heads/master | 2022-12-21T03:16:55.105896 | 2020-10-02T11:08:28 | 2020-10-02T11:08:28 | 300,580,042 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,094 | cpp | #include <vector>
#include <limits>
#include <math.h>
#include "amg_solvers.h"
#include "smoothing.h"
#include "amg_solve_components.h"
#include "matrix.h"
#include "amg_benchmark.h"
//sor solver with system matrix "matrix", rhs "rhs", damping parameter omega
//and guess phi. Iteration until max_norm of residual is smaller than maxerror
//or maxstep is reached
void sor(const Matrix& matrix, const std::vector<double>& rhs, std::vector<double>& phi, int error_interval, double maxerror, int maxstep, double omega){
assert(matrix.size() == rhs.size() && "matrix & vector size dont match in sor(...)");
assert(matrix.size() == phi.size() && "matrix & vector size dont match in sor(...)");
int steps=0;
double error=1;
std::vector<double> phi_old(0);
do{
//checkerboard pattern
for(auto i=0u;i<rhs.size();i+=2) sor_base_with_bounds(i,matrix,rhs,phi_old,phi,omega);
for(auto i=1u;i<rhs.size();i+=2) sor_base_with_bounds(i,matrix,rhs,phi_old,phi,omega);
++steps;
if(steps%error_interval == 0) error = calc_max_norm_res(matrix,rhs,phi).second;
}while(error > maxerror && steps<maxstep);
std::cout<<"sor: error="<<error<<" steps="<<steps<<std::endl;
}
//jacobi solver with system matrix "matrix", rhs "rhs", damping parameter omega
//and guess phi. Iteration until max_norm of residual is smaller than maxerror
//or maxstep is reached
void jacobi(const Matrix& matrix, const std::vector<double>& rhs, std::vector<double>& phi, int error_interval, double maxerror, int maxstep, double omega){
assert(matrix.size() == rhs.size() && "matrix & vector size dont match in jacobi(...)");
assert(matrix.size() == phi.size() && "matrix & vector size dont match in jacobi(...)");
int steps=0;
double error=1;
std::vector<double> phi_old(phi);
do{
for(auto i=0u;i<rhs.size();++i) jacobi_base_with_bounds(i,matrix,rhs,phi_old,phi,1);
++steps;
if(steps%error_interval == 0) error = calc_max_norm_res(matrix,rhs,phi).second;
std::copy(phi.begin(),phi.end(),phi_old.begin());
}while(error > maxerror && steps<maxstep);
std::cout<<"jacobi: error="<<error<<" steps="<<steps<<std::endl;
}
//non pre-conditioned cg method to solve the AMG system on the lowest level
//(should be) guaranteed to converge after dim(phi) steps
void cg(const Matrix& matrix, const std::vector<double>& rhs, std::vector<double>& phi, int maxsteps, double acc){
assert(matrix.size() == rhs.size() && "matrix & vector size dont match in cg(...)");
assert(matrix.size() == phi.size() && "matrix & vector size dont match in cg(...)");
double error=0;
int steps=0;
std::vector<double> residual=matrix_vector(matrix,phi);
for(auto i=0u;i<residual.size();++i) residual[i] = rhs[i] - residual[i];
std::vector<double> direction=residual;
std::vector<double> mvprod(direction.size(),0);
std::vector<double> new_residual(residual);
for(auto i=0;i<maxsteps;++i){
error=0;
++steps;
//save this mvproduct
mvprod = matrix_vector(matrix,direction);
//find phi in search direction and update gradient and residual
double alpha = scalar_product(residual,residual);
alpha /= scalar_product(direction,mvprod);
for(auto k=0u;k<phi.size();++k) phi[k]+=alpha*direction[k];
for(auto k=0u;k<residual.size();++k){
new_residual[k] = residual[k] - alpha*mvprod[k];
//find maximum norm of residual
if(fabs(new_residual[k])>error) error=fabs(new_residual[k]);
}
if(error<acc) break;
//update search direction
double beta = scalar_product(new_residual,new_residual);
beta /= scalar_product(residual,residual);
for(auto k=0u;k<direction.size();++k) direction[k] = new_residual[k] + beta*direction[k];
std::copy(new_residual.begin(),new_residual.end(),residual.begin());
}
//std::cout<<" cg: error="<<error<<" steps="<<steps<<std::endl;
}
//v-cycle: move straight down to coarsest level,
//then back up and repeat until convergence
void solve_v_cycle(AMGhierarchy& Hier, const std::vector<double>& rho, std::vector<double>& phi, int maxsteps,
int smooth_steps, bool gen_flag, double maxerror){
init_benchmark_variables();
int solve_id = AMGbench::start();
int max_level=Hier[0].max_level;
//int max_level=2;
int steps=0;
std::vector<int> stepsvec(max_level,smooth_steps);
//if gen flag=true, use generalized cycle
if(gen_flag){
for(auto i=0;i<max_level;++i){
stepsvec[i] = (i+1) * smooth_steps;
}
}
AMGlvl& coarsest_lvl = Hier[max_level-1];
//init first guess for each level
Hier[0].phi = phi;
Hier[0].rhs = rho;
for(auto i=1;i<max_level;++i){
std::fill(Hier[i].phi.begin(),Hier[i].phi.end(),0);
std::fill(Hier[i].rhs.begin(),Hier[i].rhs.end(),0);
}
auto v_iteration = [&](){
double error = 0;
//go "down" from i to next coarser lvl all the way to coarsest level
for(auto i=0;i<max_level-1;++i){
int id = AMGbench::start();
double cycerror = go_down(i,Hier,maxerror,stepsvec[i]);
go_down_time+=AMGbench::stop(id);
id=AMGbench::start();
if(i==0){
error=cycerror;
if(error < maxerror) return error;
}
error_time+=AMGbench::stop(id);
}
//almost exact solution on coarsest grid
int id = AMGbench::start();
//cg(coarsest_lvl.matrix,coarsest_lvl.rhs,coarsest_lvl.phi,std::numeric_limits<int>::max());
cg(coarsest_lvl.matrix,coarsest_lvl.rhs,coarsest_lvl.phi,500);
//sor(coarsest_lvl.matrix, coarsest_lvl.rhs, coarsest_lvl.phi, 10, 1e-12, 500, 1);
cg_time+=AMGbench::stop(id);
//go back "up" again from i t0 next finer lvl
id=AMGbench::start();
for(auto i=max_level-1;i>0;--i) go_up(i,Hier,maxerror,stepsvec[i]);
go_up_time+=AMGbench::stop(id);
return error;
};
double error=1;
do{
error = v_iteration();
++steps;
std::cout<<"v-cycle step "<<steps<<", error "<<error<<std::endl;
}while(error>maxerror && steps<maxsteps);
phi=Hier[0].phi;
//std::cout<<"AMG V-cycle: cycles="<<steps<<" "<<"error="<<error<<std::endl;
long int pts = number_of_points(Hier);
std::cout<<"*********************AMG V-CYCLE TIMES*********************"<<std::endl;
std::cout<<" Solve took "<<AMGbench::stop(solve_id)/1000.<<"s with "<<steps<<" cycles and error="<<error<<std::endl;
std::cout<<" Go Down took "<<1e6*go_down_time/(steps*pts)<<" ps/(cyc*pt)."<<std::endl;
std::cout<<" Pre-Smoothing took "<<1e6*pre_smoothing_time/(steps*pts)<<" ps/(cyc*pt)."<<std::endl;
std::cout<<" Residual Calculation took "<<1e6*residual_time/(steps*pts)<<" ps/(cyc*pt)."<<std::endl;
std::cout<<" Restriction took "<<1e6*restriction_time/(steps*pts)<<" ps/(cyc*pt)."<<std::endl<<std::endl;
std::cout<<" CG solve took "<<1e6*cg_time/(steps*pts)<<" ps/(cyc.*pt)"<<std::endl<<std::endl;
std::cout<<" Go Up took "<<1e6*go_up_time/(steps*pts)<<" ps/(cyc*pt)."<<std::endl;
std::cout<<" Post-Smoothing took "<<1e6*post_smoothing_time/(steps*pts)<<" ps/(cyc*pt)."<<std::endl;
std::cout<<" Jacobi Sweeps took "<<1e6*jacobi_sweep_time/(steps*pts)<<" ps/(cyc*pt)."<<std::endl;
std::cout<<" Interpolation took "<<1e6*interpolation_time/(steps*pts)<<" ps/(cyc*pt)."<<std::endl;
std::cout<<" Error Checks took "<<1e6*error_time/(steps*pts)<<" ps/(cyc*pt)."<<std::endl;
std::cout<<"***********************************************************"<<std::endl<<std::endl;
}
//TODO pass parameters of amg preconditioning
void amg_preconditioned_cg(AMGhierarchy& hier, const std::vector<double>& rhs, std::vector<double>& phi,
std::function<void(AMGhierarchy&,const std::vector<double>&,std::vector<double>&,int,int,bool,double)> precondition,
bool gen_flag, int maxsteps, double acc){
//system matrix the same for both systems
Matrix& matrix = hier[0].matrix;
assert(matrix.size() == rhs.size() && "matrix & vector size dont match in cg(...)");
assert(matrix.size() == phi.size() && "matrix & vector size dont match in cg(...)");
double error=0;
int steps=0;
//move out of here and cg() from above
auto scalar_product = [](const std::vector<double>& v1, const std::vector<double>& v2){
assert(v1.size() == v2.size() && "vector dimensions dont match in scalar_product");
double result=0;
for(auto i=0u;i<v1.size();++i) result+=v1[i]*v2[i];
return result;
};
//needed to set residual as rhs for preconditioner
std::vector<double> residual=matrix_vector(matrix,phi);
for(auto i=0u;i<residual.size();++i) residual[i] = rhs[i] - residual[i];
//preconditioned variable used here
std::vector<double> prec_residual(residual);
precondition(hier,residual,prec_residual,30,2,gen_flag,1e-12);
//search direction in preconditioned residual
std::vector<double> direction(prec_residual);
std::vector<double> mvprod(direction.size(),0);
double delta = scalar_product(residual,prec_residual);
double new_delta = delta;
for(auto i=0;i<maxsteps;++i){
error=0;
++steps;
//save this mvproduct
mvprod = matrix_vector(matrix,direction);
//find phi in search direction and update residual
double alpha = delta;
alpha /= scalar_product(direction,mvprod);
for(auto k=0u;k<phi.size();++k) phi[k]+=alpha*direction[k];
for(auto k=0u;k<residual.size();++k){
residual[k] -= alpha*mvprod[k];
if(fabs(residual[k]) > error) error = fabs(residual[k]);
}
if(error < acc) break;
//use preconditioning
precondition(hier,residual,prec_residual,30,2,gen_flag,1e-12);
//update coefficients for new search direction
new_delta = scalar_product(residual,prec_residual);
double beta = new_delta / delta;
delta = new_delta;
//std::cout<<"step="<<steps<<" error="<<error<<" alpha="<<alpha<<" beta="<<beta<<" delta="<<delta<<std::endl;
//update search direction
for(auto k=0u;k<direction.size();++k) direction[k] = prec_residual[k] + beta*direction[k];
}
std::cout<<"amg_preconditioned_cg: error="<<error<<" steps="<<steps<<std::endl;
}
| [
"kahnon@users.noreply.github.com"
] | kahnon@users.noreply.github.com |
c4bc97c97cfe5ef90c39d2f1e74d27227bee87f0 | 2deb357c9708a98f629e356df640d1b9e812aa60 | /budujemy/main.cpp | 16bc729d05bdf94385260c9f1505c9cdcf6694c9 | [] | no_license | majkimge/CompetitiveProgrammingCode | 149f2eaae4763db16a6bef143ca037e46a5f3085 | d250be7703ad56072e914c2426f86b22305b3ac4 | refs/heads/main | 2023-01-20T07:30:36.769917 | 2020-11-24T16:51:07 | 2020-11-24T16:51:07 | 315,691,829 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 745 | cpp | #include <bits/stdc++.h>
#define lld long long
#define pb push_back
#define MAX 100009
#define INF 2000000000
using namespace std;
lld n,a,best;
lld wys[MAX];
lld koszt[MAX];
lld wyny[MAX];
int main()
{
scanf("%lld",&n);
for(int i=1;i<=n;++i){
scanf("%lld",&wys[i]);
}
scanf("%lld",&a);
koszt[1]=a;
for(int i=2;i<=n;++i){
scanf("%lld",&a);
koszt[i]=koszt[i-1]+a;
//cout<<koszt[i];
}
for(int i=2;i<=n;++i){
best=INF;
for(int j=1;j<i;++j){
best=min(best,(wys[i]-wys[j])*(wys[i]-wys[j])+koszt[i-1]-koszt[j]+wyny[j]);
}
wyny[i]=best;
}
printf("%lld",wyny[n]);
return 0;
}
| [
"noreply@github.com"
] | majkimge.noreply@github.com |
3ce79245367be2a20d27aedcc22a81c3e7de8cb5 | 03b5b626962b6c62fc3215154b44bbc663a44cf6 | /src/keywords/_endif.h | 889a4c407335d2c144341ffddf086a23698f6eb7 | [] | no_license | haochenprophet/iwant | 8b1f9df8ee428148549253ce1c5d821ece0a4b4c | 1c9bd95280216ee8cd7892a10a7355f03d77d340 | refs/heads/master | 2023-06-09T11:10:27.232304 | 2023-05-31T02:41:18 | 2023-05-31T02:41:18 | 67,756,957 | 17 | 5 | null | 2018-08-11T16:37:37 | 2016-09-09T02:08:46 | C++ | UTF-8 | C++ | false | false | 208 | h | #ifndef _ENDIF_H
#define _ENDIF_H
#include "../object.h"
namespace n__endif {
class C_endif :public Object
{
public:
C_endif();
int my_init(void *p=nullptr);
};
}
using namespace n__endif;
#endif
| [
"hao__chen@sina.com"
] | hao__chen@sina.com |
b1dbac5e6527ec4532bccdf2dfed128f70d7f743 | 44a676b33c39798820bc1a6819b6cd6a156bf108 | /Bit Manip Practice/min-bit-operations.cpp | f073ea1fd844aa1da3f3dffdb646f72462b7e204 | [] | no_license | Mayank-MP05/CPP-Codes-Contests | 9111a02221ac64031f5516c88c36df039975f073 | f5113b4a84517df7ecce010da98f12aaf91e8259 | refs/heads/main | 2023-04-19T07:09:41.961955 | 2021-05-07T11:47:07 | 2021-05-07T11:47:07 | 354,313,141 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,929 | cpp | #include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(i=0;i<n;i++)
#define ll long long
#define deb(x) if(SHOW) cout << #x << "=" << x << endl
#define deb2(x, y) if(SHOW) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define debArr(a,n) if(SHOW) for(int z=0;z<n;z++){ cout<<a[z]<<" "; } cout<<endl;
#define deb2DArr(a,m,n) if(SHOW) for(int z=0;z<m;z++){for(int y=0;y<n;y++){ cout<<a[z][y]<<" "; } cout<<endl;}
#define deb3(x, y, z) if(SHOW) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" |\
"<<#z<<": "<<z<<endl
#define deb4(a, b, c, d) if(SHOW) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" |\
"<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e) if(SHOW) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" |\
"<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) if(SHOW) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<< c<<" |\
"<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define line if(SHOW) cout<<"\n__________________________________________\n";
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define SHOW false
void solve() {
ll i, j, n, m, k;
cin >> n >> m;
vl A(n), B(m);
fo(i, n) {
cin >> A[i];
}
fo(i, m) {
cin >> B[i];
}
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
// cin >> t;
while (t--) {
solve();
line;
}
return 0;
}
| [
"mayank5pande@gmail.com"
] | mayank5pande@gmail.com |
42c500f32900db9b4a13cc8baeacf7ae29bbe3f5 | fed9f14edb87cd975ac946e01e063df492a9929a | /src/hhkb2020/A.cpp | dcdbc609bb0695788e362c8ec1702dc5743f0bcd | [] | no_license | n-inja/kyoupro | ba91dd582488b2a8c7222242801cf3115ed7fd10 | 44c5a888984764b98e105780ca57d522a47d832d | refs/heads/master | 2021-01-01T06:52:59.655419 | 2020-10-17T13:28:35 | 2020-10-17T13:28:35 | 97,537,227 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 421 | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
string s, t;
cin >> s >> t;
if (s == "Y") {
for (char c : t) cout << (char) (c + 'A' - 'a');
cout << endl;
} else {
cout << t << endl;
}
return 0;
}
| [
"mail@n-inja.me"
] | mail@n-inja.me |
3c0106f59efb88c2fb511870d879ae4b04946f34 | 9f170204f6976fe59d9ee74aa78f62b10663c051 | /third_party/sputnik/sputnik/depthwise/filter_tile.h | e015b3c75925f56f64a90bafcd977fd0ce013d46 | [
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | hercules261188/xformers | 04132b4c94bfb59ea9917ccf29800a049f924da9 | 71bab94cb954e6e291ca93d3bce5dffadab4286d | refs/heads/main | 2023-09-06T02:51:47.086611 | 2021-11-24T16:36:22 | 2021-11-24T16:36:22 | 431,593,450 | 1 | 0 | NOASSERTION | 2021-11-24T18:43:24 | 2021-11-24T18:43:23 | null | UTF-8 | C++ | false | false | 2,665 | h | // Copyright 2020 The Sputnik Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef THIRD_PARTY_SPUTNIK_DEPTHWISE_FILTER_TILE_H_
#define THIRD_PARTY_SPUTNIK_DEPTHWISE_FILTER_TILE_H_
#include "sputnik/common.h"
#include "sputnik/load_store.h"
#include "sputnik/tiling_utils.h"
namespace sputnik {
template <int kKernelSize, int kBlockDimX>
struct FilterTile {
//
/// Static members.
//
// The number of weights in each filter.
static constexpr int kNumWeights = kKernelSize * kKernelSize;
//
/// Member variables.
//
const float* filters;
float* smem;
float* filter_fragment;
__device__ __forceinline__ FilterTile(int filter_offset,
const float* __restrict__ filters_,
float* __restrict__ smem_,
float* __restrict__ filter_fragment_)
: filters(filters_ + filter_offset),
smem(smem_),
filter_fragment(filter_fragment_) {}
__device__ __forceinline__ void Load() {
// TODO(tgale): This should always be true. We could get rid of
// this an just have the compiler unroll a loop.
const int thread_idx = threadIdx.x + threadIdx.y * kBlockDimX;
if (thread_idx < kNumWeights) {
Store(sputnik::Load(filters + thread_idx), smem + thread_idx);
}
__syncthreads();
// Load all of the weights. We use 4-wide vector loads. This
// loads a few more values than we need, but it doesn't matter
// and the register allocator should just reuse those registers
// right after we store to them.
constexpr int kValuesPerLoad = 4;
constexpr int kSharedFilterLoads =
RoundUpTo(kNumWeights, kValuesPerLoad) / kValuesPerLoad;
auto vector_smem = OffsetCast<const float4>(smem, 0);
auto vector_filter_fragment = OffsetCast<float4>(filter_fragment, 0);
#pragma unroll
for (int load_idx = 0; load_idx < kSharedFilterLoads; ++load_idx) {
Store(vector_smem[load_idx], vector_filter_fragment);
vector_filter_fragment++;
}
}
};
} // namespace sputnik
#endif // THIRD_PARTY_SPUTNIK_DEPTHWISE_FILTER_TILE_H_
| [
"benjamin.lefaudeux@gmail.com"
] | benjamin.lefaudeux@gmail.com |
3346858788df68ac393ec145d83ec6a9474e0e44 | 8ed64d957b1999a8b6b1aba7c5bea22a5c767d1a | /riegeli/chunk_encoding/simple_decoder.cc | 42f11fe3f94ac0789d8c3d04a56d4d14bf72bb44 | [
"Apache-2.0"
] | permissive | Bingo20/riegeli | 4b14b1793136ffdcb0d8682e964c496005f8f9fc | 2f2f1c72c30267cd2386607059f54b5214219c4c | refs/heads/master | 2021-04-16T14:30:01.324619 | 2020-03-21T11:07:13 | 2020-03-21T11:12:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,994 | cc | // Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "riegeli/chunk_encoding/simple_decoder.h"
#include <stddef.h>
#include <stdint.h>
#include <limits>
#include <tuple>
#include <vector>
#include "absl/base/optimization.h"
#include "absl/status/status.h"
#include "absl/types/optional.h"
#include "riegeli/base/base.h"
#include "riegeli/base/object.h"
#include "riegeli/bytes/limiting_reader.h"
#include "riegeli/bytes/reader.h"
#include "riegeli/bytes/reader_utils.h"
#include "riegeli/bytes/varint_reading.h"
#include "riegeli/chunk_encoding/constants.h"
#include "riegeli/chunk_encoding/decompressor.h"
namespace riegeli {
void SimpleDecoder::Done() {
if (ABSL_PREDICT_FALSE(!values_decompressor_.Close())) {
Fail(values_decompressor_);
}
}
bool SimpleDecoder::Decode(Reader* src, uint64_t num_records,
uint64_t decoded_data_size,
std::vector<size_t>* limits) {
Object::Reset(kInitiallyOpen);
if (ABSL_PREDICT_FALSE(num_records > limits->max_size())) {
return Fail(absl::ResourceExhaustedError("Too many records"));
}
if (ABSL_PREDICT_FALSE(decoded_data_size >
std::numeric_limits<size_t>::max())) {
return Fail(absl::ResourceExhaustedError("Records too large"));
}
const absl::optional<uint8_t> compression_type_byte = ReadByte(src);
if (ABSL_PREDICT_FALSE(compression_type_byte == absl::nullopt)) {
src->Fail(absl::DataLossError("Reading compression type failed"));
return Fail(*src);
}
const CompressionType compression_type =
static_cast<CompressionType>(*compression_type_byte);
const absl::optional<uint64_t> sizes_size = ReadVarint64(src);
if (ABSL_PREDICT_FALSE(sizes_size == absl::nullopt)) {
src->Fail(absl::DataLossError("Reading size of sizes failed"));
return Fail(*src);
}
if (ABSL_PREDICT_FALSE(*sizes_size >
std::numeric_limits<Position>::max() - src->pos())) {
return Fail(absl::ResourceExhaustedError("Size of sizes too large"));
}
internal::Decompressor<LimitingReader<>> sizes_decompressor(
std::forward_as_tuple(src, src->pos() + *sizes_size), compression_type);
if (ABSL_PREDICT_FALSE(!sizes_decompressor.healthy())) {
return Fail(sizes_decompressor);
}
limits->clear();
size_t limit = 0;
while (limits->size() != num_records) {
const absl::optional<uint64_t> size =
ReadVarint64(sizes_decompressor.reader());
if (ABSL_PREDICT_FALSE(size == absl::nullopt)) {
sizes_decompressor.reader()->Fail(
absl::DataLossError("Reading record size failed"));
return Fail(*sizes_decompressor.reader());
}
if (ABSL_PREDICT_FALSE(*size > decoded_data_size - limit)) {
return Fail(
absl::DataLossError("Decoded data size larger than expected"));
}
limit += IntCast<size_t>(*size);
limits->push_back(limit);
}
if (ABSL_PREDICT_FALSE(!sizes_decompressor.VerifyEndAndClose())) {
return Fail(sizes_decompressor);
}
if (ABSL_PREDICT_FALSE(limit != decoded_data_size)) {
return Fail(absl::DataLossError("Decoded data size smaller than expected"));
}
values_decompressor_.Reset(src, compression_type);
if (ABSL_PREDICT_FALSE(!values_decompressor_.healthy())) {
return Fail(values_decompressor_);
}
return true;
}
bool SimpleDecoder::VerifyEndAndClose() {
values_decompressor_.VerifyEnd();
return Close();
}
} // namespace riegeli
| [
"qrczak@google.com"
] | qrczak@google.com |
0511de1b4ad71bdf71e1966dfd12621b2f8ccc7e | 55f5d42e9e2cbfb2c3d41c1dd0050fbb6ad13781 | /get_Serial_32_demo/get_Serial_32_demo.ino | 04890a843610ed568465dff4b39384c095029649 | [] | no_license | juchani/respaldp | 97c2f4555134c376f132306dbe846adc7e7c0722 | 0e46792a35d076c45562e0b58cbaec3ae08cd4f5 | refs/heads/master | 2021-09-01T21:52:58.353039 | 2021-08-03T15:26:27 | 2021-08-03T15:26:27 | 134,037,744 | 0 | 0 | null | 2018-05-19T06:55:22 | 2018-05-19T06:51:54 | null | UTF-8 | C++ | false | false | 1,382 | ino | #include <WiFi.h>
#include <HTTPClient.h>
#include <SoftwareSerial.h>
SoftwareSerial rs232(26, 27);//rx-tx
const char* ssid = "juchani";/////red
const char* password = "12345678";//////////pasword
String url = "http://clinica.solucionespymes.com/apic/savedata?list=FREND";
unsigned long lastTime = 0;
unsigned long timerDelay = 5000;
String texto = "", E;
String item_code, test_result, test_unit, ref_max, ref_min, date_time, ver = "1.0.0.0";
String total[8] = {E, item_code, test_result, test_unit, ref_max, ref_min, date_time, ver};
int buzzer = 12, led = 13;
int vacio = 0, limite = 0;
String fecha;
bool error = 0;
void setup()
{
Serial.begin(9600);
rs232.begin(9600);
WiFi.begin(ssid, password);
Serial.println("Connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());
Serial.println("Timer set to 5 seconds (timerDelay variable), it will take 5 seconds before publishing the first reading.");
pinMode(buzzer, OUTPUT);
pinMode(led, OUTPUT);
delay(10);
digitalWrite(led, 0);
}
void loop()
{
updateSerial();
Serial.println(rs232.available());
delay(10);
}
String li(bool n, String l) {
l.trim();
if (n == 0) {
l = l + "|";
}
else {
l = "|" + l + "|";
}
return l;
}
| [
"victorfrancojuchani@gmail.com"
] | victorfrancojuchani@gmail.com |
3f19238d0ea1c69840cd49a6c9612150fe7c772d | 5bb2d3364a529f7b15c97d2f3aa175e77af3c695 | /cf318A.cpp | f37893a916d0e8cc3b4fdc17272e9cda01f2c0ce | [] | no_license | suraj021/Codeforces-Solutions | c589cf3ff72aa5297d06e854c73aa2d587ed4257 | 7d669635778700c4772674865c7b7560abe2cf89 | refs/heads/master | 2021-01-17T02:22:27.159917 | 2018-06-23T15:12:05 | 2018-06-23T15:12:05 | 37,797,992 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 323 | cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
long long int n, k, ans;
cin >> n >> k;;
if( n%2== 0 ){
if( k <= n/2 ){
ans= 2*k - 1;
}else{
k-= n/2;
ans= 2*k;
}
}else{
if( k<= n/2 + 1 ){
ans= 2*k - 1;
}else{
k= k- n/2 - 1;
ans= 2*k;
}
}
cout << ans << endl;
} | [
"surajbora021@gmail.com"
] | surajbora021@gmail.com |
7000ab36d1e5ae2539c2541158d2562726db33a9 | 43317a28027bf058cb382f8b4587c5af09345ff5 | /tinyurl.cpp | fb435c5b3b531cfb0a4b45b24f6bacddaff77858 | [] | no_license | ScoobyKot/TinyUrl | 6b701e402057e85fd10d20cfece344686b554b1c | 309c8977214ce9a4cd7806f3a08ae0ec00640c1b | refs/heads/master | 2020-05-01T05:01:35.691761 | 2019-03-23T13:03:43 | 2019-03-23T13:03:43 | 177,289,666 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,694 | cpp | /*
[2 punkty] LeetCode Przygotwać bibliotekę wspomagającą tworzenie skróconych adresów URL.
W tym celu może pomóc Zdefniowanie metody generotora, która jest testowana w pierwszym kroku testów.
Na podstawie aktualnego stanu generatora (tablica 6 znaków) wyznacza następny stan.
Tablicę stanu można dalej przechowywać w strukturze TinyUrlCodec
Moduł: tinyurl
Pliki z implementacją: TinyUrl.h/cpp
Używana struktura danych: TinyUrlCodec
Sygnatury metod:
std::unique_ptr<TinyUrlCodec> Init();
void NextHash(std::arrray<char, 6> *state);
std::string Encode(const std::string &url, std::unique_ptr<TinyUrlCodec> *codec);
std::string Decode(const std::unique_ptr<TinyUrlCodec> &codec, const std::string &hash);
Przestrzeń nazw: tinyurl
Importy:
#include <utility>
#include <string>
#include <array>
#include <memory>
*/
#include <iostream>
#include <utility>
#include <string>
#include <array>
#include <memory>
#include <regex>
using namespace std;
char letters[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
struct TinyUrlCodec
{
string long_url;
string short_url;
};
string lpu(string sb_url)
{
int rand_let;
string ti_url;
int tab[6] ;
for (int i = 0; i<6; i++)
{
rand_let = rand() %25 +0;
//cout << "random "<< rand_let<<endl;
ti_url +=letters[rand_let];
//cout<<ti_url<<endl;
}
sb_url +=ti_url;
return sb_url;
}
int main() {
srand( time( NULL ) );
char LETTERS[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
string long_url;
string t_u;
regex patter ("http://www.(\\w).(\\w)\[ ^ ]");
//cout<<"wprowadz url: ";
//cin>>long_url;
//cout<<long_url;
int num_slash = 0;
string sb_url;
string url ;
cout << "Wprowadz nazwe strony "<<endl;cin>>url;
for (int i = 0 ; i<url.length();i++)
{
if (num_slash == 3)
{
break;
}
//cout<<url[i]<<endl;
if (url[i] == '/')
{
num_slash++;
//cout << "Number of slash "<< num_slash<<endl;
}
sb_url +=url[i];
}
//cout<<sb_url<<endl;
//cout<<sb_url<<endl;
string short_url = lpu(sb_url);
cout<<short_url<<endl;
TinyUrlCodec new_url =
{
url,
short_url
};
//cout<< new_url.long_url << "<=>"<<new_url.short_url;
return 0;
}
| [
"scoobykot@gmail.com"
] | scoobykot@gmail.com |
758d19cc77c25b69fbb885903fb1217d5ea54f9a | cd6b2186ca53fe47540558e043265767bb08d06e | /TuscaroraFW/Lib/DS/GenericMessages.h | a41f5a6509c6dc8d952ae950d8ecda41947cd125 | [] | no_license | Samraksh/Tuscarora | 699135be343665f3a10cc95ea5ddd638f4909a21 | c62be9345518b609c9332202625c500b716d1fce | refs/heads/master | 2021-03-30T17:37:03.919357 | 2017-07-20T18:25:04 | 2017-07-20T18:41:39 | 88,296,912 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 33,189 | h | //////////////////////////////////////////////////////////////////////////////////
// Tuscarora Software Suite. The Samraksh Company. All rights reserved.
// Please see License.txt file in the software root directory for usage rights.
// Please see developer's manual for implementation notes.
//////////////////////////////////////////////////////////////////////////////////
#ifndef GENERIC_MESSAGE_H
#define GENERIC_MESSAGE_H
#include <iostream>
#include <type_traits>
#include <assert.h>
#include <cstdint>
#include <cstring>
#include <stdlib.h>
#include <Lib/Misc/Debug.h>
#include <sys/socket.h>
#include <Sys/SocketShim.h>
#include <unistd.h>
#include <sys/ioctl.h>
#define DBG_GEN_MSG 0
typedef uint8_t GenericMsgPayloadSize_t;
template< class T >
struct TypeIsInt
{
static const bool value = false;
};
template<>
struct TypeIsInt< GenericMsgPayloadSize_t >
{
static const bool value = true;
};
template<typename T2>
T2* AllocatePointerSpace(GenericMsgPayloadSize_t i1, T2* i2){
i2 = (T2*)malloc(i1);
return i2;
}
template<typename T1, typename T2>
T2* AllocatePointerSpace(T1 i1, T2* i2){
i2 = (T2*)malloc(i1);
return i2;
}
template<typename T1, typename T2>
T2 AllocatePointerSpace(T1 i1, T2 i2){
assert(0);
return i2;
}
class Generic_VarSized_Msg{
protected:
GenericMsgPayloadSize_t payloadSize;
uint8_t* payload;
mutable uint8_t* position;
GenericMsgPayloadSize_t byteswritten;
mutable GenericMsgPayloadSize_t bytesread;
public:
Generic_VarSized_Msg (GenericMsgPayloadSize_t _payload_size){
payload = new uint8_t[_payload_size];
position = payload;
payloadSize = _payload_size;
byteswritten = 0;
bytesread = 0;
//size = payload_size + CAL_HEADER_SIZE;
};
Generic_VarSized_Msg(GenericMsgPayloadSize_t _payload_size, uint8_t* _payload){
payloadSize = _payload_size;
payload = _payload;
position = 0;
byteswritten = _payload_size;
bytesread = 0;
};
~Generic_VarSized_Msg () {
if (DBG_GEN_MSG) {
std::cout << " Destructing ~Generic_VarSized_Msg " << " payloadSize = " << payloadSize;
}
delete[] payload;
};
void RewindPosition(){
position = payload;
}
inline uint8_t* GetPayload() const{
return payload;
}
inline GenericMsgPayloadSize_t GetPayloadSize() const{
return payloadSize;
}
inline GenericMsgPayloadSize_t GetBytesRead() const{
return bytesread;
}
template<typename T>
inline void WriteToPayload (const T& data){
GenericMsgPayloadSize_t bytes2bewritten = sizeof(T);
if (DBG_GEN_MSG) {
std::cout << "WriteToPayload1 entered " << '\n';
}
if (DBG_GEN_MSG) {
std::cout << " byteswrittenbefore = " << byteswritten << " bytes2bewritten = " << bytes2bewritten << " payloadSize = " << payloadSize;
}
if (position == NULL) position = GetPayload();
assert ( payload != NULL);
assert ( position >= payload);
assert ( position <= payload + payloadSize);
assert ( position + bytes2bewritten <= payload + payloadSize);
std::size_t bytes2bewritten2 = bytes2bewritten;
memcpy( position , &data, bytes2bewritten2);
position = position + bytes2bewritten;
byteswritten += bytes2bewritten;
if (DBG_GEN_MSG) {
std::cout << " byteswrittenafter = " << byteswritten<< " ";
}
if (DBG_GEN_MSG) {
std::cout << '\n';
}
}
template<typename T1, typename T2>
inline void WriteToPayload (GenericMsgPayloadSize_t i1, T2 i2){
if(!std::is_pointer<T2>::value){
if (DBG_GEN_MSG) {
std::cout << "WriteToPayload4 entered " << '\n';
}
assert(0);
}
else{
if (DBG_GEN_MSG) {
std::cout << "WriteToPayload3 entered " << '\n';
}
if (DBG_GEN_MSG) {
std::cout << " byteswrittenbefore = " << byteswritten << " bytes2bewritten = " << i1 << " payloadSize = " << payloadSize;
}
if (position == NULL) position = GetPayload();
assert ( payload != NULL);
assert ( i2 != NULL);
assert ( position >= payload);
assert ( position <= payload + payloadSize);
assert ( position + i1 <= payload + payloadSize);
std::size_t bytes2bewritten2 = i1;
memcpy( (void*)position , (const void*)i2, bytes2bewritten2);
byteswritten += i1;
position = position + i1;
if (DBG_GEN_MSG) {
std::cout << " byteswrittenafter = " << byteswritten << " ";
}
if (DBG_GEN_MSG) {
std::cout << '\n';
}
}
}
template<typename T1, typename T2>
inline void WriteToPayload (T1 i1, T2 i2){
if (DBG_GEN_MSG) {
std::cout << "WriteToPayload2 entered " << '\n';
}
assert(0);
}
template<typename T>
inline void ReadFromPayload (T& data) const{
GenericMsgPayloadSize_t bytes2beread = sizeof(T);
if (DBG_GEN_MSG) {
std::cout << "ReadFromPayload1 entered " << '\n';
}
if (DBG_GEN_MSG) {
std::cout << " bytesreadbefore = " << bytesread << " bytes2beread = " << bytes2beread << " payloadSize = " << payloadSize << "\n";
}
if (position == NULL) {
position = GetPayload();
}
assert ( payload != NULL);
assert ( position >= payload);
assert ( position <= payload + payloadSize);
assert ( position + bytes2beread <= payload + payloadSize);
std::size_t bytes2beread2 = bytes2beread;
// void* dataread = malloc(bytes2beread2);
// memcpy(dataread, position, bytes2beread2);
// data = *((T*)dataread);
memcpy( &data, position, bytes2beread2);
position = position + bytes2beread;
bytesread += bytes2beread;
if (DBG_GEN_MSG) {
std::cout << " bytesreadafter = " << bytesread<< " ";
}
if (DBG_GEN_MSG) {
std::cout << '\n';
}
}
template<typename T1, typename T2>
inline void ReadFromPayload (GenericMsgPayloadSize_t i1, T2& i2) const{
if(!std::is_pointer<T2>::value){
if (DBG_GEN_MSG) {
std::cout << "ReadFromPayload3 entered " << '\n';
}
assert(0);
}
else{
if (DBG_GEN_MSG) {
std::cout << "ReadFromPayload3 entered " << '\n';
}
if (DBG_GEN_MSG) {
std::cout << " bytesreadbefore = " << bytesread << " bytes2bewread = " << i1 << " payloadSize = " << payloadSize;
}
if (DBG_GEN_MSG) {
std::cout << "ReadFromPayload3 entered " << '\n';
}
if (i2 == NULL) {
//i2 = new T2[i1];
//i2 = (T2)malloc(i1);
i2 = AllocatePointerSpace(i1, i2);
}
assert ( payload != NULL);
assert ( i2 != NULL);
assert ( position >= payload);
assert ( position <= payload + payloadSize);
assert ( position + i1 <= payload + payloadSize);
std::size_t bytes2beread2 = i1;
memcpy( (void*)i2, (const void*)position, bytes2beread2);
bytesread += i1;
position = position + i1;
if (DBG_GEN_MSG) {
std::cout << " bytesreadafter = " << bytesread << " ";
}
if (DBG_GEN_MSG) {
std::cout << '\n';
}
}
}
template<typename T1, typename T2>
inline void ReadFromPayload (T1 i1, T2 i2) const{
if (DBG_GEN_MSG) {
std::cout << "ReadFromPayload2 entered " << '\n';
}
assert(0);
}
inline void CopyToPayload (void* _payload) {
memcpy( payload, _payload, payloadSize);
byteswritten = payloadSize;
}
};
// BK: This is a work in progress for Serializer. It mainly works but needs :
// Changing the size and the pointer order
// Careful implementation of deserializer
template<typename T1,typename T2, typename... TNs>
class GenericSerializer{
public:
Generic_VarSized_Msg* msg;
GenericMsgPayloadSize_t payloadSize;
template<typename C1, typename C2>
void Add2PayloadSize(const C1 av){
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize2 entered ";
}
if(TypeIsInt< C1 >::value){
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize2 "<< " is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
//payloadSize += av;
}
else{
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize2 cannot process because type is not integer"<<" is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
}
};
template<typename C1, typename C2>
void Add2PayloadSize(GenericMsgPayloadSize_t av){
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize3 entered ";
}
if(TypeIsInt< C1 >::value){
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize3 "<< " is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
payloadSize += av;
//if (DBG_GEN_MSG) {
std::cout << "av = "<< av <<" sizeof(C2) = " << sizeof(C2) << " total = "<< av * sizeof(C2) <<" payloadSize = " << payloadSize <<'\n';
}
else{
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize3 cannot process because type is not integer"<<" is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
}
};
template<typename C1>
void Add2PayloadSize(GenericMsgPayloadSize_t av){
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize1 entered ";
}
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize1 "<< " is type integer = " << TypeIsInt< GenericMsgPayloadSize_t >::value << " is pointer=" <<std::is_pointer<GenericMsgPayloadSize_t>::value << '\n';
}
payloadSize += av ;
};
template<typename C1>
void CalculateSize(const C1& i1){
if (DBG_GEN_MSG) {
std::cout << "CalculateSize with 1 input entered ";
}
if(!std::is_pointer<C1>::value){
if (DBG_GEN_MSG) {
std::cout << "CalculateSize processing non-ptr "<< " is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
}
GenericMsgPayloadSize_t a = (GenericMsgPayloadSize_t)sizeof(C1);
Add2PayloadSize<GenericMsgPayloadSize_t>(a);
}
template<typename C1, typename C2>
void CalculateSize(const C1& i1, const C2& i2){
if (DBG_GEN_MSG) {
std::cout << "CalculateSize with 2 input entered ";
}
if(!std::is_pointer<C2>::value) {
CalculateSize<C2>(i2);
}
else {
assert(!std::is_pointer<C1>::value);
if (DBG_GEN_MSG) {
std::cout << "CalculateSize processing pointer "<< "is type integer = " << TypeIsInt< C1 >::value<< " is pointer=" <<std::is_pointer<C2>::value << '\n';
}
Add2PayloadSize<C1,C2>(i1);
}
}
template<typename C1, typename C2,typename C3, typename... CNs>
void CalculateSize(const C1& i1, const C2& i2, const C3& i3, const CNs&... ins){
if (DBG_GEN_MSG) {
std::cout << "CalculateSize with 3 input entered ";
}
if(!std::is_pointer<C2>::value) {
CalculateSize<C2>(i2);
}
else {
assert(!std::is_pointer<C1>::value);
if (DBG_GEN_MSG) {
std::cout << "CalculateSize processing pointer "<< "is type integer = " << TypeIsInt< C1 >::value<< " is pointer=" <<std::is_pointer<C2>::value << '\n';
}
Add2PayloadSize<C1,C2>(i1);
}
CalculateSize<C2, C3, CNs...>(i2, i3, ins...);
}
template<typename C1>
void AddVariable(const C1& i1){
if (DBG_GEN_MSG) {
std::cout << "AddVariable with 1 input entered "<< " sizeof(C1)= "<<sizeof(C1) << " ";
}
if(!std::is_pointer<C1>::value){
if (DBG_GEN_MSG) {
std::cout << "AddVariable with 1 input "<< " is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
msg->WriteToPayload<C1>(i1);
}
}
template<typename C1, typename C2>
void AddVariable(const C1& i1, const C2& i2){
if (DBG_GEN_MSG) {
std::cout << "AddVariable with 2 input entered "<< " sizeof(C2) "<<sizeof(C2)<< " ";
}
if(!std::is_pointer<C2>::value) AddVariable<C2>(i2);
else {
if (DBG_GEN_MSG) {
std::cout << "AddVariable with 2 input "<< "is type integer = " << TypeIsInt< C2 >::value<< " is pointer=" <<std::is_pointer<C2>::value << '\n';
}
assert(std::is_pointer<C1>::value == 0);
assert(std::is_pointer<C2>::value == 1);
// void *p = static_cast<void*>(i2);
msg->WriteToPayload<C1,C2>(i1, i2);
}
}
template<typename C1, typename C2, typename C3,typename... CNs>
void AddVariable(const C1& i1, const C2& i2, const C3& i3, const CNs&... ins){
if (DBG_GEN_MSG) {
std::cout << "AddVariable with 3+ input entered "<< " sizeof(C2) "<<sizeof(C2)<< " ";
}
if(!std::is_pointer<C2>::value) AddVariable<C2>(i2);
else {
if (DBG_GEN_MSG) {
std::cout << "AddVariable with 3+ input "<< "is type integer = " << TypeIsInt< C2 >::value<< " is pointer=" <<std::is_pointer<C2>::value << " sizeof(C2) "<<sizeof(C2) <<'\n';
}
assert(std::is_pointer<C1>::value == 0);
assert(std::is_pointer<C2>::value == 1);
// void *p = static_cast<void*>(i2);
msg->WriteToPayload<C1,C2>(i1, i2);
}
AddVariable<C2, C3, CNs...>(i2, i3, ins...);
}
GenericSerializer(const T1& i1, const T2& i2, const TNs&... ins){
payloadSize = 0;
this->CalculateSize<T1>(i1);
this->CalculateSize<T1, T2, TNs...>(i1, i2, ins...);
if (DBG_GEN_MSG) {
std::cout << " payloadSize = " << payloadSize <<'\n';
}
if (DBG_GEN_MSG) {
std::cout << "\n\n";
}
msg = new Generic_VarSized_Msg(payloadSize);
this->AddVariable(i1);
this->AddVariable(i1, i2, ins...);
};
/*GenericSerializer(T1& i1){
payloadSize = 0;
this->CalculateSize(i1);
msg = new Generic_VarSized_Msg(payloadSize);
this->AddVariable(i1);
};*/
/*GenericSerializer(){
msg = NULL;
payloadSize = 0;
};*/
Generic_VarSized_Msg* Get_Generic_VarSized_Msg_Ptr(){
return msg;
};
virtual ~GenericSerializer(){
delete msg;
}
};
/*
* GenericDeSerializer:This copies serial_msg contents to the variables. For the case of pointers, it copies contents to the location pointed by the pointer. If the pointer is NULL, then malloc is called to allocate memory,
*/
template<typename T1,typename T2=void*, typename... TNs>
class GenericDeSerializer{
Generic_VarSized_Msg const* msg;
//GenericMsgPayloadSize_t payloadSize;
template<typename C1>
void GetVariable(C1& i1){
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 1 input entered "<< " sizeof(C1)= "<<sizeof(C1) << " ";
}
if(!std::is_pointer<C1>::value){
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 1 input "<< " is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
msg->ReadFromPayload<C1>(i1);
}
}
template<typename C1, typename C2>
void GetVariable(C1& i1, C2& i2){
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 2 input entered "<< " sizeof(C2) "<<sizeof(C2)<< " ";
}
if(!std::is_pointer<C2>::value) GetVariable<C2>(i2);
else {
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 2 input "<< "is type integer = " << TypeIsInt< C2 >::value<< " is pointer=" <<std::is_pointer<C2>::value << '\n';
}
assert(std::is_pointer<C1>::value == 0);
assert(std::is_pointer<C2>::value == 1);
msg->ReadFromPayload<C1,C2>(i1, i2);
}
}
template<typename C1, typename C2, typename C3,typename... CNs>
void GetVariable(C1& i1, C2& i2, C3& i3, CNs&... ins){
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 3+ input entered "<< " sizeof(C2) "<<sizeof(C2)<< " ";
}
if(!std::is_pointer<C2>::value) GetVariable<C2>(i2);
else {
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 3+ input "<< "is type integer = " << TypeIsInt< C2 >::value<< " is pointer=" <<std::is_pointer<C2>::value << " sizeof(C2) "<<sizeof(C2) <<'\n';
}
assert(std::is_pointer<C1>::value == 0);
assert(std::is_pointer<C2>::value == 1);
msg->ReadFromPayload<C1,C2>(i1,i2);
}
GetVariable<C2, C3, CNs...>(i2, i3, ins...);
}
public:
/*
* GenericDeSerializer:This copies serial_msg contents to the variables.
* For the case of pointers, it copies contents to the location pointed by the pointer.
* If the pointer is NULL, then malloc is called to allocate memory and the pointer is changed to point to the new location.
*
*/
GenericDeSerializer(Generic_VarSized_Msg const * const _msg, T1& i1, T2& i2, TNs&... ins){
msg = _msg;
//payloadSize = msg->GetPayloadSize();
this->GetVariable(i1);
this->GetVariable(i1, i2, ins...);
};
GenericDeSerializer(Generic_VarSized_Msg const * const _msg, T1& i1){
msg = _msg;
//payloadSize = msg->GetPayloadSize();
this->GetVariable(i1);
};
};
/*
* GenericDeSerializer:This copies serial_msg contents to the variables. For the case of pointers, it copies contents to the location pointed by the pointer. If the pointer is NULL, then malloc is called to allocate memory,
*/
class SocketDeSerializer{
GenericMsgPayloadSize_t bytesread;
mutable uint32_t num_vars_read;
GenericMsgPayloadSize_t payloadSize;
bool blockingread;
template<typename C1, typename C2>
void Add2PayloadSize(const C1 av){
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize2 entered ";
}
if(TypeIsInt< C1 >::value){
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize2 "<< " is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
//payloadSize += av;
}
else{
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize2 cannot process because type is not integer"<<" is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
}
};
template<typename C1, typename C2>
void Add2PayloadSize(GenericMsgPayloadSize_t av){
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize3 entered ";
}
if(TypeIsInt< C1 >::value){
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize3 "<< " is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
payloadSize += av;
//if (DBG_GEN_MSG) {
std::cout << "av = "<< av <<" sizeof(C2) = " << sizeof(C2) << " total = "<< av * sizeof(C2) <<" payloadSize = " << payloadSize <<'\n';
}
else{
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize3 cannot process because type is not integer"<<" is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
}
};
template<typename C1>
void Add2PayloadSize(GenericMsgPayloadSize_t av){
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize1 entered ";
}
if (DBG_GEN_MSG) {
std::cout << "Add2PayloadSize1 "<< " is type integer = " << TypeIsInt< GenericMsgPayloadSize_t >::value << " is pointer=" <<std::is_pointer<GenericMsgPayloadSize_t>::value << '\n';
}
payloadSize += av ;
};
template<typename C1>
void CalculateSize(const C1& i1){
if (DBG_GEN_MSG) {
std::cout << "CalculateSize with 1 input entered ";
}
if(!std::is_pointer<C1>::value){
if (DBG_GEN_MSG) {
std::cout << "CalculateSize processing non-ptr "<< " is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
}
GenericMsgPayloadSize_t a = (GenericMsgPayloadSize_t)sizeof(C1);
Add2PayloadSize<GenericMsgPayloadSize_t>(a);
}
template<typename C1, typename C2>
void CalculateSize(const C1& i1, const C2& i2){
if (DBG_GEN_MSG) {
std::cout << "CalculateSize with 2 input entered ";
}
if(!std::is_pointer<C2>::value) {
CalculateSize<C2>(i2);
}
else {
assert(!std::is_pointer<C1>::value);
if (DBG_GEN_MSG) {
std::cout << "CalculateSize processing pointer "<< "is type integer = " << TypeIsInt< C1 >::value<< " is pointer=" <<std::is_pointer<C2>::value << '\n';
}
Add2PayloadSize<C1,C2>(i1);
}
}
template<typename C1, typename C2,typename C3, typename... CNs>
void CalculateSize(const C1& i1, const C2& i2, const C3& i3, const CNs&... ins){
if (DBG_GEN_MSG) {
std::cout << "CalculateSize with 3 input entered ";
}
if(!std::is_pointer<C2>::value) {
CalculateSize<C2>(i2);
}
else {
assert(!std::is_pointer<C1>::value);
if (DBG_GEN_MSG) {
std::cout << "CalculateSize processing pointer "<< "is type integer = " << TypeIsInt< C1 >::value<< " is pointer=" <<std::is_pointer<C2>::value << '\n';
}
Add2PayloadSize<C1,C2>(i1);
}
CalculateSize<C2, C3, CNs...>(i2, i3, ins...);
}
template<typename T>
inline bool ReadFromSocket (T& data) const{
if (DBG_GEN_MSG) {
std::cout << "ReadFromSocket1 entered " << '\n';
}
if(!std::is_pointer<T>::value){
return RecvBytesfromSocket(&data, sizeof(T));
}
else{
return true; // TODO: Think about this case.
}
}
template<typename T2>
inline bool ReadFromSocket (std::size_t i1, T2& i2) const{
if(!std::is_pointer<T2>::value){
if (DBG_GEN_MSG) {
std::cout << "ReadFromSocket2 entered with a no pointer second input " << '\n';
}
assert(0);
return false;
}
else{
if (DBG_GEN_MSG) {
std::cout << "ReadFromSocket2 entered " << '\n';
}
if (i2 == NULL) {
// i2 = (T2)malloc(i1);
i2 = AllocatePointerSpace(i1,i2); //BK: TODO: For some reason this evaluates to the wrong template. //TODO: Look into why
}
if(i2 == NULL){
std::cout << "ReadFromSocket: Allocation unsuccessfull " << '\n';
}
assert ( i2 != NULL);
return RecvBytesfromSocket(i2, i1);
}
}
template<typename T1, typename T2>
inline bool ReadFromSocket (T1 i1, T2 i2) const{
if (DBG_GEN_MSG) {
std::cout << "ReadFromSocket3 entered " << '\n';
}
assert(0);
return false;
}
//GenericMsgPayloadSize_t payloadSize;
template<typename C1>
bool GetVariable(C1& i1){
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 1 input entered "<< " sizeof(C1)= "<<sizeof(C1) << " ";
}
if(!std::is_pointer<C1>::value){
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 1 input "<< " is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
return this->ReadFromSocket<C1>(i1);
}
}
template<typename C1, typename C2>
bool GetVariable(C1& i1, C2& i2){
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 2 input entered "<< " sizeof(C2) "<<sizeof(C2)<< " ";
}
if(!std::is_pointer<C2>::value) {
return this->GetVariable<C2>(i2);
}
else {
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 2 input "<< "is type integer = " << TypeIsInt< C2 >::value<< " is pointer=" <<std::is_pointer<C2>::value << '\n';
}
assert(std::is_pointer<C1>::value == 0);
assert(std::is_pointer<C2>::value == 1);
return this->ReadFromSocket(i1, i2);
}
}
template<typename C1, typename C2, typename C3,typename... CNs>
bool GetVariable(C1& i1, C2& i2, C3& i3, CNs&... ins){
bool cont;
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 3+ input entered "<< " sizeof(C2) "<<sizeof(C2)<< " ";
}
if(!std::is_pointer<C2>::value) {
cont = GetVariable<C2>(i2);
}
else {
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 3+ input "<< "is type integer = " << TypeIsInt< C2 >::value<< " is pointer=" <<std::is_pointer<C2>::value << " sizeof(C2) "<<sizeof(C2) <<'\n';
}
assert(std::is_pointer<C1>::value == 0);
assert(std::is_pointer<C2>::value == 1);
cont = this->ReadFromSocket(i1,i2);
}
if(!cont) return false;
else return GetVariable<C2, C3, CNs...>(i2, i3, ins...);
}
int32_t socketID;
public:
uint32_t GetNumVarsRead(){ return num_vars_read;}
/*
* GenericDeSerializer:This copies serial_msg contents to the variables.
* For the case of pointers, it copies contents to the location pointed by the pointer.
* If the pointer is NULL, then malloc is called to allocate memory and the pointer is changed to point to the new location.
*
*/
template<typename T>
bool RecvBytesfromSocket(T i1, uint32_t size, int flags = 0) const{
return false;
}
template<typename T>
bool RecvBytesfromSocket(T* i1, uint32_t size, int flags = 0) const{
void* buf = (void*)i1;
//First check if the entire data for the variable is available
ssize_t newlyreadbytes = 0;
ssize_t readBytes = 0;
char* tip_of_buffer = (char*) buf;
// int32_t readBytes = recv(socketID,buf, size, MSG_PEEK ); //First check whether the entire data length is available in the socket
while(readBytes < size){
newlyreadbytes = recv(socketID, tip_of_buffer, size, flags );
if(newlyreadbytes == 0) { //Case for closed connections
return false;
}
else if(newlyreadbytes < 0 ) { //Case for unsuccessful reads
if(!blockingread){
return false;
}
}
else{
readBytes += newlyreadbytes;
tip_of_buffer += readBytes;
}
}
char* cbuf = (char*)buf;
printf("-- ");
for (uint i=0; i< size; i++){
printf("%X ", cbuf[i]);
}
printf("--\n "); fflush(stdout);
++num_vars_read;
return true;
}
// SocketDeSerializer( SocketReaderFnc _func){
SocketDeSerializer( const int32_t _socketID, bool _blockingread = true){
socketID = _socketID;
blockingread = _blockingread;
}
template<typename T1,typename T2=void*, typename... TNs>
bool Read(T1& i1, T2& i2, TNs&... ins){
bool rv;
if(!blockingread){
// //First Check whether all data was received
//Calculate total size and check whether that much data is available at the socket
payloadSize = 0;
this->CalculateSize<T1>(i1);
this->CalculateSize<T1, T2, TNs...>(i1, i2, ins...);
// //Perform a dry run
// ioctl(fd,FIONREAD,&bytes_available)
int32_t readBytes = 0;
void* dummy_read = malloc(payloadSize);
readBytes = recv(socketID, dummy_read, payloadSize, MSG_PEEK);
free(dummy_read);
if(readBytes < (int32_t)payloadSize) { //If all variables are not ready to be read
return false;
}
}
rv = false;
num_vars_read = 0;
printf("SocketDeSerializer reading on %d : ", socketID); fflush(stdout);
if(this->GetVariable(i1))
rv = this->GetVariable(i1, i2, ins...);
printf("\nSocketDeSerializer END OF reading on %d : rv = %d ", socketID, rv); fflush(stdout);
return rv;
};
template<typename T1>
bool Read(T1& i1){
bool rv = false;
printf("SocketDeSerializer reading on %d : ", socketID); fflush(stdout);
rv = this->GetVariable(i1);
printf("\nSocketDeSerializer END OF reading on %d : rv = %d ", socketID, rv); fflush(stdout);
return rv;
};
template<typename C1>
bool Peek(C1& i1){
if(!std::is_pointer<C1>::value){
if (DBG_GEN_MSG) {
std::cout << "GetVariable with 1 input "<< " is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
return RecvBytesfromSocket(&i1, sizeof(C1), MSG_PEEK );
}
return false;
};
};
/*
* SocketSerializer: This module writes the contents of the variables one by one to a socket */
// BK: This is a work in progress for Serializer. It mainly works but needs :
// Changing the size and the pointer order
// Careful implementation of deserializer
class SocketSerializer{
template<typename T>
inline bool WriteToSocket (const T& data, bool isMoreVars){
if (DBG_GEN_MSG) {
std::cout << "WriteToSocket1 entered " << '\n';
}
return WriteBytesToSocket(&data, sizeof(T), isMoreVars);
}
template< typename T2>
inline bool WriteToSocket (std::size_t i1, T2* i2, bool isMoreVars){
if (DBG_GEN_MSG) {
std::cout << "WriteToSocket2 entered " << '\n';
}
assert ( i2 != NULL);
return WriteBytesToSocket(i2, i1, isMoreVars);
}
template<typename T1, typename T2>
inline bool WriteToSocket (T1 i1, T2 i2, bool isMoreVars){
if (DBG_GEN_MSG) {
std::cout << "WriteToSocket3 entered " << '\n';
}
assert(0);
}
template<typename C1>
bool AddVariable(const C1& i1, bool isMoreVars = false){
if (DBG_GEN_MSG) {
std::cout << "AddVariable with 1 input entered "<< " sizeof(C1)= "<<sizeof(C1) << " ";
}
if(!std::is_pointer<C1>::value){
if (DBG_GEN_MSG) {
std::cout << "AddVariable with 1 input "<< " is type integer = " << TypeIsInt< C1 >::value << " is pointer=" <<std::is_pointer<C1>::value << '\n';
}
return WriteToSocket<C1>(i1,isMoreVars);
}
return false;
}
template<typename C1, typename C2>
bool AddVariable(const C1& i1, const C2& i2){
if (DBG_GEN_MSG) {
std::cout << "AddVariable with 2 input entered "<< " sizeof(C2) "<<sizeof(C2)<< " ";
}
if(!std::is_pointer<C2>::value) {
return AddVariable<C2>(i2);
}
else {
if (DBG_GEN_MSG) {
std::cout << "AddVariable with 2 input "<< "is type integer = " << TypeIsInt< C2 >::value<< " is pointer=" <<std::is_pointer<C2>::value << '\n';
}
assert(std::is_pointer<C1>::value == 0);
assert(std::is_pointer<C2>::value == 1);
// void *p = static_cast<void*>(i2);
return WriteToSocket(i1, i2, false);
}
}
template<typename C1, typename C2, typename C3,typename... CNs>
bool AddVariable(const C1& i1, const C2& i2, const C3& i3, const CNs&... ins){
bool cont;
if (DBG_GEN_MSG) {
std::cout << "AddVariable with 3+ input entered "<< " sizeof(C2) "<<sizeof(C2)<< " ";
}
if(!std::is_pointer<C2>::value) {
cont = AddVariable<C2>(i2);
}
else {
if (DBG_GEN_MSG) {
std::cout << "AddVariable with 3+ input "<< "is type integer = " << TypeIsInt< C2 >::value<< " is pointer=" <<std::is_pointer<C2>::value << " sizeof(C2) "<<sizeof(C2) <<'\n';
}
assert(std::is_pointer<C1>::value == 0);
assert(std::is_pointer<C2>::value == 1);
// void *p = static_cast<void*>(i2);
cont = WriteToSocket(i1, i2, true);
}
if(!cont) return false;
else return AddVariable<C2, C3, CNs...>(i2, i3, ins...);
}
int32_t socketID;
bool WriteBytesToSocket(const void * buf, const uint32_t size, bool isMoreVars = true) const{
//size_t readBytes = write((int)socketID, buf, (size_t)size);
size_t sentBytes;
if(isMoreVars){
sentBytes = send((int)socketID, buf, (size_t)size, MSG_MORE);
}
else{
sentBytes = send((int)socketID, buf, (size_t)size, 0);
}
char* cbuf = (char*)buf;
printf("-- ");
for (uint i=0; i< size; i++){
printf("%X ", cbuf[i]);
}
printf("--\n "); fflush(stdout);
return sentBytes>0;
}
public:
SocketSerializer( int32_t _socketID){
socketID = _socketID;
}
template<typename T1,typename T2=void*, typename... TNs>
bool Write(const T1& i1, const T2& i2, const TNs&... ins){
bool rv = false;
printf("SocketSerializer writing on %d : ", socketID); fflush(stdout);
if(this->AddVariable(i1, true))
rv = this->AddVariable(i1, i2, ins...);
printf("\n SocketSerializer END OF writing on %d : rv = %d ", socketID, rv); fflush(stdout);
return rv;
};
template<typename T1>
bool Write(T1& i1){
bool rv = false;
printf("SocketSerializer writing on %d : ", socketID); fflush(stdout);
rv = this->AddVariable(i1);
printf("\n SocketSerializer END OF writing on %d : rv = %d", socketID, rv); fflush(stdout);
return rv;
};
};
#endif // GENERIC_MESSAGE_H
| [
"bora.karaoglu@samraksh.com"
] | bora.karaoglu@samraksh.com |
b65470450e5d245292b8f6429f7efe601d6aa80a | 883ab57c7fc417e89d2c1dc977f29d0d7c4c94fa | /SDL_Collide.cpp | 45be1039589308c358bb176946327d999784c8c0 | [] | no_license | charnet3d/ENSAS-Fighter | 40a2e92c2591cc8475c3920edcbd0b0f84f6d390 | a15a821035342b2691b2d3d956bd6d8625011897 | refs/heads/master | 2020-05-25T17:26:28.820200 | 2016-07-11T13:47:55 | 2016-07-11T13:47:55 | 17,574,562 | 1 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 7,337 | cpp | /*
SDL_Collide: A 2D collision detection library for use with SDL
MIT License
Copyright 2005-2006 SDL_collide Team
http://sdl-collide.sourceforge.net
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Amir Taaki
genjix@gmail.com
Rob Loach
http://robloach.net
*/
#include "SDL_collide.h"
/*if this header is not supported on your system comment out
the assert function call in SDL_TransparentPixel*/
#include "assert.h"
/*returns maximum or minimum of number*/
#define SDL_COLLIDE_MAX(a,b) ((a > b) ? a : b)
#define SDL_COLLIDE_MIN(a,b) ((a < b) ? a : b)
/*
SDL surface test if offset (u,v) is a transparent pixel
*/
int SDL_CollideTransparentPixel(SDL_Surface *surface , int u , int v)
{
if(SDL_MUSTLOCK(surface))
SDL_LockSurface(surface);
/*assert that (u,v) offsets lie within surface*/
assert((u < surface->w) && (v < surface->h));
int bpp = surface->format->BytesPerPixel;
/*here p is the address to the pixel we want to retrieve*/
Uint8 *p = (Uint8 *)surface->pixels + v * surface->pitch + u * bpp;
Uint32 pixelcolor;
bool ret = false;
switch(bpp)
{
case(1):
pixelcolor = *p;
ret = (pixelcolor == surface->format->colorkey);
break;
case(2):
pixelcolor = *(Uint16 *)p;
ret = (pixelcolor == surface->format->colorkey);
break;
case(3):
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
pixelcolor = p[0] << 16 | p[1] << 8 | p[2];
else
pixelcolor = p[0] | p[1] << 8 | p[2] << 16;
ret = (pixelcolor == surface->format->colorkey);
break;
case(4):
pixelcolor = *(Uint32 *)p;
// ce dernier cas gère la transparence quelque soit son type
// soit par ColorKey ou bien par pixel (dernier octet de chaque pixel qui représente la valeur Alpha)
ret = (surface->format->colorkey >> 24 == 255)?(pixelcolor == surface->format->colorkey):(pixelcolor >> 24 == 0);
break;
}
if(SDL_MUSTLOCK(surface))
SDL_UnlockSurface(surface);
return ret;
}
/*
SDL pixel perfect collision test
*/
int SDL_CollidePixel(SDL_Surface *as , int ax , int ay ,
SDL_Surface *bs , int bx , int by, int skip)
{
/*a - bottom right co-ordinates in world space*/
int ax1 = ax + as->w - 1;
int ay1 = ay + as->h - 1;
/*b - bottom right co-ordinates in world space*/
int bx1 = bx + bs->w - 1;
int by1 = by + bs->h - 1;
/*check if bounding boxes intersect*/
if (bx1 < ax) return 0;
if (ax1 < bx) return 0;
if (by1 < ay) return 0;
if (ay1 < by) return 0;
/*Now lets make the bouding box for which we check for a pixel collision*/
/*To get the bounding box we do
Ax1,Ay1______________
| |
| |
| |
| Bx1,By1____________
| | | |
| | | |
|________|_______| |
| Ax2,Ay2 |
| |
| |
|___________Bx2,By2
To find that overlap we find the biggest left hand cordinate
AND the smallest right hand co-ordinate
To find it for y we do the biggest top y value
AND the smallest bottom y value
Therefore the overlap here is Bx1,By1 --> Ax2,Ay2
Remember Ax2 = Ax1 + SA->w
Bx2 = Bx1 + SB->w
Ay2 = Ay1 + SA->h
By2 = By1 + SB->h
*/
/*now we loop round every pixel in area of
intersection
if 2 pixels alpha values on 2 surfaces at the
same place != 0 then we have a collision*/
int xstart = SDL_COLLIDE_MAX(ax,bx);
int xend = SDL_COLLIDE_MIN(ax1,bx1);
int ystart = SDL_COLLIDE_MAX(ay,by);
int yend = SDL_COLLIDE_MIN(ay1,by1);
for(int y = ystart ; y <= yend ; y += skip)
{
for(int x = xstart ; x <= xend ; x += skip)
{
/*compute offsets for surface
before pass to TransparentPixel test*/
if(!SDL_CollideTransparentPixel(as , x-ax , y-ay)
&& !SDL_CollideTransparentPixel(bs , x-bx , y-by))
return 1;
}
}
return 0;
}
/*
SDL bounding box collision test
*/
int SDL_CollideBoundingBox(SDL_Surface *sa , int ax , int ay ,
SDL_Surface *sb , int bx , int by)
{
if(bx + sb->w < ax) return 0; //just checking if their
if(bx > ax + sa->w) return 0; //bounding boxes even touch
if(by + sb->h < ay) return 0;
if(by > ay + sa->h) return 0;
return 1; //bounding boxes intersect
}
/*
SDL bounding box collision tests (works on SDL_Rect's)
*/
int SDL_CollideBoundingBox(SDL_Rect a , SDL_Rect b)
{
if(b.x + b.w < a.x) return 0; //just checking if their
if(b.x > a.x + a.w) return 0; //bounding boxes even touch
if(b.y + b.h < a.y) return 0;
if(b.y > a.y + a.h) return 0;
return 1; //bounding boxes intersect
}
/*
tests whether 2 circles intersect
circle1 : centre (x1,y1) with radius r1
circle2 : centre (x2,y2) with radius r2
(allow distance between circles of offset)
*/
int SDL_CollideBoundingCircle(int x1 , int y1 , int r1 ,
int x2 , int y2 , int r2 , int offset)
{
int xdiff = x2 - x1; // x plane difference
int ydiff = y2 - y1; // y plane difference
/* distance between the circles centres squared */
int dcentre_sq = (ydiff*ydiff) + (xdiff*xdiff);
/* calculate sum of radiuses squared */
int r_sum_sq = r1 + r2; // square on seperate line, so
r_sum_sq *= r_sum_sq; // dont recompute r1 + r2
return (dcentre_sq - r_sum_sq <= (offset*offset));
}
/*
a circle intersection detection algorithm that will use
the position of the centre of the surface as the centre of
the circle and approximate the radius using the width and height
of the surface (for example a rect of 4x6 would have r = 2.5).
*/
int SDL_CollideBoundingCircle(SDL_Surface *a , int x1 , int y1 ,
SDL_Surface *b , int x2 , int y2 ,
int offset)
{
/* if radius is not specified
we approximate them using SDL_Surface's
width and height average and divide by 2*/
int r1 = (a->w + a->h) / 4; // same as / 2) / 2;
int r2 = (b->w + b->h) / 4;
x1 += a->w / 2; // offset x and y
y1 += a->h / 2; // co-ordinates into
// centre of image
x2 += b->w / 2;
y2 += b->h / 2;
return SDL_CollideBoundingCircle(x1,y1,r1,x2,y2,r2,offset);
}
| [
"charnet3d@gmail.com"
] | charnet3d@gmail.com |
21621a2c40d3247a7113e160e07398aa87c05bc4 | 04a540847c1333c987a1957fd8d31197c594f6bb | /BOJ/10820_1.cpp | c95880ed96998b8a5f0e263129f322f1db6c976b | [] | no_license | k8440009/Algorithm | fd148269b264b580876c7426e19dbe2425ddc1ab | a48eba0ac5c9f2e10f3c509ce9d349c8a1dc3f0c | refs/heads/master | 2023-04-02T16:06:10.260768 | 2023-04-02T11:04:32 | 2023-04-02T11:04:32 | 200,506,643 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 343 | cpp | char *read_line(int fd)
{
char *buf;
char c;
int i;
int n_read;
buf = malloc(sizeof(char) * 50000);
if (buf == NULL)
return (NULL);
n_read = 0;
i = 0;
while (read(fd, &c, 1) > 0)
{
n_read++;
if (c == '\n')
break;
buf[i] = c;
i++;
}
if (n_read == 0)
{
free(buf);
return (NULL);
}
buf[i] = '\0';
return (buf);
} | [
"k8440009@gmail.com"
] | k8440009@gmail.com |
a03209ebd3d61dbb54d765943a79af3e3b1106e8 | aacc7ecfb6a23aa5a13e7cd872d2c2ea3053858d | /Two Pointers/Remove Duplicates from Sorted Array.cpp | 19a33c6e597973ead5184808f2df35606ecd006b | [] | no_license | pranayagr/InterviewBit | 4dd7a300ced59920904dc2dedb9f1035a7201705 | 4031abac73dc56ee5f4b53ed797353d34d9362bd | refs/heads/main | 2023-05-13T01:11:14.979359 | 2021-06-04T18:26:23 | 2021-06-04T18:26:23 | 326,433,528 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 400 | cpp | int Solution::removeDuplicates(vector<int> &A) {
int n = A.size(), unq_num = 1;
if(n == 1) return 1;
for(int i = 1 ; i < n ; i++){
if(A[i] != A[i-1]){
unq_num++;
}
}
int r = 1, w = 1;
while(r < n && w < n){
if(A[r] != A[r-1]){
A[w] = A[r];
w++;
}
r++;
}
return unq_num;
}
| [
"noreply@github.com"
] | pranayagr.noreply@github.com |
b0180da56ae854842636698337e51c8a929ac0ef | 9231ec805e1238984b2209cf6952a85af84d678d | /bcos-tool/test/unittests/libtool/VersionConvert.cpp | 846fb0bd834de1340bb1d9b56814b086d509fb54 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | ywy2090/FISCO-BCOS | 775c359866bbadd59dbe651e3f1341dd127deb9f | f24d5b9a1abb3d224962877abd4c92e411e4de45 | refs/heads/master | 2023-07-26T17:17:55.173858 | 2023-04-04T04:52:03 | 2023-04-04T04:52:03 | 154,145,600 | 2 | 0 | Apache-2.0 | 2022-10-08T03:16:02 | 2018-10-22T13:06:41 | C++ | UTF-8 | C++ | false | false | 640 | cpp |
#include <bcos-tool/VersionConverter.h>
#include <bcos-utilities/Common.h>
#include <boost/test/tools/old/interface.hpp>
#include <boost/test/unit_test.hpp>
using namespace bcos;
using namespace bcos::tool;
namespace bcos
{
namespace test
{
BOOST_AUTO_TEST_CASE(testVersionConvert)
{
BOOST_CHECK_EQUAL(toVersionNumber("3.2.3"), 0x03020300);
BOOST_CHECK_EQUAL(toVersionNumber("3.2"), 0x03020000);
BOOST_CHECK_THROW(toVersionNumber("1"), InvalidVersion);
BOOST_CHECK_THROW(toVersionNumber("2.1"), InvalidVersion);
BOOST_CHECK_THROW(toVersionNumber("256.1"), InvalidVersion);
}
} // namespace test
} // namespace bcos | [
"noreply@github.com"
] | ywy2090.noreply@github.com |
027308f40a33b54f90ce02f5b4b52f31947fe63b | 101b45e1f7054ff20dccbf0fb3128edb68880780 | /legacy/qmmp_ui_example/renamedialog.cpp | 5ab6b4bf3beb56f38f6cdeac1cffef97a50d7fbc | [] | no_license | calupator/QMMP | 2803c0d2c07c13f6804456aa4058b3e17b8cba52 | b56617e0f1d1d0adabbb14008a3ab3f19d3cb3fc | refs/heads/master | 2023-04-01T09:38:09.317025 | 2021-04-11T20:31:10 | 2021-04-11T20:31:10 | 357,050,154 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 153 | cpp | #include "renamedialog.h"
renameDialog::renameDialog (QWidget *parent)
: QDialog (parent)
{
ui.setupUi (this);
}
renameDialog::~renameDialog()
{
}
| [
"trialuser02@90c681e8-e032-0410-971d-27865f9a5e38"
] | trialuser02@90c681e8-e032-0410-971d-27865f9a5e38 |
c5d886edd807b29962024608b51f71932920c828 | fec81bfe0453c5646e00c5d69874a71c579a103d | /blazetest/src/mathtest/operations/smatsmatadd/HCbUCa.cpp | 394e4df4c3740116222cd46beeb59ad59f5c0823 | [
"BSD-3-Clause"
] | permissive | parsa/blaze | 801b0f619a53f8c07454b80d0a665ac0a3cf561d | 6ce2d5d8951e9b367aad87cc55ac835b054b5964 | refs/heads/master | 2022-09-19T15:46:44.108364 | 2022-07-30T04:47:03 | 2022-07-30T04:47:03 | 105,918,096 | 52 | 7 | null | null | null | null | UTF-8 | C++ | false | false | 4,309 | cpp | //=================================================================================================
/*!
// \file src/mathtest/operations/smatsmatadd/HCbUCa.cpp
// \brief Source file for the HCbUCa sparse matrix/sparse matrix addition math test
//
// Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. Redistribution and use in source and binary
// forms, with or without modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
// 3. Neither the names of the Blaze development group nor the names of its contributors
// may be used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
*/
//=================================================================================================
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <cstdlib>
#include <iostream>
#include <blaze/math/CompressedMatrix.h>
#include <blaze/math/HermitianMatrix.h>
#include <blaze/math/UpperMatrix.h>
#include <blazetest/mathtest/Creator.h>
#include <blazetest/mathtest/operations/smatsmatadd/OperationTest.h>
#include <blazetest/system/MathTest.h>
#ifdef BLAZE_USE_HPX_THREADS
# include <hpx/hpx_main.hpp>
#endif
//=================================================================================================
//
// MAIN FUNCTION
//
//=================================================================================================
//*************************************************************************************************
int main()
{
std::cout << " Running 'HCbUCa'..." << std::endl;
using blazetest::mathtest::ScalarA;
using blazetest::mathtest::ScalarB;
try
{
// Matrix type definitions
using HCb = blaze::HermitianMatrix< blaze::CompressedMatrix<ScalarB> >;
using UCa = blaze::UpperMatrix< blaze::CompressedMatrix<ScalarA> >;
// Creator type definitions
using CHCb = blazetest::Creator<HCb>;
using CUCa = blazetest::Creator<UCa>;
// Running tests with small matrices
for( size_t i=0UL; i<=6UL; ++i ) {
for( size_t j=0UL; j<=i*i; ++j ) {
for( size_t k=0UL; k<=UCa::maxNonZeros( i ); ++k ) {
RUN_SMATSMATADD_OPERATION_TEST( CHCb( i, j ), CUCa( i, k ) );
}
}
}
// Running tests with large matrices
RUN_SMATSMATADD_OPERATION_TEST( CHCb( 67UL, 7UL ), CUCa( 67UL, 13UL ) );
RUN_SMATSMATADD_OPERATION_TEST( CHCb( 128UL, 16UL ), CUCa( 128UL, 8UL ) );
}
catch( std::exception& ex ) {
std::cerr << "\n\n ERROR DETECTED during sparse matrix/sparse matrix addition:\n"
<< ex.what() << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
//*************************************************************************************************
| [
"klaus.iglberger@gmail.com"
] | klaus.iglberger@gmail.com |
da54f9ab64de7c21c14936c97daf5ad7e6b9208e | cffab619d884373b83f0b5040409ac9753f4e9ca | /LADA/oj2-dup.cpp | 6b21e34e4a7b4a3869eb5def0cb04d1dd2c8d87c | [
"MIT"
] | permissive | luyiming/CLRS | 15ff9c275f93710f34ca95eff4d0c3e6d537b852 | 84cee023d8f3bb8ff8ac3b417324006001ab1ea6 | refs/heads/master | 2021-01-19T07:43:05.222066 | 2017-05-15T05:01:19 | 2017-05-15T05:01:19 | 87,565,554 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,851 | cpp | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
int totalSize;
int cnt = 0;
const int NodeSize = 1000;
struct Node {
double x, y;
Node(int x, int y) : x(x), y(y) {}
Node() : x(0), y(0) {}
Node(const Node &rhs) {
x = rhs.x;
y = rhs.y;
}
void flip() { swap(x, y); }
};
bool operator<(const Node &lhs, const Node &rhs) { return lhs.x < rhs.x; }
/************** Expect complexity O(n) Selection algorithm **************/
int partition(int *A, int p, int r) {
// use A[r] to partition A[p..r]
int i = p;
for (int j = p; j < r; j++) {
if (A[j] < A[r]) {
swap(A[j], A[i]);
i++;
}
}
swap(A[r], A[i]);
return i;
}
// k starts from 1, Expect O(n)
// return index
int selectRank(int *A, int left, int right, int k) {
if (left > right) {
return -1;
}
int mid = partition(A, left, right);
int leftNum = mid - left + 1;
if (leftNum == k) {
return mid;
} else if (leftNum < k) {
return selectRank(A, mid + 1, right, k - leftNum);
} else {
return selectRank(A, left, mid - 1, k);
}
}
/************** Expect complexity O(n) Selection algorithm **************/
double nodeDistance(Node n1, Node n2) {
return sqrt((n1.x - n2.x) * (n1.x - n2.x) + (n1.y - n2.y) * (n1.y - n2.y));
}
double findMinDistance(Node *Nodes, int low, int high) {
/*
if (CNodes != Nodes) {
cout << CNodes << endl;
exit(1);
}
if (low < 0 || low > high) {
cout << "low: " << low << " high: " << high << endl;
exit(1);
}
if (high >= NodeSize) {
cout << "low: " << low << " high: " << high << endl;
exit(1);
}
*/
int nodesSize = high - low + 1;
if (nodesSize <= 1) {
return std::numeric_limits<double>::max();
}
if (nodesSize == 2) {
// assert(low >= 0 && high < NodeSize);
// assert(low <= high);
// assert(high == low + 1);
return nodeDistance(Nodes[low], Nodes[high]);
}
// int *xArray = new int[nodesSize];
// for (int i = 0; i < nodesSize; i++) {
// xArray[i] = Nodes.at(i).x;
//}
// int xMedian = xArray[selectRank(xArray, 0, nodesSize - 1, nodesSize / 2)];
sort(Nodes + low, Nodes + high + 1);
// qsort(Nodes + low, high - low + 1, sizeof(Node), cmp);
// for (int i = low; i <= high; i++) {
// cout << Nodes[i].x << " ";
// }
// cout << endl;
int xMedianIndex = (low + high) / 2;
int xMedian = Nodes[xMedianIndex].x;
// cout << "xmedian: " << xMedian << endl;
if (Nodes[low].x == Nodes[high].x) {
if (Nodes[low].y == Nodes[high].y) {
return 0.0;
}
// flip
for (int i = low; i <= high; i++) {
Nodes[i].flip();
}
double ret = findMinDistance(Nodes, low, high);
for (int i = low; i <= high; i++) {
Nodes[i].flip();
}
return ret;
}
// ensure both parts have nodes
if (xMedianIndex + 1 > high) {
xMedianIndex--;
}
assert(xMedianIndex >= low && xMedianIndex < high);
// cout << "median: " << Nodes[xMedianIndex].x << endl;
double d1 = findMinDistance(Nodes, low, xMedianIndex);
double d2 = findMinDistance(Nodes, xMedianIndex + 1, high);
double d = d1 < d2 ? d1 : d2;
// cout << "d: " << d << endl;
int leftCandidatesIndex = xMedianIndex,
rightCandidatesIndex = xMedianIndex + 1;
while (leftCandidatesIndex >= low) {
if ((double)Nodes[leftCandidatesIndex].x >= (double)xMedian - d) {
leftCandidatesIndex--;
} else {
break;
}
}
leftCandidatesIndex--;
if (leftCandidatesIndex < low) {
leftCandidatesIndex = low;
}
while (rightCandidatesIndex <= high) {
if ((double)Nodes[rightCandidatesIndex].x <= (double)xMedian + d) {
rightCandidatesIndex++;
} else {
break;
}
}
rightCandidatesIndex++;
if (rightCandidatesIndex > high) {
rightCandidatesIndex = high;
}
// cout << "xMedianIndex: " << xMedianIndex << endl;
// cout << "leftCandidatesIndex: " << leftCandidatesIndex << endl;
// cout << "rightCandidatesIndex: " << rightCandidatesIndex << endl;
/*
for (int i = low; i < leftCandidatesIndex; i++) {
if ((double)Nodes[i].x >= (double)xMedian - d) {
cout << "1.d: " << d << endl;
cout << "xMedian: " << xMedian << endl;
cout << "xMedianIndex: " << xMedianIndex << endl;
cout << "low: " << low << endl;
cout << "high: " << high << endl;
cout << "leftCandidatesIndex: " << leftCandidatesIndex << endl;
cout << "rightCandidatesIndex: " << rightCandidatesIndex << endl;
for (int j = low; j <= high; j++) {
cout << Nodes[j].x << " ";
}
cout << endl;
for (int j = low; j <= high; j++) {
cout << Nodes[j].y << " ";
}
cout << endl;
assert(0);
}
}
for (int i = rightCandidatesIndex + 1; i <= high; i++) {
if ((double)Nodes[i].x <= (double)xMedian + d) {
cout << "2.d: " << d << endl;
cout << "xMedian: " << xMedian << endl;
cout << "xMedianIndex: " << xMedianIndex << endl;
cout << "low: " << low << endl;
cout << "high: " << high << endl;
cout << "leftCandidatesIndex: " << leftCandidatesIndex << endl;
cout << "rightCandidatesIndex: " << rightCandidatesIndex << endl;
for (int j = low; j <= high; j++) {
cout << Nodes[j].x << " ";
}
cout << endl;
for (int j = low; j <= high; j++) {
cout << Nodes[j].y << " ";
}
cout << endl;
assert(0);
}
}
*/
for (int i = leftCandidatesIndex; i <= xMedianIndex; i++) {
for (int j = xMedianIndex + 1; j <= rightCandidatesIndex; j++) {
double currentD = nodeDistance(Nodes[i], Nodes[j]);
if (currentD < d) {
d = currentD;
}
}
}
// delete[] xArray;
return d;
}
double bruteForceMinDistance(Node *Nodes, int n) {
double minDistance = std::numeric_limits<double>::max();
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
double currentD = nodeDistance(Nodes[i], Nodes[j]);
if (currentD < minDistance) {
minDistance = currentD;
}
}
}
return minDistance;
}
int main() {
int x, y;
cin >> totalSize;
Node *Nodes = new Node[totalSize];
for (int i = 0; i < totalSize; i++) {
scanf("%d,%d", &x, &y);
Nodes[i] = Node(x, y);
}
// for (int i = 0; i < n; i++) {
// cout << Nodes[i].x << " " << Nodes[i].y << endl;
// }
cout << "wo yi yue du guan yu chao xi de shuo ming" << endl;
printf("%.6f", findMinDistance(Nodes, 0, totalSize - 1));
delete[] Nodes;
// 3 657994585,941883880 243678075,1353968635 730268714,177645073
// should be 25059.093140, you solve 30714.540872
// should be 2148.444321, you solve 9909.975277
// 10 1653377373,1131176229 1914544919,859484421 756898537,608413784 1973594324,1734575198 2038664370,149798315 184803526,1129566413 1424268980,412776091 749241873,1911759956 42999170,137806862 135497281,982906996
/*
const int TESTNUM = 100;
const double EPSILON = 1.0e-5;
Node *testNodes = new Node[NodeSize];
Node *testNodes2 = new Node[NodeSize];
for (int i = 0; i < TESTNUM; i++) {
for (int j = 0; j < NodeSize; j++) {
testNodes[j] = Node(rand(), rand());
testNodes2[j] = testNodes[j];
}
cnt++;
double d1 = bruteForceMinDistance(testNodes, NodeSize);
double d2 = findMinDistance(testNodes2, 0, NodeSize - 1);
if (fabs(d1 - d2) > EPSILON) {
printf("should be %.6f, you solve %.6f\n", d1, d2);
for (int k = 0; k < NodeSize; k++) {
printf("%d,%d ", testNodes[k].x, testNodes[k].y);
}
printf("\n");
for (int k = 0; k < NodeSize; k++) {
printf("%d,%d ", testNodes2[k].x, testNodes2[k].y);
}
printf("\n");
printf("\n");
return 0;
}
}
*/
return 0;
}
| [
"luyimingchn@gmail.com"
] | luyimingchn@gmail.com |
da0f4ae7d21a7b1da99ac6409e4f4bfc3485385d | d2d0e72fc04f4699595aa1946362e081c63fd69a | /SandBox/src/Parseur.cpp | 84c594c30fe279e0624f69d3a43ebf43a15fb490 | [] | no_license | T4ouf/Rainbow-Engine | f3b8e908dc0bef053efea2ec7c7fbb9a2478a663 | 5b57b9b20c6edecf7da90595e7ef9b13852ff6d5 | refs/heads/master | 2020-05-16T05:55:44.215733 | 2019-05-10T11:46:22 | 2019-05-10T11:46:22 | 182,830,198 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,908 | cpp | #include "Parseur.h"
Parseur::Parseur(std::string pathFile) {
path = pathFile;
// Initiate the structure
lvl.startPosX = 0.0f;
lvl.startPosY = 0.0f;
lvl.startPosZ = 0.0f;
lvl.levelPath = "";
lvl.musicPath = "";
lvl.endPosX = 0.0f;
lvl.endPosY = 0.0f;
lvl.endPosZ = 0.0f;
lvl.length = 0.0f;
lvl.width = 0.0f;
lvl.height = 0.0f;
}
Parseur::~Parseur() {
}
void Parseur::setPath(std::string pathFile) {
path = pathFile;
}
std::string Parseur::getPath() {
return path;
}
Level Parseur::parse(Rainbow::Scene& scene) {
// Clear the structure
lvl.startPosX = 0.0f;
lvl.startPosY = 0.0f;
lvl.startPosZ = 0.0f;
lvl.levelPath = "";
lvl.musicPath = "";
lvl.endPosX = 0.0f;
lvl.endPosY = 0.0f;
lvl.endPosZ = 0.0f;
lvl.length = 0.0f;
lvl.width = 0.0f;
lvl.height = 0.0f;
// ************** Open File ***************//
rapidxml::xml_document<> doc;
rapidxml::xml_node<> * root_node;
std::ifstream theFile(this->path);
// if the file exist and is open
if (theFile) {
// declaration of buffer to read file
std::vector<char> buffer((std::istreambuf_iterator<char>(theFile)), std::istreambuf_iterator<char>());
buffer.push_back('\0');
doc.parse<0>(&buffer[0]);
// first node level
root_node = doc.first_node("Level");
std::string nameLevel = root_node->first_attribute("name")->value();
lvl.levelPath = nameLevel;
// first node Background
rapidxml::xml_node<> * background_node = root_node->first_node("Background");
//*********************** COLOR / MUSIC / LIGHT ******************//
// first node name Color if it exists
rapidxml::xml_node<>* color_node = background_node->first_node("Color");
if (color_node != nullptr) {
std::string::size_type sz;
float r, g, b;
r = std::stof(color_node->first_attribute("red")->value(), &sz);
g = std::stof(color_node->first_attribute("green")->value(), &sz);
b = std::stof(color_node->first_attribute("blue")->value(), &sz);
scene.setBackgroundColor(r/255.0f,g/255.0f,b/255.0f);
}
rapidxml::xml_node<>* music_node = background_node->first_node("Music");
if (music_node != nullptr) {
std::string musicName = music_node->first_attribute("name")->value();
lvl.musicPath = musicName;
}
rapidxml::xml_node<>* light_node = background_node->first_node("Light");
if (light_node != nullptr) {
float posX, posY, posZ;
posX = std::stof(light_node->first_attribute("posX")->value());
posY = std::stof(light_node->first_attribute("posY")->value());
posZ = std::stof(light_node->first_attribute("posZ")->value());
scene.setLightPos(posX/255.0f, posY/255.0f, posZ/255.0f);
}
//*********************** START, END AND OBJECT ******************//
// node structure of Level
rapidxml::xml_node<> * structure_node = root_node->first_node("Structure");
// node start of structure
rapidxml::xml_node<> * start_node = structure_node->first_node("Start");
if (start_node != nullptr) {
float posX = std::stof(start_node->first_attribute("posX")->value());
float posY = std::stof(start_node->first_attribute("posY")->value());
float posZ = std::stof(start_node->first_attribute("posZ")->value());
// Store in structure
lvl.startPosX = posX;
lvl.startPosY = posY;
lvl.startPosZ = posZ;
}
// node end of structure
rapidxml::xml_node<> * end_node = structure_node->first_node("End");
if (end_node != nullptr) {
float posX = std::stof(end_node->first_attribute("posX")->value());
float posY = std::stof(end_node->first_attribute("posY")->value());
float posZ = std::stof(end_node->first_attribute("posZ")->value());
float length = std::stof(end_node->first_attribute("length")->value());
float width = std::stof(end_node->first_attribute("width")->value());
float height = std::stof(end_node->first_attribute("height")->value());
// Store in structure
lvl.endPosX = posX;
lvl.endPosY = posY;
lvl.endPosZ = posZ;
lvl.length = length;
lvl.width = width;
lvl.height = height;
}
rapidxml::xml_node<>* objects_node = structure_node->first_node("Objects");
if (objects_node != nullptr) {
for (rapidxml::xml_node<> * obj_node = objects_node->first_node("Obj");; obj_node = obj_node->next_sibling()) {
if (obj_node != nullptr) {
if (strcmp(obj_node->name(), "Obj") != 0) {
break;
}
// We get attribut object
float posX = std::stof(obj_node->first_attribute("posX")->value());
float posY = std::stof(obj_node->first_attribute("posY")->value());
float posZ = std::stof(obj_node->first_attribute("posZ")->value());
float sizeX = std::stof(obj_node->first_attribute("sizeX")->value());
float sizeY = std::stof(obj_node->first_attribute("sizeY")->value());
float sizeZ = std::stof(obj_node->first_attribute("sizeZ")->value());
float mass = std::stof(obj_node->first_attribute("mass")->value());
bool isAnchor = atoi(obj_node->first_attribute("isAnchor")->value());
std::string nameMaterial = obj_node->first_attribute("material")->value();
Rainbow::Shader * shader = new Rainbow::Shader("Ressources/Shaders/Material.shader");
Rainbow::Material * material;
// we create material according to the name of material in the file
if (nameMaterial == "Gold") {
material = new Rainbow::Material(shader, nullptr,
glm::vec3(0.329412f, 0.223529f, 0.027451f),
glm::vec3(0.780392f, 0.568627f, 0.113725f),
glm::vec3(0.992157f, 0.941176f, 0.807843f), 27.8974f);
}
else if (nameMaterial == "Ruby") {
material = new Rainbow::Material(shader, nullptr,
glm::vec3(0.1745f, 0.01175f, 0.01175f),
glm::vec3(0.61424f, 0.04136f, 0.04136f),
glm::vec3(0.727811f, 0.626959f, 0.626959f), 0.6f * 128);
}
else if (nameMaterial == "Chrome") {
material = new Rainbow::Material(shader, nullptr,
glm::vec3(0.25f, 0.25f, 0.25f),
glm::vec3(0.4f, 0.4f, 0.4f),
glm::vec3(0.774597f, 0.774597f, 0.774597f), 0.6f * 128);
}
else if (nameMaterial == "Pearl") {
material = new Rainbow::Material(shader, nullptr,
glm::vec3(0.25f, 0.20725f, 0.20725f),
glm::vec3(1.0f, 0.829f, 0.829f),
glm::vec3(0.296648f, 0.296648f, 0.296648f), 0.088f * 128);
}
else if (nameMaterial == "Copper") {
material = new Rainbow::Material(shader, nullptr,
glm::vec3(0.19125f, 0.0735f, 0.0225f),
glm::vec3(0.7038f, 0.27048f, 0.0828f),
glm::vec3(0.256777f, 0.137622f, 0.086014f), 0.1f * 128);
}
else if (nameMaterial == "Obsidian") {
material = new Rainbow::Material(shader, nullptr,
glm::vec3(0.05375f, 0.05f, 0.06625f),
glm::vec3(0.18275f, 0.17f, 0.22525f),
glm::vec3(0.332741f, 0.328634f, 0.346435f), 0.3f * 128);
}
else if (nameMaterial == "BlackRubber") {
material = new Rainbow::Material(shader, nullptr,
glm::vec3(0.02f, 0.02f, 0.02f),
glm::vec3(0.01f, 0.01f, 0.01f),
glm::vec3(0.4f, 0.4f, 0.4f), 10.0f);
}
else if (nameMaterial == "LampMaterial") {
material = new Rainbow::Material(Rainbow::LightSourceShader, "Ressources/Textures/texture-caisse.png",
glm::vec3(1.0f, 1.0f, 1.0f),
glm::vec3(1.0f, 1.0f, 1.0f),
glm::vec3(1.0f, 1.0f, 1.0f), 1.0f);
}
else {
nameMaterial = "No";
material = new Rainbow::Material(shader, nullptr,
glm::vec3(1.0f, 1.0f, 1.0f),
glm::vec3(1.0f, 1.0f, 1.0f),
glm::vec3(1.0f, 1.0f, 1.0f), 1.0f);
}
//add object at the scene
Rainbow::Object *b = Rainbow::ObjectFactory::CreateBoxe(glm::vec3(posX, posY, posZ), sizeX, sizeY, sizeZ, mass, isAnchor, material);
scene.addObject(b);
if (obj_node->next_sibling() == nullptr) {
break;
}
}
}
}
doc.clear();
}
else {
// There is an error with file
std::cerr << "Impossible to open file !" << std::endl;
}
return lvl;
}
| [
"thomasvonascheberg@hotmail.fr"
] | thomasvonascheberg@hotmail.fr |
a2b6d554c5edb61851bbc085244ebacb17007a57 | 9e37bb8dc004cc39f39aae340b5ca5e3223bbde0 | /174-15653.cpp | 425151891a832de5ac13ccaab284c2b31c476c5e | [] | no_license | yongsoonko/solved-problems | 5868823edfa2a5451b23b06e06ee7855b7073182 | 55dd3e0a1e40581f48a46b4ed78455d04de41ffc | refs/heads/master | 2022-11-19T15:23:39.938416 | 2020-04-07T03:37:15 | 2020-04-07T03:37:15 | 221,386,455 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,148 | cpp | #include <algorithm>
#include <array>
#include <iostream>
#include <queue>
#include <string>
#include <time.h>
#include <vector>
#define fi first
#define se second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using ai3 = array<int, 3>;
struct Ball {
int i;
int j;
int k;
Ball operator+(const Ball &other) {
return Ball{i + other.i, j + other.j, k};
}
};
int N, M;
int di[4] = {-1, 0, 1, 0}, dj[4] = {0, 1, 0, -1};
string map[11];
int chk[10000];
int chk_fall[2];
Ball move_ball(Ball b, int d) {
Ball res = {0, 0};
while (map[b.i + di[d]][b.j + dj[d]] == '.') {
b.i += di[d], b.j += dj[d];
res.i += di[d], res.j += dj[d];
}
if (map[b.i + di[d]][b.j + dj[d]] == 'O') {
b.i += di[d], b.j += dj[d];
res.i += di[d], res.j += dj[d];
chk_fall[b.k] = 1;
}
return res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
clock_t start = clock();
int tc = 1;
while (tc--) {
fill(chk_fall, chk_fall + 2, 0);
fill(chk, chk + 10000, 0);
Ball cr, cb;
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> map[i];
for (int j = 0; j < M; j++) {
if (map[i][j] == 'R') {
cr.i = i, cr.j = j, cr.k = 0;
map[i][j] = '.';
} else if (map[i][j] == 'B') {
cb.i = i, cb.j = j, cb.k = 1;
map[i][j] = '.';
}
}
}
int curr = cr.i * 1000 + cr.j * 100 + cb.i * 10 + cb.j;
chk[curr] = 1;
queue<int> q;
q.push(curr);
int prev_lv = 1, next_lv = 0, cnt = 1, flag = 0;
while (!q.empty()) {
curr = q.front();
q.pop();
prev_lv--;
cr = {curr / 1000, curr % 1000 / 100, 0}, cb = {curr % 100 / 10, curr % 10, 1};
for (int i = 0; i < 4; i++) {
Ball mr = move_ball(cr, i);
Ball mb = move_ball(cb, i);
Ball nr = cr + mr, nb = cb + mb;
if (chk_fall[0] && !chk_fall[1]) {
flag = 1;
goto out;
} else if (chk_fall[1]) {
chk_fall[0] = chk_fall[1] = 0;
continue;
} else {
if (nr.i == nb.i && nr.j == nb.j) {
if (i == 0) {
if (cr.i < cb.i)
nb.i++;
else
nr.i++;
} else if (i == 1) {
if (cr.j < cb.j)
nr.j--;
else
nb.j--;
} else if (i == 2) {
if (cr.i < cb.i)
nr.i--;
else
nb.i--;
} else {
if (cr.j < cb.j)
nb.j++;
else
nr.j++;
}
}
}
int next = nr.i * 1000 + nr.j * 100 + nb.i * 10 + nb.j;
if (!chk[next]) {
chk[next] = 1;
q.push(next);
next_lv++;
}
}
if (!prev_lv) {
prev_lv = next_lv;
next_lv = 0;
cnt++;
}
}
out:
if (flag)
cout << cnt << '\n';
else
cout << -1 << '\n';
}
float time = (float)(clock() - start) / CLOCKS_PER_SEC;
// cout << "\ntime : " << time;
} | [
"goys5228@gmail.com"
] | goys5228@gmail.com |
f56a01ffdd076f1a58420405edae1ad4545f15d4 | fb22522d72bc35979405e3ac07d0e4663c2ed6fc | /src/raid/io/manager.cpp | fc3bc1d63740b88cc545a84ed66065278e026133 | [] | no_license | DreadedX/raid | f9872785be5d49e6a03ae7ea126bf44662bf10f0 | 15cf52e9a2bc7c9e511dd06aec0fc04c027c6ddc | refs/heads/master | 2020-05-30T08:39:27.457741 | 2017-05-17T19:47:32 | 2017-05-17T19:47:32 | 70,187,823 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,624 | cpp | //----------------------------------------------
#include "typedef.h"
#include "raid/engine.h"
#include "flxr/spec.h"
#include "flxr/exceptions.h"
#include "logger.h"
//----------------------------------------------
/// @todo Make this not platform specific
void raid::FileManager::add_container(const std::string& container_path) {
// Create en pointer to a container
std::string full_path = Engine::instance().get_platform()->get_storage_path() + "/" + container_path;
std::unique_ptr<flxr::Container> container = std::make_unique<flxr::Container>(full_path);
// try {
container->check_crc();
container->read_header();
container->read_index();
for(auto& meta_data : (*container).get_index()) {
add_file(meta_data);
}
containers.emplace_back(std::move(container));
// } catch(flxr::bad_file& e) {
// warning << e.what() << '\n';
// }
}
//----------------------------------------------
flxr::MetaData& raid::FileManager::get_file(std::string file_name) {
/// @todo Optimize this
// Search for file and return it
for (auto& file : files) {
if (file.get_name() == file_name) {
return file;
}
}
warning << "Unable to find file: " << file_name << '\n';
throw std::runtime_error("Unable to find file");
/// @todo This should be an exception, maybe even return a default object or something
// exit(-1);
}
//----------------------------------------------
/// @todo Prevent duplication
void raid::FileManager::add_file(flxr::MetaData& meta_data) {
debug << "Adding file: " << meta_data.get_name() << '\n';
files.push_back(meta_data);
}
//----------------------------------------------
| [
"tim.huizinga@gmail.com"
] | tim.huizinga@gmail.com |
a03267c2d7bbbfb9257c8a1b241b726bb0811cb6 | a775a26cded574dcc5c090a0d78f6ccc626bdb64 | /partie.cpp | feec092c3f60ad560255c6b85082f178098cb08b | [] | no_license | Winnie75/TowerDefense | c0f522fdd1dc3bde0b94e4152ce41e0d413e56ea | 0638bdabbcab726e374a8e4b0cfc8d1e538fec3f | refs/heads/master | 2021-12-02T23:58:48.897791 | 2012-05-10T14:01:48 | 2012-05-10T14:01:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,507 | cpp | #include "partie.h"
#include <QTextStream>
#include <QFile>
Partie::Partie(QObject *parent) :
QObject(parent)
{
sonNiveau = new Niveau();
sonTerrain = NULL;
sonTimerDecompte = new QTimer();
sonTimerDecompte->start(1000);
QObject::connect(sonTimerDecompte, SIGNAL(timeout()), this, SLOT(decompte()));
nouvellePartie();
sonImageBaseTourelle = QImage("data/tourelle_base.png");
chargeImageTypeTourelle();
}
Partie::~Partie()
{
delete sonTerrain;
delete sonNiveau;
delete sonTimerDecompte;
}
void Partie::decompte()
{
if (sonDecompteTemps > 0)
sonDecompteTemps--;
else if (sonDecompteEnnemi > 0)
{
sonTerrain->ajouteEnnemi
(
new Ennemi(sonNiveau->getSonChemin(),
sonNiveau->getSesVagues()->at(saVague).getSonTypeEnnemis())
);
sonDecompteEnnemi--;
}
else if ((unsigned int)saVague+1 < sonNiveau->getSesVagues()->size())
{
saVague++;
sonDecompteTemps = sonNiveau->getSesVagues()->at(saVague).getSonDelai();
sonDecompteEnnemi = sonNiveau->getSesVagues()->at(saVague).getSonNombreEnnemis();
}
else if (sonTerrain->getSaListeEnnemis()->size() == 0)
sonEtat = fin() ? FIN : VICTOIRE;
if (sonEtat == VICTOIRE)
{
sauvegarderPartie();
}
}
void Partie::infligerDegat(int unDegat)
{
saVie -= unDegat;
if (saVie <= 0)
{
saVie = 0;
sonEtat = DEFAITE;
}
}
void Partie::ajoutCredits(Ennemi *unEnnemi)
{
sesCredits += unEnnemi->getSonPrix();
}
void Partie::nouvellePartie()
{
sonNumeroNiveau = 1;
chargerNiveau();
}
void Partie::chargerPartie()
{
QFile file("data/1.sav");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QTextStream stream(&file);
stream.readLine();
{
stream >> sonNumeroNiveau;
chargerNiveau();
stream >> saVie;
stream >> sesCredits;
stream >> sonEtat;
stream >> saVague;
stream >> sonDecompteTemps;
stream >> sonDecompteEnnemi;
stream >> sonTypeTourelle;
}
stream.read(3);
sonTerrain->charge(&stream);
file.close();
chargeImageTypeTourelle();
}
void Partie::sauvegarderPartie()
{
QFile file("data/1.sav");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream stream(&file);
stream << "partie" << endl;
{
stream << sonNumeroNiveau << endl;
stream << saVie << endl;
stream << sesCredits << endl;
stream << sonEtat << endl;
stream << saVague << endl;
stream << sonDecompteTemps << endl;
stream << sonDecompteEnnemi << endl;
stream << sonTypeTourelle << endl;
}
stream << ';' << endl;
sonTerrain->sauvegarde(&stream);
file.close();
}
bool Partie::fin()
{
Niveau *leNiveau;
leNiveau = new Niveau("data/" + QString::number(sonNumeroNiveau+1) + ".lvl");
if (!leNiveau->charge())
return true;
delete leNiveau;
return false;
}
void Partie::chargerNiveau()
{
delete sonNiveau;
sonNiveau = new Niveau("data/" + QString::number(sonNumeroNiveau) + ".lvl");
if (!sonNiveau->charge())
return;
recommencerNiveau();
}
void Partie::niveauSuivant()
{
sonNumeroNiveau++;
chargerNiveau();
chargeImageTypeTourelle();
}
void Partie::chargeImageTypeTourelle()
{
sonImageTypeTourelle = QImage("data/tourelle" + QString::number(sonTypeTourelle) + "_canon.png");
}
void Partie::recommencerNiveau()
{
delete sonTerrain;
sonTerrain = new Terrain(this, sonNiveau->getSonChemin());
saVie = 100;
sesCredits = sonNiveau->getSesCredits();
sonEtat = JOUE;
saVague = 0;
sonDecompteTemps = sonNiveau->getSesVagues()->at(0).getSonDelai();
sonDecompteEnnemi = sonNiveau->getSesVagues()->at(0).getSonNombreEnnemis();
sonTypeTourelle = 0;
}
void Partie::afficheBarreVie(QPainter *unPainter)
{
unPainter->save();
unPainter->translate(20, 20);
unPainter->setPen(Qt::black);
unPainter->setBrush(Qt::green);
unPainter->drawRect(QRect(0, 0, 22, 102));
unPainter->setPen(Qt::green);
unPainter->setBrush(Qt::red);
unPainter->drawRect(QRect(1, 1, 20, 100-saVie));
unPainter->restore();
}
void Partie::afficheInfoVague(QPainter *unPainter)
{
unPainter->save();
unPainter->translate(10, HEIGHT-28);
unPainter->setPen(Qt::white);
unPainter->setBrush(Qt::black);
if (sonDecompteTemps > 0)
{
unPainter->drawText(0, 0, "Prochaine vague dans :");
unPainter->drawText(0, 20, QString::number(sonDecompteTemps) + " seconde(s)");
}
else
{
unPainter->drawText(0, 20, QString::number(sonDecompteEnnemi) + " ennemi(s) restant(s)");
}
unPainter->restore();
}
void Partie::afficheEtat(QPainter *unPainter, QString unTitre, QString unSousTitre)
{
unPainter->save();
unPainter->setPen(Qt::transparent);
unPainter->setBrush(QColor(0, 0, 0, 50));
unPainter->drawRect(QRect(0, 0, WIDTH, HEIGHT));
unPainter->setPen(Qt::white);
unPainter->setFont(QFont("Arial", 70));
unPainter->drawText(0, 0, WIDTH, HEIGHT, Qt::AlignCenter, unTitre);
unPainter->setFont(QFont("Arial", 25));
unPainter->drawText(0, 0, WIDTH, HEIGHT, Qt::AlignCenter, "\n\n\n" + unSousTitre);
unPainter->restore();
}
void Partie::afficheCredits(QPainter *unPainter)
{
unPainter->save();
unPainter->translate(0, HEIGHT-20);
unPainter->setPen(Qt::white);
unPainter->setBrush(Qt::black);
unPainter->drawText(0, 0, WIDTH-10, 20, Qt::AlignRight,
QString::number(sesCredits) + QString::fromUtf8(" crédit(s)"));
unPainter->restore();
}
void Partie::affiche(Curseur *unCurseur, QPainter *unPainter)
{
sonTerrain->affiche(unPainter);
sonTerrain->afficheSurvol(unCurseur, unPainter, &sonImageBaseTourelle,
sesCredits - Tourelle::prix(sonTypeTourelle) >= 0 ? &sonImageTypeTourelle
: NULL);
afficheBarreVie(unPainter);
afficheInfoVague(unPainter);
afficheCredits(unPainter);
switch (sonEtat)
{
case DEFAITE:
afficheEtat(unPainter, QString::fromUtf8("Défaite"), "");
break;
case VICTOIRE:
afficheEtat(unPainter, "Victoire", "Cliquez pour continuer");
break;
case FIN:
afficheEtat(unPainter, "Fin de partie", "");
break;
}
}
void Partie::logique(Curseur *unCurseur)
{
switch (sonEtat)
{
case JOUE:
{
if (unCurseur->getBouton() == Qt::RightButton && unCurseur->getDernierBouton() != Qt::RightButton)
{
sonTypeTourelle = (sonTypeTourelle+1) % 2;
chargeImageTypeTourelle();
}
if (unCurseur->getBouton() == Qt::LeftButton && sesCredits - Tourelle::prix(sonTypeTourelle) >= 0)
if (sonTerrain->ajouteTourelle(unCurseur, sonTypeTourelle))
sesCredits -= Tourelle::prix(sonTypeTourelle);
sonTerrain->logique();
}
break;
case VICTOIRE:
{
if (unCurseur->getBouton() == Qt::LeftButton)
niveauSuivant();
}
break;
}
}
Niveau* Partie::getSonNiveau()
{
return sonNiveau;
}
| [
"geecko.dev@free.fr"
] | geecko.dev@free.fr |
3194f6cb395a7d3a2e72076982d6541b3043e9fd | 401bd5c11dbb27d7d39e7f412e2d69c04c64fb92 | /orderedhttest.cpp | 1c9a562aeb1e1fe51663accdc1db3285bec753ab | [] | no_license | Rebecca-Su/Hashing | 40685b1818080fa15178153406bbeeaa3fbca2cb | 1efa3feaf0bdada87f8bee96edd352286ea037d0 | refs/heads/master | 2022-12-23T14:19:51.457522 | 2020-09-22T21:51:56 | 2020-09-22T21:51:56 | 297,780,227 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,586 | cpp | #include "ordered.h"
int main() {
string command, param;
ChainedHashing chained_hash;
string thisLine;
while(!cin.eof())
{
getline(cin, thisLine);
if(thisLine.size() == 0)
break;
command = thisLine.substr(0, 1);
param = thisLine.substr(2, thisLine.size());
if(command == "n")
{
chained_hash.createTable(stol(param));
cout << "success" << endl;
}
if(command == "i")
{
size_t pos;
string caller = "";
long key = -1;
pos = param.find(";");
if(pos != string::npos)
{
key = stol(param.substr(0, pos));
caller = param.substr(pos + 1, param.size());
}
if(chained_hash.insert(key, caller))
cout << "success" << endl;
else
cout << "failure" << endl;
}
else if(command == "s")
{
Data result = chained_hash.search(stol(param));
if(result.caller == "")
cout << "not found" << endl;
else
cout << "found " << result.caller << " in " << result.key << endl;
}
else if(command == "d")
{
if(chained_hash.del(stol(param)))
cout << "success" << endl;
else
cout << "failure" << endl;
}
else if(command == "p")
chained_hash.print(stol(param));
}
return 0;
}
| [
"r24su@uwaterloo.ca"
] | r24su@uwaterloo.ca |
23926276f8278be1d08073c5034dbe83d08a9de0 | dfff1eb0823f0ef1fd284e674f8c77453794f859 | /ASTGen.h | 1945fa2628027100b911406b76a34e6c7316f1c7 | [] | no_license | Lisa1999/SMLComplier | 4379ad77441b6a20bc4b3f2722bbd1f4057015bb | e967f5c302c73a2b76050120c91b1715013670ad | refs/heads/master | 2020-09-18T18:27:50.469605 | 2019-11-25T06:16:06 | 2019-11-25T06:16:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 65 | h | #pragma once
#include"GeneralFile.h"
class ASTGen {
public:
};
| [
"YAOXL819@outlook.com"
] | YAOXL819@outlook.com |
aaef63bbde57e0da771a6684f4d0259df7b36dfb | ba8f56b4292be78b6df3cd423497f1962f855965 | /Frameworks/JuceModules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp | 9c34f09ae183783e5dd1f7b39d13253d14cdf9ed | [
"MIT"
] | permissive | Sin-tel/protoplug | 644355f4dbf072eea68ac1e548f9f164b1364cc4 | 236344b1c3b1cc64d7dc01ea0c0c2a656bdc4ba1 | refs/heads/master | 2023-09-01T00:45:02.745857 | 2023-08-15T22:54:52 | 2023-08-15T22:54:52 | 151,246,506 | 17 | 4 | NOASSERTION | 2018-10-02T11:54:37 | 2018-10-02T11:54:37 | null | UTF-8 | C++ | false | false | 142,850 | cpp | /*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 5 End-User License
Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
27th April 2017).
End User License Agreement: www.juce.com/juce-5-licence
Privacy Policy: www.juce.com/juce-5-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
#if JUCE_DEBUG && ! defined (JUCE_DEBUG_XERRORS)
#define JUCE_DEBUG_XERRORS 1
#endif
#if JUCE_MODULE_AVAILABLE_juce_gui_extra
#define JUCE_X11_SUPPORTS_XEMBED 1
#else
#define JUCE_X11_SUPPORTS_XEMBED 0
#endif
#if JUCE_X11_SUPPORTS_XEMBED
bool juce_handleXEmbedEvent (ComponentPeer*, void*);
unsigned long juce_getCurrentFocusWindow (ComponentPeer*);
#endif
extern WindowMessageReceiveCallback dispatchWindowMessage;
extern XContext windowHandleXContext;
//=============================== X11 - Keys ===================================
namespace Keys
{
enum MouseButtons
{
NoButton = 0,
LeftButton = 1,
MiddleButton = 2,
RightButton = 3,
WheelUp = 4,
WheelDown = 5
};
static int AltMask = 0;
static int NumLockMask = 0;
static bool numLock = false;
static bool capsLock = false;
static char keyStates [32];
static const int extendedKeyModifier = 0x10000000;
}
bool KeyPress::isKeyCurrentlyDown (int keyCode)
{
ScopedXDisplay xDisplay;
if (auto display = xDisplay.display)
{
int keysym;
if (keyCode & Keys::extendedKeyModifier)
{
keysym = 0xff00 | (keyCode & 0xff);
}
else
{
keysym = keyCode;
if (keysym == (XK_Tab & 0xff)
|| keysym == (XK_Return & 0xff)
|| keysym == (XK_Escape & 0xff)
|| keysym == (XK_BackSpace & 0xff))
{
keysym |= 0xff00;
}
}
ScopedXLock xlock (display);
const int keycode = XKeysymToKeycode (display, (KeySym) keysym);
const int keybyte = keycode >> 3;
const int keybit = (1 << (keycode & 7));
return (Keys::keyStates [keybyte] & keybit) != 0;
}
return false;
}
//==============================================================================
const int KeyPress::spaceKey = XK_space & 0xff;
const int KeyPress::returnKey = XK_Return & 0xff;
const int KeyPress::escapeKey = XK_Escape & 0xff;
const int KeyPress::backspaceKey = XK_BackSpace & 0xff;
const int KeyPress::leftKey = (XK_Left & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::rightKey = (XK_Right & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::upKey = (XK_Up & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::downKey = (XK_Down & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::pageUpKey = (XK_Page_Up & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::pageDownKey = (XK_Page_Down & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::endKey = (XK_End & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::homeKey = (XK_Home & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::insertKey = (XK_Insert & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::deleteKey = (XK_Delete & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::tabKey = XK_Tab & 0xff;
const int KeyPress::F1Key = (XK_F1 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F2Key = (XK_F2 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F3Key = (XK_F3 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F4Key = (XK_F4 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F5Key = (XK_F5 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F6Key = (XK_F6 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F7Key = (XK_F7 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F8Key = (XK_F8 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F9Key = (XK_F9 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F10Key = (XK_F10 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F11Key = (XK_F11 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F12Key = (XK_F12 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F13Key = (XK_F13 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F14Key = (XK_F14 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F15Key = (XK_F15 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F16Key = (XK_F16 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F17Key = (XK_F17 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F18Key = (XK_F18 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F19Key = (XK_F19 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F20Key = (XK_F20 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F21Key = (XK_F21 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F22Key = (XK_F22 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F23Key = (XK_F23 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F24Key = (XK_F24 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F25Key = (XK_F25 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F26Key = (XK_F26 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F27Key = (XK_F27 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F28Key = (XK_F28 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F29Key = (XK_F29 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F30Key = (XK_F30 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F31Key = (XK_F31 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F32Key = (XK_F32 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F33Key = (XK_F33 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F34Key = (XK_F34 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::F35Key = (XK_F35 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::numberPad0 = (XK_KP_0 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::numberPad1 = (XK_KP_1 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::numberPad2 = (XK_KP_2 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::numberPad3 = (XK_KP_3 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::numberPad4 = (XK_KP_4 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::numberPad5 = (XK_KP_5 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::numberPad6 = (XK_KP_6 & 0xff) | Keys::extendedKeyModifier;
const int KeyPress::numberPad7 = (XK_KP_7 & 0xff)| Keys::extendedKeyModifier;
const int KeyPress::numberPad8 = (XK_KP_8 & 0xff)| Keys::extendedKeyModifier;
const int KeyPress::numberPad9 = (XK_KP_9 & 0xff)| Keys::extendedKeyModifier;
const int KeyPress::numberPadAdd = (XK_KP_Add & 0xff)| Keys::extendedKeyModifier;
const int KeyPress::numberPadSubtract = (XK_KP_Subtract & 0xff)| Keys::extendedKeyModifier;
const int KeyPress::numberPadMultiply = (XK_KP_Multiply & 0xff)| Keys::extendedKeyModifier;
const int KeyPress::numberPadDivide = (XK_KP_Divide & 0xff)| Keys::extendedKeyModifier;
const int KeyPress::numberPadSeparator = (XK_KP_Separator & 0xff)| Keys::extendedKeyModifier;
const int KeyPress::numberPadDecimalPoint = (XK_KP_Decimal & 0xff)| Keys::extendedKeyModifier;
const int KeyPress::numberPadEquals = (XK_KP_Equal & 0xff)| Keys::extendedKeyModifier;
const int KeyPress::numberPadDelete = (XK_KP_Delete & 0xff)| Keys::extendedKeyModifier;
const int KeyPress::playKey = ((int) 0xffeeff00) | Keys::extendedKeyModifier;
const int KeyPress::stopKey = ((int) 0xffeeff01) | Keys::extendedKeyModifier;
const int KeyPress::fastForwardKey = ((int) 0xffeeff02) | Keys::extendedKeyModifier;
const int KeyPress::rewindKey = ((int) 0xffeeff03) | Keys::extendedKeyModifier;
//================================== X11 - Shm =================================
#if JUCE_USE_XSHM
namespace XSHMHelpers
{
static int trappedErrorCode = 0;
extern "C" int errorTrapHandler (Display*, XErrorEvent* err)
{
trappedErrorCode = err->error_code;
return 0;
}
static bool isShmAvailable (::Display* display) noexcept
{
static bool isChecked = false;
static bool isAvailable = false;
if (! isChecked)
{
isChecked = true;
if (display != nullptr)
{
int major, minor;
Bool pixmaps;
ScopedXLock xlock (display);
if (XShmQueryVersion (display, &major, &minor, &pixmaps))
{
trappedErrorCode = 0;
XErrorHandler oldHandler = XSetErrorHandler (errorTrapHandler);
XShmSegmentInfo segmentInfo;
zerostruct (segmentInfo);
if (auto* xImage = XShmCreateImage (display, DefaultVisual (display, DefaultScreen (display)),
24, ZPixmap, 0, &segmentInfo, 50, 50))
{
if ((segmentInfo.shmid = shmget (IPC_PRIVATE,
(size_t) (xImage->bytes_per_line * xImage->height),
IPC_CREAT | 0777)) >= 0)
{
segmentInfo.shmaddr = (char*) shmat (segmentInfo.shmid, 0, 0);
if (segmentInfo.shmaddr != (void*) -1)
{
segmentInfo.readOnly = False;
xImage->data = segmentInfo.shmaddr;
XSync (display, False);
if (XShmAttach (display, &segmentInfo) != 0)
{
XSync (display, False);
XShmDetach (display, &segmentInfo);
isAvailable = true;
}
}
XFlush (display);
XDestroyImage (xImage);
shmdt (segmentInfo.shmaddr);
}
shmctl (segmentInfo.shmid, IPC_RMID, 0);
XSetErrorHandler (oldHandler);
if (trappedErrorCode != 0)
isAvailable = false;
}
}
}
}
return isAvailable;
}
}
#endif
//=============================== X11 - Render =================================
#if JUCE_USE_XRENDER
namespace XRender
{
typedef Status (*tXRenderQueryVersion) (Display*, int*, int*);
typedef XRenderPictFormat* (*tXRenderFindStandardFormat) (Display*, int);
typedef XRenderPictFormat* (*tXRenderFindFormat) (Display*, unsigned long, XRenderPictFormat*, int);
typedef XRenderPictFormat* (*tXRenderFindVisualFormat) (Display*, Visual*);
static tXRenderQueryVersion xRenderQueryVersion = nullptr;
static tXRenderFindStandardFormat xRenderFindStandardFormat = nullptr;
static tXRenderFindFormat xRenderFindFormat = nullptr;
static tXRenderFindVisualFormat xRenderFindVisualFormat = nullptr;
static bool isAvailable (::Display* display)
{
static bool hasLoaded = false;
if (! hasLoaded)
{
if (display != nullptr)
{
hasLoaded = true;
ScopedXLock xlock (display);
if (void* h = dlopen ("libXrender.so.1", RTLD_GLOBAL | RTLD_NOW))
{
xRenderQueryVersion = (tXRenderQueryVersion) dlsym (h, "XRenderQueryVersion");
xRenderFindStandardFormat = (tXRenderFindStandardFormat) dlsym (h, "XRenderFindStandardFormat");
xRenderFindFormat = (tXRenderFindFormat) dlsym (h, "XRenderFindFormat");
xRenderFindVisualFormat = (tXRenderFindVisualFormat) dlsym (h, "XRenderFindVisualFormat");
}
if (xRenderQueryVersion != nullptr
&& xRenderFindStandardFormat != nullptr
&& xRenderFindFormat != nullptr
&& xRenderFindVisualFormat != nullptr)
{
int major, minor;
if (xRenderQueryVersion (display, &major, &minor))
return true;
}
}
xRenderQueryVersion = nullptr;
}
return xRenderQueryVersion != nullptr;
}
static bool hasCompositingWindowManager (::Display* display) noexcept
{
return display != nullptr
&& XGetSelectionOwner (display, Atoms::getCreating ("_NET_WM_CM_S0")) != 0;
}
static XRenderPictFormat* findPictureFormat (::Display* display)
{
ScopedXLock xlock (display);
XRenderPictFormat* pictFormat = nullptr;
if (isAvailable())
{
pictFormat = xRenderFindStandardFormat (display, PictStandardARGB32);
if (pictFormat == nullptr)
{
XRenderPictFormat desiredFormat;
desiredFormat.type = PictTypeDirect;
desiredFormat.depth = 32;
desiredFormat.direct.alphaMask = 0xff;
desiredFormat.direct.redMask = 0xff;
desiredFormat.direct.greenMask = 0xff;
desiredFormat.direct.blueMask = 0xff;
desiredFormat.direct.alpha = 24;
desiredFormat.direct.red = 16;
desiredFormat.direct.green = 8;
desiredFormat.direct.blue = 0;
pictFormat = xRenderFindFormat (display,
PictFormatType | PictFormatDepth
| PictFormatRedMask | PictFormatRed
| PictFormatGreenMask | PictFormatGreen
| PictFormatBlueMask | PictFormatBlue
| PictFormatAlphaMask | PictFormatAlpha,
&desiredFormat,
0);
}
}
return pictFormat;
}
}
#endif
//================================ X11 - Visuals ===============================
namespace Visuals
{
static Visual* findVisualWithDepth (::Display* display, int desiredDepth) noexcept
{
ScopedXLock xlock (display);
Visual* visual = nullptr;
int numVisuals = 0;
long desiredMask = VisualNoMask;
XVisualInfo desiredVisual;
desiredVisual.screen = DefaultScreen (display);
desiredVisual.depth = desiredDepth;
desiredMask = VisualScreenMask | VisualDepthMask;
if (desiredDepth == 32)
{
desiredVisual.c_class = TrueColor;
desiredVisual.red_mask = 0x00FF0000;
desiredVisual.green_mask = 0x0000FF00;
desiredVisual.blue_mask = 0x000000FF;
desiredVisual.bits_per_rgb = 8;
desiredMask |= VisualClassMask;
desiredMask |= VisualRedMaskMask;
desiredMask |= VisualGreenMaskMask;
desiredMask |= VisualBlueMaskMask;
desiredMask |= VisualBitsPerRGBMask;
}
if (auto* xvinfos = XGetVisualInfo (display, desiredMask, &desiredVisual, &numVisuals))
{
for (int i = 0; i < numVisuals; i++)
{
if (xvinfos[i].depth == desiredDepth)
{
visual = xvinfos[i].visual;
break;
}
}
XFree (xvinfos);
}
return visual;
}
static Visual* findVisualFormat (::Display* display, int desiredDepth, int& matchedDepth) noexcept
{
Visual* visual = nullptr;
if (desiredDepth == 32)
{
#if JUCE_USE_XSHM
if (XSHMHelpers::isShmAvailable (display))
{
#if JUCE_USE_XRENDER
if (XRender::isAvailable (display))
{
if (auto pictFormat = XRender::findPictureFormat (display))
{
int numVisuals = 0;
XVisualInfo desiredVisual;
desiredVisual.screen = DefaultScreen (display);
desiredVisual.depth = 32;
desiredVisual.bits_per_rgb = 8;
if (auto xvinfos = XGetVisualInfo (display,
VisualScreenMask | VisualDepthMask | VisualBitsPerRGBMask,
&desiredVisual, &numVisuals))
{
for (int i = 0; i < numVisuals; ++i)
{
auto pictVisualFormat = XRender::xRenderFindVisualFormat (display, xvinfos[i].visual);
if (pictVisualFormat != nullptr
&& pictVisualFormat->type == PictTypeDirect
&& pictVisualFormat->direct.alphaMask)
{
visual = xvinfos[i].visual;
matchedDepth = 32;
break;
}
}
XFree (xvinfos);
}
}
}
#endif
if (visual == nullptr)
{
visual = findVisualWithDepth (display, 32);
if (visual != nullptr)
matchedDepth = 32;
}
}
#endif
}
if (visual == nullptr && desiredDepth >= 24)
{
visual = findVisualWithDepth (display, 24);
if (visual != nullptr)
matchedDepth = 24;
}
if (visual == nullptr && desiredDepth >= 16)
{
visual = findVisualWithDepth (display, 16);
if (visual != nullptr)
matchedDepth = 16;
}
return visual;
}
}
//================================= X11 - Bitmap ===============================
class XBitmapImage : public ImagePixelData
{
public:
XBitmapImage (::Display* d, Image::PixelFormat format, int w, int h,
bool clearImage, unsigned int imageDepth_, Visual* visual)
: ImagePixelData (format, w, h),
imageDepth (imageDepth_),
display (d)
{
jassert (format == Image::RGB || format == Image::ARGB);
pixelStride = (format == Image::RGB) ? 3 : 4;
lineStride = ((w * pixelStride + 3) & ~3);
ScopedXLock xlock (display);
#if JUCE_USE_XSHM
usingXShm = false;
if ((imageDepth > 16) && XSHMHelpers::isShmAvailable (display))
{
zerostruct (segmentInfo);
segmentInfo.shmid = -1;
segmentInfo.shmaddr = (char *) -1;
segmentInfo.readOnly = False;
xImage = XShmCreateImage (display, visual, imageDepth, ZPixmap, 0,
&segmentInfo, (unsigned int) w, (unsigned int) h);
if (xImage != nullptr)
{
if ((segmentInfo.shmid = shmget (IPC_PRIVATE,
(size_t) (xImage->bytes_per_line * xImage->height),
IPC_CREAT | 0777)) >= 0)
{
if (segmentInfo.shmid != -1)
{
segmentInfo.shmaddr = (char*) shmat (segmentInfo.shmid, 0, 0);
if (segmentInfo.shmaddr != (void*) -1)
{
segmentInfo.readOnly = False;
xImage->data = segmentInfo.shmaddr;
imageData = (uint8*) segmentInfo.shmaddr;
if (XShmAttach (display, &segmentInfo) != 0)
usingXShm = true;
else
jassertfalse;
}
else
{
shmctl (segmentInfo.shmid, IPC_RMID, 0);
}
}
}
}
}
if (! isUsingXShm())
#endif
{
imageDataAllocated.allocate ((size_t) (lineStride * h), format == Image::ARGB && clearImage);
imageData = imageDataAllocated;
xImage = (XImage*) ::calloc (1, sizeof (XImage));
xImage->width = w;
xImage->height = h;
xImage->xoffset = 0;
xImage->format = ZPixmap;
xImage->data = (char*) imageData;
xImage->byte_order = ImageByteOrder (display);
xImage->bitmap_unit = BitmapUnit (display);
xImage->bitmap_bit_order = BitmapBitOrder (display);
xImage->bitmap_pad = 32;
xImage->depth = pixelStride * 8;
xImage->bytes_per_line = lineStride;
xImage->bits_per_pixel = pixelStride * 8;
xImage->red_mask = 0x00FF0000;
xImage->green_mask = 0x0000FF00;
xImage->blue_mask = 0x000000FF;
if (imageDepth == 16)
{
const int pixStride = 2;
const int stride = ((w * pixStride + 3) & ~3);
imageData16Bit.malloc (stride * h);
xImage->data = imageData16Bit;
xImage->bitmap_pad = 16;
xImage->depth = pixStride * 8;
xImage->bytes_per_line = stride;
xImage->bits_per_pixel = pixStride * 8;
xImage->red_mask = visual->red_mask;
xImage->green_mask = visual->green_mask;
xImage->blue_mask = visual->blue_mask;
}
if (! XInitImage (xImage))
jassertfalse;
}
}
~XBitmapImage()
{
ScopedXLock xlock (display);
if (gc != None)
XFreeGC (display, gc);
#if JUCE_USE_XSHM
if (isUsingXShm())
{
XShmDetach (display, &segmentInfo);
XFlush (display);
XDestroyImage (xImage);
shmdt (segmentInfo.shmaddr);
shmctl (segmentInfo.shmid, IPC_RMID, 0);
}
else
#endif
{
xImage->data = nullptr;
XDestroyImage (xImage);
}
}
LowLevelGraphicsContext* createLowLevelContext() override
{
sendDataChangeMessage();
return new LowLevelGraphicsSoftwareRenderer (Image (this));
}
void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y,
Image::BitmapData::ReadWriteMode mode) override
{
bitmap.data = imageData + x * pixelStride + y * lineStride;
bitmap.pixelFormat = pixelFormat;
bitmap.lineStride = lineStride;
bitmap.pixelStride = pixelStride;
if (mode != Image::BitmapData::readOnly)
sendDataChangeMessage();
}
ImagePixelData::Ptr clone() override
{
jassertfalse;
return nullptr;
}
ImageType* createType() const override { return new NativeImageType(); }
void blitToWindow (Window window, int dx, int dy,
unsigned int dw, unsigned int dh, int sx, int sy)
{
ScopedXLock xlock (display);
if (gc == None)
{
XGCValues gcvalues;
gcvalues.foreground = None;
gcvalues.background = None;
gcvalues.function = GXcopy;
gcvalues.plane_mask = AllPlanes;
gcvalues.clip_mask = None;
gcvalues.graphics_exposures = False;
gc = XCreateGC (display, window,
GCBackground | GCForeground | GCFunction | GCPlaneMask | GCClipMask | GCGraphicsExposures,
&gcvalues);
}
if (imageDepth == 16)
{
auto rMask = (uint32) xImage->red_mask;
auto gMask = (uint32) xImage->green_mask;
auto bMask = (uint32) xImage->blue_mask;
auto rShiftL = (uint32) jmax (0, getShiftNeeded (rMask));
auto rShiftR = (uint32) jmax (0, -getShiftNeeded (rMask));
auto gShiftL = (uint32) jmax (0, getShiftNeeded (gMask));
auto gShiftR = (uint32) jmax (0, -getShiftNeeded (gMask));
auto bShiftL = (uint32) jmax (0, getShiftNeeded (bMask));
auto bShiftR = (uint32) jmax (0, -getShiftNeeded (bMask));
const Image::BitmapData srcData (Image (this), Image::BitmapData::readOnly);
for (int y = sy; y < sy + (int)dh; ++y)
{
const uint8* p = srcData.getPixelPointer (sx, y);
for (int x = sx; x < sx + (int)dw; ++x)
{
auto* pixel = (const PixelRGB*) p;
p += srcData.pixelStride;
XPutPixel (xImage, x, y,
(((((uint32) pixel->getRed()) << rShiftL) >> rShiftR) & rMask)
| (((((uint32) pixel->getGreen()) << gShiftL) >> gShiftR) & gMask)
| (((((uint32) pixel->getBlue()) << bShiftL) >> bShiftR) & bMask));
}
}
}
// blit results to screen.
#if JUCE_USE_XSHM
if (isUsingXShm())
XShmPutImage (display, (::Drawable) window, gc, xImage, sx, sy, dx, dy, dw, dh, True);
else
#endif
XPutImage (display, (::Drawable) window, gc, xImage, sx, sy, dx, dy, dw, dh);
}
#if JUCE_USE_XSHM
bool isUsingXShm() const noexcept { return usingXShm; }
#endif
private:
//==============================================================================
XImage* xImage = {};
const unsigned int imageDepth;
HeapBlock<uint8> imageDataAllocated;
HeapBlock<char> imageData16Bit;
int pixelStride, lineStride;
uint8* imageData = {};
GC gc = None;
::Display* display = {};
#if JUCE_USE_XSHM
XShmSegmentInfo segmentInfo;
bool usingXShm;
#endif
static int getShiftNeeded (const uint32 mask) noexcept
{
for (int i = 32; --i >= 0;)
if (((mask >> i) & 1) != 0)
return i - 7;
jassertfalse;
return 0;
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XBitmapImage)
};
//==============================================================================
#if JUCE_USE_XINERAMA
static Array<XineramaScreenInfo> XineramaQueryDisplays (::Display* display)
{
typedef Bool (*tXineramaIsActive) (::Display*);
typedef XineramaScreenInfo* (*tXineramaQueryScreens) (::Display*, int*);
int major_opcode, first_event, first_error;
if (XQueryExtension (display, "XINERAMA", &major_opcode, &first_event, &first_error))
{
static void* libXinerama = nullptr;
static tXineramaIsActive isActiveFuncPtr = nullptr;
static tXineramaQueryScreens xineramaQueryScreens = nullptr;
if (libXinerama == nullptr)
{
libXinerama = dlopen ("libXinerama.so", RTLD_GLOBAL | RTLD_NOW);
if (libXinerama == nullptr)
libXinerama = dlopen ("libXinerama.so.1", RTLD_GLOBAL | RTLD_NOW);
if (libXinerama != nullptr)
{
isActiveFuncPtr = (tXineramaIsActive) dlsym (libXinerama, "XineramaIsActive");
xineramaQueryScreens = (tXineramaQueryScreens) dlsym (libXinerama, "XineramaQueryScreens");
}
}
if (isActiveFuncPtr != nullptr && xineramaQueryScreens != nullptr && isActiveFuncPtr (display) != 0)
{
int numScreens;
if (auto* xinfo = xineramaQueryScreens (display, &numScreens))
{
Array<XineramaScreenInfo> infos (xinfo, numScreens);
XFree (xinfo);
return infos;
}
}
}
return {};
}
#endif
//==============================================================================
#if JUCE_USE_XRANDR
class XRandrWrapper
{
private:
XRandrWrapper()
{
if (libXrandr == nullptr)
{
libXrandr = dlopen ("libXrandr.so", RTLD_GLOBAL | RTLD_NOW);
if (libXrandr == nullptr)
libXrandr = dlopen ("libXrandr.so.2", RTLD_GLOBAL | RTLD_NOW);
if (libXrandr != nullptr)
{
getScreenResourcesPtr = (tXRRGetScreenResources) dlsym (libXrandr, "XRRGetScreenResources");
freeScreenResourcesPtr = (tXRRFreeScreenResources) dlsym (libXrandr, "XRRFreeScreenResources");
getOutputInfoPtr = (tXRRGetOutputInfo) dlsym (libXrandr, "XRRGetOutputInfo");
freeOutputInfoPtr = (tXRRFreeOutputInfo) dlsym (libXrandr, "XRRFreeOutputInfo");
getCrtcInfoPtr = (tXRRGetCrtcInfo) dlsym (libXrandr, "XRRGetCrtcInfo");
freeCrtcInfoPtr = (tXRRFreeCrtcInfo) dlsym (libXrandr, "XRRFreeCrtcInfo");
getOutputPrimaryPtr = (tXRRGetOutputPrimary) dlsym (libXrandr, "XRRGetOutputPrimary");
}
}
}
public:
//==============================================================================
static XRandrWrapper& getInstance()
{
static XRandrWrapper xrandr;
return xrandr;
}
//==============================================================================
XRRScreenResources* getScreenResources (::Display* display, ::Window window)
{
if (getScreenResourcesPtr != nullptr)
return getScreenResourcesPtr (display, window);
return nullptr;
}
XRROutputInfo* getOutputInfo (::Display* display, XRRScreenResources* resources, RROutput output)
{
if (getOutputInfoPtr != nullptr)
return getOutputInfoPtr (display, resources, output);
return nullptr;
}
XRRCrtcInfo* getCrtcInfo (::Display* display, XRRScreenResources* resources, RRCrtc crtc)
{
if (getCrtcInfoPtr != nullptr)
return getCrtcInfoPtr (display, resources, crtc);
return nullptr;
}
RROutput getOutputPrimary (::Display* display, ::Window window)
{
if (getOutputPrimaryPtr != nullptr)
return getOutputPrimaryPtr (display, window);
return 0;
}
//==============================================================================
void freeScreenResources (XRRScreenResources* ptr)
{
if (freeScreenResourcesPtr != nullptr)
freeScreenResourcesPtr (ptr);
}
void freeOutputInfo (XRROutputInfo* ptr)
{
if (freeOutputInfoPtr != nullptr)
freeOutputInfoPtr (ptr);
}
void freeCrtcInfo (XRRCrtcInfo* ptr)
{
if (freeCrtcInfoPtr != nullptr)
freeCrtcInfoPtr (ptr);
}
private:
using tXRRGetScreenResources = XRRScreenResources* (*) (::Display*, ::Window);
using tXRRFreeScreenResources = void (*) (XRRScreenResources*);
using tXRRGetOutputInfo = XRROutputInfo* (*) (::Display*, XRRScreenResources*, RROutput);
using tXRRFreeOutputInfo = void (*) (XRROutputInfo*);
using tXRRGetCrtcInfo = XRRCrtcInfo* (*) (::Display*, XRRScreenResources*, RRCrtc);
using tXRRFreeCrtcInfo = void (*) (XRRCrtcInfo*);
using tXRRGetOutputPrimary = RROutput (*) (::Display*, ::Window);
void* libXrandr = nullptr;
tXRRGetScreenResources getScreenResourcesPtr = nullptr;
tXRRFreeScreenResources freeScreenResourcesPtr = nullptr;
tXRRGetOutputInfo getOutputInfoPtr = nullptr;
tXRRFreeOutputInfo freeOutputInfoPtr = nullptr;
tXRRGetCrtcInfo getCrtcInfoPtr = nullptr;
tXRRFreeCrtcInfo freeCrtcInfoPtr = nullptr;
tXRRGetOutputPrimary getOutputPrimaryPtr = nullptr;
};
#endif
static double getDisplayDPI (::Display* display, int index)
{
double dpiX = (DisplayWidth (display, index) * 25.4) / DisplayWidthMM (display, index);
double dpiY = (DisplayHeight (display, index) * 25.4) / DisplayHeightMM (display, index);
return (dpiX + dpiY) / 2.0;
}
static double getScaleForDisplay (const String& name, double dpi)
{
if (name.isNotEmpty())
{
// Ubuntu and derived distributions now save a per-display scale factor as a configuration
// variable. This can be changed in the Monitor system settings panel.
ChildProcess dconf;
if (File ("/usr/bin/dconf").existsAsFile()
&& dconf.start ("/usr/bin/dconf read /com/ubuntu/user-interface/scale-factor", ChildProcess::wantStdOut))
{
if (dconf.waitForProcessToFinish (200))
{
auto jsonOutput = dconf.readAllProcessOutput().replaceCharacter ('\'', '"');
if (dconf.getExitCode() == 0 && jsonOutput.isNotEmpty())
{
auto jsonVar = JSON::parse (jsonOutput);
if (auto* object = jsonVar.getDynamicObject())
{
auto scaleFactorVar = object->getProperty (name);
if (! scaleFactorVar.isVoid())
{
auto scaleFactor = ((double) scaleFactorVar) / 8.0;
if (scaleFactor > 0.0)
return scaleFactor;
}
}
}
}
}
}
{
// Other gnome based distros now use gsettings for a global scale factor
ChildProcess gsettings;
if (File ("/usr/bin/gsettings").existsAsFile()
&& gsettings.start ("/usr/bin/gsettings get org.gnome.desktop.interface scaling-factor", ChildProcess::wantStdOut))
{
if (gsettings.waitForProcessToFinish (200))
{
auto gsettingsOutput = StringArray::fromTokens (gsettings.readAllProcessOutput(), true);
if (gsettingsOutput.size() >= 2 && gsettingsOutput[1].length() > 0)
{
auto scaleFactor = gsettingsOutput[1].getDoubleValue();
if (scaleFactor > 0.0)
return scaleFactor;
}
}
}
}
// If no scale factor is set by GNOME or Ubuntu then calculate from monitor dpi
// We use the same approach as chromium which simply divides the dpi by 96
// and then rounds the result
return round (dpi / 150.0);
}
//=============================== X11 - Pixmap =================================
namespace PixmapHelpers
{
Pixmap createColourPixmapFromImage (::Display* display, const Image& image)
{
ScopedXLock xlock (display);
auto width = (unsigned int) image.getWidth();
auto height = (unsigned int) image.getHeight();
HeapBlock<uint32> colour (width * height);
int index = 0;
for (int y = 0; y < (int) height; ++y)
for (int x = 0; x < (int) width; ++x)
colour[index++] = image.getPixelAt (x, y).getARGB();
XImage* ximage = XCreateImage (display, CopyFromParent, 24, ZPixmap,
0, reinterpret_cast<char*> (colour.getData()),
width, height, 32, 0);
Pixmap pixmap = XCreatePixmap (display, DefaultRootWindow (display),
width, height, 24);
GC gc = XCreateGC (display, pixmap, 0, 0);
XPutImage (display, pixmap, gc, ximage, 0, 0, 0, 0, width, height);
XFreeGC (display, gc);
return pixmap;
}
Pixmap createMaskPixmapFromImage (::Display* display, const Image& image)
{
ScopedXLock xlock (display);
auto width = (unsigned int) image.getWidth();
auto height = (unsigned int) image.getHeight();
auto stride = (width + 7) >> 3;
HeapBlock<char> mask;
mask.calloc (stride * height);
const bool msbfirst = (BitmapBitOrder (display) == MSBFirst);
for (unsigned int y = 0; y < height; ++y)
{
for (unsigned int x = 0; x < width; ++x)
{
auto bit = (char) (1 << (msbfirst ? (7 - (x & 7)) : (x & 7)));
const unsigned int offset = y * stride + (x >> 3);
if (image.getPixelAt ((int) x, (int) y).getAlpha() >= 128)
mask[offset] |= bit;
}
}
return XCreatePixmapFromBitmapData (display, DefaultRootWindow (display),
mask.getData(), width, height, 1, 0, 1);
}
}
static void* createDraggingHandCursor()
{
static unsigned char dragHandData[] = { 71,73,70,56,57,97,16,0,16,0,145,2,0,0,0,0,255,255,255,0,
0,0,0,0,0,33,249,4,1,0,0,2,0,44,0,0,0,0,16,0, 16,0,0,2,52,148,47,0,200,185,16,130,90,12,74,139,107,84,123,39,
132,117,151,116,132,146,248,60,209,138,98,22,203,114,34,236,37,52,77,217, 247,154,191,119,110,240,193,128,193,95,163,56,60,234,98,135,2,0,59 };
const int dragHandDataSize = 99;
return CustomMouseCursorInfo (ImageFileFormat::loadFrom (dragHandData, dragHandDataSize), { 8, 7 }).create();
}
//==============================================================================
static int numAlwaysOnTopPeers = 0;
bool juce_areThereAnyAlwaysOnTopWindows()
{
return numAlwaysOnTopPeers > 0;
}
//==============================================================================
class LinuxComponentPeer : public ComponentPeer
{
public:
LinuxComponentPeer (Component& comp, int windowStyleFlags, Window parentToAddTo)
: ComponentPeer (comp, windowStyleFlags),
isAlwaysOnTop (comp.isAlwaysOnTop())
{
// it's dangerous to create a window on a thread other than the message thread..
jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager());
display = XWindowSystem::getInstance()->displayRef();
atoms.reset (new Atoms (display));
dragState.reset (new DragState (display));
repainter.reset (new LinuxRepaintManager (*this, display));
if (isAlwaysOnTop)
++numAlwaysOnTopPeers;
createWindow (parentToAddTo);
setTitle (component.getName());
getNativeRealtimeModifiers = []
{
ScopedXDisplay xDisplay;
if (auto display = xDisplay.display)
{
Window root, child;
int x, y, winx, winy;
unsigned int mask;
int mouseMods = 0;
ScopedXLock xlock (display);
if (XQueryPointer (display, RootWindow (display, DefaultScreen (display)),
&root, &child, &x, &y, &winx, &winy, &mask) != False)
{
if ((mask & Button1Mask) != 0) mouseMods |= ModifierKeys::leftButtonModifier;
if ((mask & Button2Mask) != 0) mouseMods |= ModifierKeys::middleButtonModifier;
if ((mask & Button3Mask) != 0) mouseMods |= ModifierKeys::rightButtonModifier;
}
ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withoutMouseButtons().withFlags (mouseMods);
}
return ModifierKeys::currentModifiers;
};
}
~LinuxComponentPeer()
{
// it's dangerous to delete a window on a thread other than the message thread..
jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager());
#if JUCE_X11_SUPPORTS_XEMBED
juce_handleXEmbedEvent (this, nullptr);
#endif
deleteIconPixmaps();
destroyWindow();
windowH = 0;
if (isAlwaysOnTop)
--numAlwaysOnTopPeers;
// delete before display
repainter = nullptr;
display = XWindowSystem::getInstance()->displayUnref();
}
//==============================================================================
void* getNativeHandle() const override
{
return (void*) windowH;
}
static LinuxComponentPeer* getPeerFor (Window windowHandle) noexcept
{
XPointer peer = nullptr;
if (display != nullptr)
{
ScopedXLock xlock (display);
if (! XFindContext (display, (XID) windowHandle, windowHandleXContext, &peer))
if (peer != nullptr && ! ComponentPeer::isValidPeer (reinterpret_cast<LinuxComponentPeer*> (peer)))
peer = nullptr;
}
return reinterpret_cast<LinuxComponentPeer*> (peer);
}
void setVisible (bool shouldBeVisible) override
{
ScopedXLock xlock (display);
if (shouldBeVisible)
XMapWindow (display, windowH);
else
XUnmapWindow (display, windowH);
}
void setTitle (const String& title) override
{
XTextProperty nameProperty;
char* strings[] = { const_cast<char*> (title.toRawUTF8()) };
ScopedXLock xlock (display);
if (XStringListToTextProperty (strings, 1, &nameProperty))
{
XSetWMName (display, windowH, &nameProperty);
XSetWMIconName (display, windowH, &nameProperty);
XFree (nameProperty.value);
}
}
void setBounds (const Rectangle<int>& newBounds, bool isNowFullScreen) override
{
if (fullScreen && ! isNowFullScreen)
{
// When transitioning back from fullscreen, we might need to remove
// the FULLSCREEN window property
Atom fs = Atoms::getIfExists (display, "_NET_WM_STATE_FULLSCREEN");
if (fs != None)
{
Window root = RootWindow (display, DefaultScreen (display));
XClientMessageEvent clientMsg;
clientMsg.display = display;
clientMsg.window = windowH;
clientMsg.type = ClientMessage;
clientMsg.format = 32;
clientMsg.message_type = atoms->windowState;
clientMsg.data.l[0] = 0; // Remove
clientMsg.data.l[1] = (long) fs;
clientMsg.data.l[2] = 0;
clientMsg.data.l[3] = 1; // Normal Source
ScopedXLock xlock (display);
XSendEvent (display, root, false,
SubstructureRedirectMask | SubstructureNotifyMask,
(XEvent*) &clientMsg);
}
}
fullScreen = isNowFullScreen;
if (windowH != 0)
{
bounds = newBounds.withSize (jmax (1, newBounds.getWidth()),
jmax (1, newBounds.getHeight()));
auto& displays = Desktop::getInstance().getDisplays();
auto newScaleFactor = displays.findDisplayForRect (bounds, true).scale;
if (! approximatelyEqual (newScaleFactor, currentScaleFactor))
{
currentScaleFactor = newScaleFactor;
scaleFactorListeners.call ([&] (ScaleFactorListener& l) { l.nativeScaleFactorChanged (currentScaleFactor); });
}
auto physicalBounds = displays.logicalToPhysical (bounds);
WeakReference<Component> deletionChecker (&component);
ScopedXLock xlock (display);
auto* hints = XAllocSizeHints();
hints->flags = USSize | USPosition;
hints->x = physicalBounds.getX();
hints->y = physicalBounds.getY();
hints->width = physicalBounds.getWidth();
hints->height = physicalBounds.getHeight();
if ((getStyleFlags() & windowIsResizable) == 0)
{
hints->min_width = hints->max_width = hints->width;
hints->min_height = hints->max_height = hints->height;
hints->flags |= PMinSize | PMaxSize;
}
XSetWMNormalHints (display, windowH, hints);
XFree (hints);
XMoveResizeWindow (display, windowH,
physicalBounds.getX() - windowBorder.getLeft(),
physicalBounds.getY() - windowBorder.getTop(),
(unsigned int) physicalBounds.getWidth(),
(unsigned int) physicalBounds.getHeight());
if (deletionChecker != nullptr)
{
updateBorderSize();
handleMovedOrResized();
}
}
}
Rectangle<int> getBounds() const override { return bounds; }
Point<float> localToGlobal (Point<float> relativePosition) override
{
return relativePosition + bounds.getPosition().toFloat();
}
Point<float> globalToLocal (Point<float> screenPosition) override
{
return screenPosition - bounds.getPosition().toFloat();
}
void setAlpha (float /* newAlpha */) override
{
//xxx todo!
}
StringArray getAvailableRenderingEngines() override
{
return StringArray ("Software Renderer");
}
void setMinimised (bool shouldBeMinimised) override
{
if (shouldBeMinimised)
{
Window root = RootWindow (display, DefaultScreen (display));
XClientMessageEvent clientMsg;
clientMsg.display = display;
clientMsg.window = windowH;
clientMsg.type = ClientMessage;
clientMsg.format = 32;
clientMsg.message_type = atoms->changeState;
clientMsg.data.l[0] = IconicState;
ScopedXLock xlock (display);
XSendEvent (display, root, false, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent*) &clientMsg);
}
else
{
setVisible (true);
}
}
bool isMinimised() const override
{
ScopedXLock xlock (display);
GetXProperty prop (display, windowH, atoms->state, 0, 64, false, atoms->state);
return prop.success
&& prop.actualType == atoms->state
&& prop.actualFormat == 32
&& prop.numItems > 0
&& ((unsigned long*) prop.data)[0] == IconicState;
}
void setFullScreen (bool shouldBeFullScreen) override
{
auto r = lastNonFullscreenBounds; // (get a copy of this before de-minimising)
setMinimised (false);
if (fullScreen != shouldBeFullScreen)
{
if (shouldBeFullScreen)
r = Desktop::getInstance().getDisplays().getMainDisplay().userArea;
if (! r.isEmpty())
setBounds (ScalingHelpers::scaledScreenPosToUnscaled (component, r), shouldBeFullScreen);
component.repaint();
}
}
bool isFullScreen() const override
{
return fullScreen;
}
bool isChildWindowOf (Window possibleParent) const
{
Window* windowList = nullptr;
uint32 windowListSize = 0;
Window parent, root;
ScopedXLock xlock (display);
if (XQueryTree (display, windowH, &root, &parent, &windowList, &windowListSize) != 0)
{
if (windowList != nullptr)
XFree (windowList);
return parent == possibleParent;
}
return false;
}
bool isParentWindowOf (Window possibleChild) const
{
if (windowH != 0 && possibleChild != 0)
{
if (possibleChild == windowH)
return true;
Window* windowList = nullptr;
uint32 windowListSize = 0;
Window parent, root;
ScopedXLock xlock (display);
if (XQueryTree (display, possibleChild, &root, &parent, &windowList, &windowListSize) != 0)
{
if (windowList != nullptr)
XFree (windowList);
if (parent == root)
return false;
return isParentWindowOf (parent);
}
}
return false;
}
bool isFrontWindow() const
{
Window* windowList = nullptr;
uint32 windowListSize = 0;
bool result = false;
ScopedXLock xlock (display);
Window parent, root = RootWindow (display, DefaultScreen (display));
if (XQueryTree (display, root, &root, &parent, &windowList, &windowListSize) != 0)
{
for (int i = (int) windowListSize; --i >= 0;)
{
if (auto* peer = LinuxComponentPeer::getPeerFor (windowList[i]))
{
result = (peer == this);
break;
}
}
}
if (windowList != nullptr)
XFree (windowList);
return result;
}
bool contains (Point<int> localPos, bool trueIfInAChildWindow) const override
{
if (! bounds.withZeroOrigin().contains (localPos))
return false;
for (int i = Desktop::getInstance().getNumComponents(); --i >= 0;)
{
auto* c = Desktop::getInstance().getComponent (i);
if (c == &component)
break;
if (! c->isVisible())
continue;
if (auto* peer = c->getPeer())
if (peer->contains (localPos + bounds.getPosition() - peer->getBounds().getPosition(), true))
return false;
}
if (trueIfInAChildWindow)
return true;
::Window root, child;
int wx, wy;
unsigned int ww, wh, bw, bitDepth;
ScopedXLock xlock (display);
localPos *= currentScaleFactor;
return XGetGeometry (display, (::Drawable) windowH, &root, &wx, &wy, &ww, &wh, &bw, &bitDepth)
&& XTranslateCoordinates (display, windowH, windowH, localPos.getX(), localPos.getY(), &wx, &wy, &child)
&& child == None;
}
BorderSize<int> getFrameSize() const override
{
return {};
}
bool setAlwaysOnTop (bool /* alwaysOnTop */) override
{
return false;
}
void toFront (bool makeActive) override
{
if (makeActive)
{
setVisible (true);
grabFocus();
}
{
ScopedXLock xlock (display);
XEvent ev;
ev.xclient.type = ClientMessage;
ev.xclient.serial = 0;
ev.xclient.send_event = True;
ev.xclient.message_type = atoms->activeWin;
ev.xclient.window = windowH;
ev.xclient.format = 32;
ev.xclient.data.l[0] = 2;
ev.xclient.data.l[1] = getUserTime();
ev.xclient.data.l[2] = 0;
ev.xclient.data.l[3] = 0;
ev.xclient.data.l[4] = 0;
XSendEvent (display, RootWindow (display, DefaultScreen (display)),
False, SubstructureRedirectMask | SubstructureNotifyMask, &ev);
XSync (display, False);
}
handleBroughtToFront();
}
void toBehind (ComponentPeer* other) override
{
if (auto* otherPeer = dynamic_cast<LinuxComponentPeer*> (other))
{
if (otherPeer->styleFlags & windowIsTemporary)
return;
setMinimised (false);
Window newStack[] = { otherPeer->windowH, windowH };
ScopedXLock xlock (display);
XRestackWindows (display, newStack, 2);
}
else
jassertfalse; // wrong type of window?
}
bool isFocused() const override
{
int revert = 0;
Window focusedWindow = 0;
ScopedXLock xlock (display);
XGetInputFocus (display, &focusedWindow, &revert);
return isParentWindowOf (focusedWindow);
}
Window getFocusWindow()
{
#if JUCE_X11_SUPPORTS_XEMBED
if (Window w = (Window) juce_getCurrentFocusWindow (this))
return w;
#endif
return windowH;
}
void grabFocus() override
{
XWindowAttributes atts;
ScopedXLock xlock (display);
if (windowH != 0
&& XGetWindowAttributes (display, windowH, &atts)
&& atts.map_state == IsViewable
&& ! isFocused())
{
XSetInputFocus (display, getFocusWindow(), RevertToParent, (::Time) getUserTime());
isActiveApplication = true;
}
}
void textInputRequired (Point<int>, TextInputTarget&) override {}
void repaint (const Rectangle<int>& area) override
{
repainter->repaint (area.getIntersection (bounds.withZeroOrigin()));
}
void performAnyPendingRepaintsNow() override
{
repainter->performAnyPendingRepaintsNow();
}
void setIcon (const Image& newIcon) override
{
const int dataSize = newIcon.getWidth() * newIcon.getHeight() + 2;
HeapBlock<unsigned long> data (dataSize);
int index = 0;
data[index++] = (unsigned long) newIcon.getWidth();
data[index++] = (unsigned long) newIcon.getHeight();
for (int y = 0; y < newIcon.getHeight(); ++y)
for (int x = 0; x < newIcon.getWidth(); ++x)
data[index++] = (unsigned long) newIcon.getPixelAt (x, y).getARGB();
ScopedXLock xlock (display);
xchangeProperty (windowH, Atoms::getCreating (display, "_NET_WM_ICON"), XA_CARDINAL, 32, data.getData(), dataSize);
deleteIconPixmaps();
XWMHints* wmHints = XGetWMHints (display, windowH);
if (wmHints == nullptr)
wmHints = XAllocWMHints();
wmHints->flags |= IconPixmapHint | IconMaskHint;
wmHints->icon_pixmap = PixmapHelpers::createColourPixmapFromImage (display, newIcon);
wmHints->icon_mask = PixmapHelpers::createMaskPixmapFromImage (display, newIcon);
XSetWMHints (display, windowH, wmHints);
XFree (wmHints);
XSync (display, False);
}
void deleteIconPixmaps()
{
ScopedXLock xlock (display);
if (auto* wmHints = XGetWMHints (display, windowH))
{
if ((wmHints->flags & IconPixmapHint) != 0)
{
wmHints->flags &= ~IconPixmapHint;
XFreePixmap (display, wmHints->icon_pixmap);
}
if ((wmHints->flags & IconMaskHint) != 0)
{
wmHints->flags &= ~IconMaskHint;
XFreePixmap (display, wmHints->icon_mask);
}
XSetWMHints (display, windowH, wmHints);
XFree (wmHints);
}
}
//==============================================================================
void handleWindowMessage (XEvent& event)
{
switch (event.xany.type)
{
case KeyPressEventType: handleKeyPressEvent (event.xkey); break;
case KeyRelease: handleKeyReleaseEvent (event.xkey); break;
case ButtonPress: handleButtonPressEvent (event.xbutton); break;
case ButtonRelease: handleButtonReleaseEvent (event.xbutton); break;
case MotionNotify: handleMotionNotifyEvent (event.xmotion); break;
case EnterNotify: handleEnterNotifyEvent (event.xcrossing); break;
case LeaveNotify: handleLeaveNotifyEvent (event.xcrossing); break;
case FocusIn: handleFocusInEvent(); break;
case FocusOut: handleFocusOutEvent(); break;
case Expose: handleExposeEvent (event.xexpose); break;
case MappingNotify: handleMappingNotify (event.xmapping); break;
case ClientMessage: handleClientMessageEvent (event.xclient, event); break;
case SelectionNotify: handleDragAndDropSelection (event); break;
case ConfigureNotify: handleConfigureNotifyEvent (event.xconfigure); break;
case ReparentNotify: handleReparentNotifyEvent(); break;
case GravityNotify: handleGravityNotify(); break;
case SelectionClear: handleExternalSelectionClear(); break;
case SelectionRequest: handleExternalSelectionRequest (event); break;
case CirculateNotify:
case CreateNotify:
case DestroyNotify:
// Think we can ignore these
break;
case MapNotify:
mapped = true;
handleBroughtToFront();
break;
case UnmapNotify:
mapped = false;
break;
default:
#if JUCE_USE_XSHM
if (XSHMHelpers::isShmAvailable (display))
{
ScopedXLock xlock (display);
if (event.xany.type == XShmGetEventBase (display))
repainter->notifyPaintCompleted();
}
#endif
break;
}
}
void handleKeyPressEvent (XKeyEvent& keyEvent)
{
auto oldMods = ModifierKeys::currentModifiers;
char utf8 [64] = { 0 };
juce_wchar unicodeChar = 0;
int keyCode = 0;
bool keyDownChange = false;
KeySym sym;
{
ScopedXLock xlock (display);
updateKeyStates ((int) keyEvent.keycode, true);
String oldLocale (::setlocale (LC_ALL, 0));
::setlocale (LC_ALL, "");
XLookupString (&keyEvent, utf8, sizeof (utf8), &sym, 0);
if (oldLocale.isNotEmpty())
::setlocale (LC_ALL, oldLocale.toRawUTF8());
unicodeChar = *CharPointer_UTF8 (utf8);
keyCode = (int) unicodeChar;
if (keyCode < 0x20)
keyCode = (int) XkbKeycodeToKeysym (display, (::KeyCode) keyEvent.keycode, 0, ModifierKeys::currentModifiers.isShiftDown() ? 1 : 0);
keyDownChange = (sym != NoSymbol) && ! updateKeyModifiersFromSym (sym, true);
}
bool keyPressed = false;
if ((sym & 0xff00) == 0xff00 || keyCode == XK_ISO_Left_Tab)
{
switch (sym) // Translate keypad
{
case XK_KP_Add: keyCode = XK_plus; break;
case XK_KP_Subtract: keyCode = XK_hyphen; break;
case XK_KP_Divide: keyCode = XK_slash; break;
case XK_KP_Multiply: keyCode = XK_asterisk; break;
case XK_KP_Enter: keyCode = XK_Return; break;
case XK_KP_Insert: keyCode = XK_Insert; break;
case XK_Delete:
case XK_KP_Delete: keyCode = XK_Delete; break;
case XK_KP_Left: keyCode = XK_Left; break;
case XK_KP_Right: keyCode = XK_Right; break;
case XK_KP_Up: keyCode = XK_Up; break;
case XK_KP_Down: keyCode = XK_Down; break;
case XK_KP_Home: keyCode = XK_Home; break;
case XK_KP_End: keyCode = XK_End; break;
case XK_KP_Page_Down: keyCode = XK_Page_Down; break;
case XK_KP_Page_Up: keyCode = XK_Page_Up; break;
case XK_KP_0: keyCode = XK_0; break;
case XK_KP_1: keyCode = XK_1; break;
case XK_KP_2: keyCode = XK_2; break;
case XK_KP_3: keyCode = XK_3; break;
case XK_KP_4: keyCode = XK_4; break;
case XK_KP_5: keyCode = XK_5; break;
case XK_KP_6: keyCode = XK_6; break;
case XK_KP_7: keyCode = XK_7; break;
case XK_KP_8: keyCode = XK_8; break;
case XK_KP_9: keyCode = XK_9; break;
default: break;
}
switch (keyCode)
{
case XK_Left:
case XK_Right:
case XK_Up:
case XK_Down:
case XK_Page_Up:
case XK_Page_Down:
case XK_End:
case XK_Home:
case XK_Delete:
case XK_Insert:
keyPressed = true;
keyCode = (keyCode & 0xff) | Keys::extendedKeyModifier;
break;
case XK_Tab:
case XK_Return:
case XK_Escape:
case XK_BackSpace:
keyPressed = true;
keyCode &= 0xff;
break;
case XK_ISO_Left_Tab:
keyPressed = true;
keyCode = XK_Tab & 0xff;
break;
default:
if (sym >= XK_F1 && sym <= XK_F35)
{
keyPressed = true;
keyCode = (sym & 0xff) | Keys::extendedKeyModifier;
}
break;
}
}
if (utf8[0] != 0 || ((sym & 0xff00) == 0 && sym >= 8))
keyPressed = true;
if (oldMods != ModifierKeys::currentModifiers)
handleModifierKeysChange();
if (keyDownChange)
handleKeyUpOrDown (true);
if (keyPressed)
handleKeyPress (keyCode, unicodeChar);
}
static bool isKeyReleasePartOfAutoRepeat (const XKeyEvent& keyReleaseEvent)
{
if (XPending (display))
{
XEvent e;
XPeekEvent (display, &e);
// Look for a subsequent key-down event with the same timestamp and keycode
return e.type == KeyPressEventType
&& e.xkey.keycode == keyReleaseEvent.keycode
&& e.xkey.time == keyReleaseEvent.time;
}
return false;
}
void handleKeyReleaseEvent (const XKeyEvent& keyEvent)
{
if (! isKeyReleasePartOfAutoRepeat (keyEvent))
{
updateKeyStates ((int) keyEvent.keycode, false);
KeySym sym;
{
ScopedXLock xlock (display);
sym = XkbKeycodeToKeysym (display, (::KeyCode) keyEvent.keycode, 0, 0);
}
auto oldMods = ModifierKeys::currentModifiers;
const bool keyDownChange = (sym != NoSymbol) && ! updateKeyModifiersFromSym (sym, false);
if (oldMods != ModifierKeys::currentModifiers)
handleModifierKeysChange();
if (keyDownChange)
handleKeyUpOrDown (false);
}
}
template <typename EventType>
Point<float> getMousePos (const EventType& e) noexcept
{
return Point<float> ((float) e.x, (float) e.y) / currentScaleFactor;
}
void handleWheelEvent (const XButtonPressedEvent& buttonPressEvent, float amount)
{
MouseWheelDetails wheel;
wheel.deltaX = 0.0f;
wheel.deltaY = amount;
wheel.isReversed = false;
wheel.isSmooth = false;
wheel.isInertial = false;
handleMouseWheel (MouseInputSource::InputSourceType::mouse, getMousePos (buttonPressEvent),
getEventTime (buttonPressEvent), wheel);
}
void handleButtonPressEvent (const XButtonPressedEvent& buttonPressEvent, int buttonModifierFlag)
{
ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withFlags (buttonModifierFlag);
toFront (true);
handleMouseEvent (MouseInputSource::InputSourceType::mouse, getMousePos (buttonPressEvent), ModifierKeys::currentModifiers,
MouseInputSource::invalidPressure, MouseInputSource::invalidOrientation, getEventTime (buttonPressEvent), {});
}
void handleButtonPressEvent (const XButtonPressedEvent& buttonPressEvent)
{
updateKeyModifiers ((int) buttonPressEvent.state);
auto mapIndex = (uint32) (buttonPressEvent.button - Button1);
if (mapIndex < (uint32) numElementsInArray (pointerMap))
{
switch (pointerMap[mapIndex])
{
case Keys::WheelUp: handleWheelEvent (buttonPressEvent, 50.0f / 256.0f); break;
case Keys::WheelDown: handleWheelEvent (buttonPressEvent, -50.0f / 256.0f); break;
case Keys::LeftButton: handleButtonPressEvent (buttonPressEvent, ModifierKeys::leftButtonModifier); break;
case Keys::RightButton: handleButtonPressEvent (buttonPressEvent, ModifierKeys::rightButtonModifier); break;
case Keys::MiddleButton: handleButtonPressEvent (buttonPressEvent, ModifierKeys::middleButtonModifier); break;
default: break;
}
}
clearLastMousePos();
}
void handleButtonReleaseEvent (const XButtonReleasedEvent& buttonRelEvent)
{
updateKeyModifiers ((int) buttonRelEvent.state);
if (parentWindow != 0)
updateWindowBounds();
auto mapIndex = (uint32) (buttonRelEvent.button - Button1);
if (mapIndex < (uint32) numElementsInArray (pointerMap))
{
switch (pointerMap[mapIndex])
{
case Keys::LeftButton: ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withoutFlags (ModifierKeys::leftButtonModifier); break;
case Keys::RightButton: ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withoutFlags (ModifierKeys::rightButtonModifier); break;
case Keys::MiddleButton: ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withoutFlags (ModifierKeys::middleButtonModifier); break;
default: break;
}
}
if (dragState->dragging)
handleExternalDragButtonReleaseEvent();
handleMouseEvent (MouseInputSource::InputSourceType::mouse, getMousePos (buttonRelEvent), ModifierKeys::currentModifiers,
MouseInputSource::invalidPressure, MouseInputSource::invalidOrientation, getEventTime (buttonRelEvent));
clearLastMousePos();
}
void handleMotionNotifyEvent (const XPointerMovedEvent& movedEvent)
{
updateKeyModifiers ((int) movedEvent.state);
lastMousePos = Point<int> (movedEvent.x_root, movedEvent.y_root);
if (dragState->dragging)
handleExternalDragMotionNotify();
handleMouseEvent (MouseInputSource::InputSourceType::mouse, getMousePos (movedEvent), ModifierKeys::currentModifiers,
MouseInputSource::invalidPressure, MouseInputSource::invalidOrientation, getEventTime (movedEvent));
}
void handleEnterNotifyEvent (const XEnterWindowEvent& enterEvent)
{
if (parentWindow != 0)
updateWindowBounds();
clearLastMousePos();
if (! ModifierKeys::currentModifiers.isAnyMouseButtonDown())
{
updateKeyModifiers ((int) enterEvent.state);
handleMouseEvent (MouseInputSource::InputSourceType::mouse, getMousePos (enterEvent), ModifierKeys::currentModifiers,
MouseInputSource::invalidPressure, MouseInputSource::invalidOrientation, getEventTime (enterEvent));
}
}
void handleLeaveNotifyEvent (const XLeaveWindowEvent& leaveEvent)
{
// Suppress the normal leave if we've got a pointer grab, or if
// it's a bogus one caused by clicking a mouse button when running
// in a Window manager
if (((! ModifierKeys::currentModifiers.isAnyMouseButtonDown()) && leaveEvent.mode == NotifyNormal)
|| leaveEvent.mode == NotifyUngrab)
{
updateKeyModifiers ((int) leaveEvent.state);
handleMouseEvent (MouseInputSource::InputSourceType::mouse, getMousePos (leaveEvent), ModifierKeys::currentModifiers,
MouseInputSource::invalidPressure, MouseInputSource::invalidOrientation, getEventTime (leaveEvent));
}
}
void handleFocusInEvent()
{
isActiveApplication = true;
if (isFocused() && ! focused)
{
focused = true;
handleFocusGain();
}
}
void handleFocusOutEvent()
{
if (! isFocused() && focused)
{
focused = false;
isActiveApplication = false;
handleFocusLoss();
}
}
void handleExposeEvent (XExposeEvent& exposeEvent)
{
// Batch together all pending expose events
XEvent nextEvent;
ScopedXLock xlock (display);
// if we have opengl contexts then just repaint them all
// regardless if this is really necessary
repaintOpenGLContexts();
if (exposeEvent.window != windowH)
{
Window child;
XTranslateCoordinates (display, exposeEvent.window, windowH,
exposeEvent.x, exposeEvent.y, &exposeEvent.x, &exposeEvent.y,
&child);
}
// exposeEvent is in local window local coordinates so do not convert with
// physicalToScaled, but rather use currentScaleFactor
repaint (Rectangle<int> (exposeEvent.x, exposeEvent.y,
exposeEvent.width, exposeEvent.height) / currentScaleFactor);
while (XEventsQueued (display, QueuedAfterFlush) > 0)
{
XPeekEvent (display, &nextEvent);
if (nextEvent.type != Expose || nextEvent.xany.window != exposeEvent.window)
break;
XNextEvent (display, &nextEvent);
auto& nextExposeEvent = (const XExposeEvent&) nextEvent.xexpose;
repaint (Rectangle<int> (nextExposeEvent.x, nextExposeEvent.y,
nextExposeEvent.width, nextExposeEvent.height) / currentScaleFactor);
}
}
void handleConfigureNotifyEvent (XConfigureEvent& confEvent)
{
updateWindowBounds();
updateBorderSize();
handleMovedOrResized();
// if the native title bar is dragged, need to tell any active menus, etc.
if ((styleFlags & windowHasTitleBar) != 0
&& component.isCurrentlyBlockedByAnotherModalComponent())
{
if (auto* currentModalComp = Component::getCurrentlyModalComponent())
currentModalComp->inputAttemptWhenModal();
}
if (confEvent.window == windowH && confEvent.above != 0 && isFrontWindow())
handleBroughtToFront();
}
void handleReparentNotifyEvent()
{
parentWindow = 0;
Window wRoot = 0;
Window* wChild = nullptr;
unsigned int numChildren;
{
ScopedXLock xlock (display);
XQueryTree (display, windowH, &wRoot, &parentWindow, &wChild, &numChildren);
}
if (parentWindow == windowH || parentWindow == wRoot)
parentWindow = 0;
handleGravityNotify();
}
void handleGravityNotify()
{
updateWindowBounds();
updateBorderSize();
handleMovedOrResized();
}
void handleMappingNotify (XMappingEvent& mappingEvent)
{
if (mappingEvent.request != MappingPointer)
{
// Deal with modifier/keyboard mapping
ScopedXLock xlock (display);
XRefreshKeyboardMapping (&mappingEvent);
updateModifierMappings();
}
}
void handleClientMessageEvent (XClientMessageEvent& clientMsg, XEvent& event)
{
if (clientMsg.message_type == atoms->protocols && clientMsg.format == 32)
{
auto atom = (Atom) clientMsg.data.l[0];
if (atom == atoms->protocolList [Atoms::PING])
{
Window root = RootWindow (display, DefaultScreen (display));
clientMsg.window = root;
XSendEvent (display, root, False, NoEventMask, &event);
XFlush (display);
}
else if (atom == atoms->protocolList [Atoms::TAKE_FOCUS])
{
if ((getStyleFlags() & juce::ComponentPeer::windowIgnoresKeyPresses) == 0)
{
XWindowAttributes atts;
ScopedXLock xlock (display);
if (clientMsg.window != 0
&& XGetWindowAttributes (display, clientMsg.window, &atts))
{
if (atts.map_state == IsViewable)
XSetInputFocus (display,
(clientMsg.window == windowH ? getFocusWindow()
: clientMsg.window),
RevertToParent,
(::Time) clientMsg.data.l[1]);
}
}
}
else if (atom == atoms->protocolList [Atoms::DELETE_WINDOW])
{
handleUserClosingWindow();
}
}
else if (clientMsg.message_type == atoms->XdndEnter)
{
handleDragAndDropEnter (clientMsg);
}
else if (clientMsg.message_type == atoms->XdndLeave)
{
handleDragExit (dragInfo);
resetDragAndDrop();
}
else if (clientMsg.message_type == atoms->XdndPosition)
{
handleDragAndDropPosition (clientMsg);
}
else if (clientMsg.message_type == atoms->XdndDrop)
{
handleDragAndDropDrop (clientMsg);
}
else if (clientMsg.message_type == atoms->XdndStatus)
{
handleExternalDragAndDropStatus (clientMsg);
}
else if (clientMsg.message_type == atoms->XdndFinished)
{
externalResetDragAndDrop();
}
}
bool externalDragTextInit (const String& text, std::function<void()> cb)
{
if (dragState->dragging)
return false;
return externalDragInit (true, text, cb);
}
bool externalDragFileInit (const StringArray& files, bool /*canMoveFiles*/, std::function<void()> cb)
{
if (dragState->dragging)
return false;
StringArray uriList;
for (auto& f : files)
{
if (f.matchesWildcard ("?*://*", false))
uriList.add (f);
else
uriList.add ("file://" + f);
}
return externalDragInit (false, uriList.joinIntoString ("\r\n"), cb);
}
//==============================================================================
void showMouseCursor (Cursor cursor) noexcept
{
ScopedXLock xlock (display);
XDefineCursor (display, windowH, cursor);
}
//==============================================================================
double getPlatformScaleFactor() const noexcept override
{
return currentScaleFactor;
}
//==============================================================================
void addOpenGLRepaintListener (Component* dummy)
{
if (dummy != nullptr)
glRepaintListeners.addIfNotAlreadyThere (dummy);
}
void removeOpenGLRepaintListener (Component* dummy)
{
if (dummy != nullptr)
glRepaintListeners.removeAllInstancesOf (dummy);
}
void repaintOpenGLContexts()
{
for (int i = 0; i < glRepaintListeners.size(); ++i)
if (auto* c = glRepaintListeners [i])
c->handleCommandMessage (0);
}
//==============================================================================
unsigned long createKeyProxy()
{
jassert (keyProxy == 0 && windowH != 0);
if (keyProxy == 0 && windowH != 0)
{
XSetWindowAttributes swa;
swa.event_mask = KeyPressMask | KeyReleaseMask | FocusChangeMask;
keyProxy = XCreateWindow (display, windowH,
-1, -1, 1, 1, 0, 0,
InputOnly, CopyFromParent,
CWEventMask,
&swa);
XMapWindow (display, keyProxy);
XSaveContext (display, (XID) keyProxy, windowHandleXContext, (XPointer) this);
}
return keyProxy;
}
void deleteKeyProxy()
{
jassert (keyProxy != 0);
if (keyProxy != 0)
{
XPointer handlePointer;
if (! XFindContext (display, (XID) keyProxy, windowHandleXContext, &handlePointer))
XDeleteContext (display, (XID) keyProxy, windowHandleXContext);
XDestroyWindow (display, keyProxy);
XSync (display, false);
XEvent event;
while (XCheckWindowEvent (display, keyProxy, getAllEventsMask(), &event) == True)
{}
keyProxy = 0;
}
}
//==============================================================================
bool dontRepaint;
static bool isActiveApplication;
private:
//==============================================================================
class LinuxRepaintManager : public Timer
{
public:
LinuxRepaintManager (LinuxComponentPeer& p, ::Display* d)
: peer (p), display (d)
{
#if JUCE_USE_XSHM
useARGBImagesForRendering = XSHMHelpers::isShmAvailable (display);
if (useARGBImagesForRendering)
{
ScopedXLock xlock (display);
XShmSegmentInfo segmentinfo;
auto testImage = XShmCreateImage (display, DefaultVisual (display, DefaultScreen (display)),
24, ZPixmap, 0, &segmentinfo, 64, 64);
useARGBImagesForRendering = (testImage->bits_per_pixel == 32);
XDestroyImage (testImage);
}
#endif
}
void timerCallback() override
{
#if JUCE_USE_XSHM
if (shmPaintsPending != 0)
return;
#endif
if (! regionsNeedingRepaint.isEmpty())
{
stopTimer();
performAnyPendingRepaintsNow();
}
else if (Time::getApproximateMillisecondCounter() > lastTimeImageUsed + 3000)
{
stopTimer();
image = Image();
}
}
void repaint (Rectangle<int> area)
{
if (! isTimerRunning())
startTimer (repaintTimerPeriod);
regionsNeedingRepaint.add (area * peer.currentScaleFactor);
}
void performAnyPendingRepaintsNow()
{
#if JUCE_USE_XSHM
if (shmPaintsPending != 0)
{
startTimer (repaintTimerPeriod);
return;
}
#endif
auto originalRepaintRegion = regionsNeedingRepaint;
regionsNeedingRepaint.clear();
auto totalArea = originalRepaintRegion.getBounds();
if (! totalArea.isEmpty())
{
if (image.isNull() || image.getWidth() < totalArea.getWidth()
|| image.getHeight() < totalArea.getHeight())
{
#if JUCE_USE_XSHM
image = Image (new XBitmapImage (display, useARGBImagesForRendering ? Image::ARGB
: Image::RGB,
#else
image = Image (new XBitmapImage (display, Image::RGB,
#endif
(totalArea.getWidth() + 31) & ~31,
(totalArea.getHeight() + 31) & ~31,
false, (unsigned int) peer.depth, peer.visual));
}
startTimer (repaintTimerPeriod);
RectangleList<int> adjustedList (originalRepaintRegion);
adjustedList.offsetAll (-totalArea.getX(), -totalArea.getY());
if (peer.depth == 32)
for (auto& i : originalRepaintRegion)
image.clear (i - totalArea.getPosition());
{
std::unique_ptr<LowLevelGraphicsContext> context (peer.getComponent().getLookAndFeel()
.createGraphicsContext (image, -totalArea.getPosition(), adjustedList));
context->addTransform (AffineTransform::scale ((float) peer.currentScaleFactor));
peer.handlePaint (*context);
}
for (auto& i : originalRepaintRegion)
{
auto* xbitmap = static_cast<XBitmapImage*> (image.getPixelData());
#if JUCE_USE_XSHM
if (xbitmap->isUsingXShm())
++shmPaintsPending;
#endif
xbitmap->blitToWindow (peer.windowH,
i.getX(), i.getY(),
(unsigned int) i.getWidth(),
(unsigned int) i.getHeight(),
i.getX() - totalArea.getX(), i.getY() - totalArea.getY());
}
}
lastTimeImageUsed = Time::getApproximateMillisecondCounter();
startTimer (repaintTimerPeriod);
}
#if JUCE_USE_XSHM
void notifyPaintCompleted() noexcept { --shmPaintsPending; }
#endif
private:
enum { repaintTimerPeriod = 1000 / 100 };
LinuxComponentPeer& peer;
Image image;
uint32 lastTimeImageUsed = 0;
RectangleList<int> regionsNeedingRepaint;
::Display* display;
#if JUCE_USE_XSHM
bool useARGBImagesForRendering;
int shmPaintsPending = 0;
#endif
JUCE_DECLARE_NON_COPYABLE (LinuxRepaintManager)
};
std::unique_ptr<Atoms> atoms;
std::unique_ptr<LinuxRepaintManager> repainter;
friend class LinuxRepaintManager;
Window windowH = {}, parentWindow = {}, keyProxy = {};
Rectangle<int> bounds;
Image taskbarImage;
bool fullScreen = false, mapped = false, focused = false;
Visual* visual = {};
int depth = 0;
BorderSize<int> windowBorder;
bool isAlwaysOnTop;
double currentScaleFactor = 1.0;
Array<Component*> glRepaintListeners;
enum { KeyPressEventType = 2 };
static ::Display* display;
struct MotifWmHints
{
unsigned long flags;
unsigned long functions;
unsigned long decorations;
long input_mode;
unsigned long status;
};
static void updateKeyStates (int keycode, bool press) noexcept
{
const int keybyte = keycode >> 3;
const int keybit = (1 << (keycode & 7));
if (press)
Keys::keyStates [keybyte] |= keybit;
else
Keys::keyStates [keybyte] &= ~keybit;
}
static void updateKeyModifiers (int status) noexcept
{
int keyMods = 0;
if ((status & ShiftMask) != 0) keyMods |= ModifierKeys::shiftModifier;
if ((status & ControlMask) != 0) keyMods |= ModifierKeys::ctrlModifier;
if ((status & Keys::AltMask) != 0) keyMods |= ModifierKeys::altModifier;
ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withOnlyMouseButtons().withFlags (keyMods);
Keys::numLock = ((status & Keys::NumLockMask) != 0);
Keys::capsLock = ((status & LockMask) != 0);
}
static bool updateKeyModifiersFromSym (KeySym sym, bool press) noexcept
{
int modifier = 0;
bool isModifier = true;
switch (sym)
{
case XK_Shift_L:
case XK_Shift_R: modifier = ModifierKeys::shiftModifier; break;
case XK_Control_L:
case XK_Control_R: modifier = ModifierKeys::ctrlModifier; break;
case XK_Alt_L:
case XK_Alt_R: modifier = ModifierKeys::altModifier; break;
case XK_Num_Lock:
if (press)
Keys::numLock = ! Keys::numLock;
break;
case XK_Caps_Lock:
if (press)
Keys::capsLock = ! Keys::capsLock;
break;
case XK_Scroll_Lock:
break;
default:
isModifier = false;
break;
}
ModifierKeys::currentModifiers = press ? ModifierKeys::currentModifiers.withFlags (modifier)
: ModifierKeys::currentModifiers.withoutFlags (modifier);
return isModifier;
}
// Alt and Num lock are not defined by standard X
// modifier constants: check what they're mapped to
static void updateModifierMappings() noexcept
{
ScopedXLock xlock (display);
int altLeftCode = XKeysymToKeycode (display, XK_Alt_L);
int numLockCode = XKeysymToKeycode (display, XK_Num_Lock);
Keys::AltMask = 0;
Keys::NumLockMask = 0;
if (auto* mapping = XGetModifierMapping (display))
{
for (int i = 0; i < 8; i++)
{
if (mapping->modifiermap [i << 1] == altLeftCode)
Keys::AltMask = 1 << i;
else if (mapping->modifiermap [i << 1] == numLockCode)
Keys::NumLockMask = 1 << i;
}
XFreeModifiermap (mapping);
}
}
//==============================================================================
static void xchangeProperty (Window wndH, Atom property, Atom type, int format, const void* data, int numElements)
{
XChangeProperty (display, wndH, property, type, format, PropModeReplace, (const unsigned char*) data, numElements);
}
void removeWindowDecorations (Window wndH)
{
Atom hints = Atoms::getIfExists (display, "_MOTIF_WM_HINTS");
if (hints != None)
{
MotifWmHints motifHints;
zerostruct (motifHints);
motifHints.flags = 2; /* MWM_HINTS_DECORATIONS */
motifHints.decorations = 0;
ScopedXLock xlock (display);
xchangeProperty (wndH, hints, hints, 32, &motifHints, 4);
}
hints = Atoms::getIfExists (display, "_WIN_HINTS");
if (hints != None)
{
long gnomeHints = 0;
ScopedXLock xlock (display);
xchangeProperty (wndH, hints, hints, 32, &gnomeHints, 1);
}
hints = Atoms::getIfExists (display, "KWM_WIN_DECORATION");
if (hints != None)
{
long kwmHints = 2; /*KDE_tinyDecoration*/
ScopedXLock xlock (display);
xchangeProperty (wndH, hints, hints, 32, &kwmHints, 1);
}
hints = Atoms::getIfExists (display, "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
if (hints != None)
{
ScopedXLock xlock (display);
xchangeProperty (wndH, atoms->windowType, XA_ATOM, 32, &hints, 1);
}
}
void addWindowButtons (Window wndH)
{
ScopedXLock xlock (display);
Atom hints = Atoms::getIfExists (display, "_MOTIF_WM_HINTS");
if (hints != None)
{
MotifWmHints motifHints;
zerostruct (motifHints);
motifHints.flags = 1 | 2; /* MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS */
motifHints.decorations = 2 /* MWM_DECOR_BORDER */ | 8 /* MWM_DECOR_TITLE */ | 16; /* MWM_DECOR_MENU */
motifHints.functions = 4 /* MWM_FUNC_MOVE */;
if ((styleFlags & windowHasCloseButton) != 0)
motifHints.functions |= 32; /* MWM_FUNC_CLOSE */
if ((styleFlags & windowHasMinimiseButton) != 0)
{
motifHints.functions |= 8; /* MWM_FUNC_MINIMIZE */
motifHints.decorations |= 0x20; /* MWM_DECOR_MINIMIZE */
}
if ((styleFlags & windowHasMaximiseButton) != 0)
{
motifHints.functions |= 0x10; /* MWM_FUNC_MAXIMIZE */
motifHints.decorations |= 0x40; /* MWM_DECOR_MAXIMIZE */
}
if ((styleFlags & windowIsResizable) != 0)
{
motifHints.functions |= 2; /* MWM_FUNC_RESIZE */
motifHints.decorations |= 0x4; /* MWM_DECOR_RESIZEH */
}
xchangeProperty (wndH, hints, hints, 32, &motifHints, 5);
}
hints = Atoms::getIfExists (display, "_NET_WM_ALLOWED_ACTIONS");
if (hints != None)
{
Atom netHints [6];
int num = 0;
if ((styleFlags & windowIsResizable) != 0)
netHints [num++] = Atoms::getIfExists (display, "_NET_WM_ACTION_RESIZE");
if ((styleFlags & windowHasMaximiseButton) != 0)
netHints [num++] = Atoms::getIfExists (display, "_NET_WM_ACTION_FULLSCREEN");
if ((styleFlags & windowHasMinimiseButton) != 0)
netHints [num++] = Atoms::getIfExists (display, "_NET_WM_ACTION_MINIMIZE");
if ((styleFlags & windowHasCloseButton) != 0)
netHints [num++] = Atoms::getIfExists (display, "_NET_WM_ACTION_CLOSE");
xchangeProperty (wndH, hints, XA_ATOM, 32, &netHints, num);
}
}
void setWindowType()
{
Atom netHints [2];
if ((styleFlags & windowIsTemporary) != 0
|| ((styleFlags & windowHasDropShadow) == 0 && Desktop::canUseSemiTransparentWindows()))
netHints [0] = Atoms::getIfExists (display, "_NET_WM_WINDOW_TYPE_COMBO");
else
netHints [0] = Atoms::getIfExists (display, "_NET_WM_WINDOW_TYPE_NORMAL");
xchangeProperty (windowH, atoms->windowType, XA_ATOM, 32, &netHints, 1);
int numHints = 0;
if ((styleFlags & windowAppearsOnTaskbar) == 0)
netHints [numHints++] = Atoms::getIfExists (display, "_NET_WM_STATE_SKIP_TASKBAR");
if (component.isAlwaysOnTop())
netHints [numHints++] = Atoms::getIfExists (display, "_NET_WM_STATE_ABOVE");
if (numHints > 0)
xchangeProperty (windowH, atoms->windowState, XA_ATOM, 32, &netHints, numHints);
}
void createWindow (Window parentToAddTo)
{
ScopedXLock xlock (display);
resetDragAndDrop();
// Get defaults for various properties
const int screen = DefaultScreen (display);
Window root = RootWindow (display, screen);
parentWindow = parentToAddTo;
// Try to obtain a 32-bit visual or fallback to 24 or 16
visual = Visuals::findVisualFormat (display, (styleFlags & windowIsSemiTransparent) ? 32 : 24, depth);
if (visual == nullptr)
{
Logger::outputDebugString ("ERROR: System doesn't support 32, 24 or 16 bit RGB display.\n");
Process::terminate();
}
// Create and install a colormap suitable fr our visual
Colormap colormap = XCreateColormap (display, root, visual, AllocNone);
XInstallColormap (display, colormap);
// Set up the window attributes
XSetWindowAttributes swa;
swa.border_pixel = 0;
swa.background_pixmap = None;
swa.colormap = colormap;
swa.override_redirect = ((styleFlags & windowIsTemporary) != 0) ? True : False;
swa.event_mask = getAllEventsMask();
windowH = XCreateWindow (display, parentToAddTo != 0 ? parentToAddTo : root,
0, 0, 1, 1,
0, depth, InputOutput, visual,
CWBorderPixel | CWColormap | CWBackPixmap | CWEventMask | CWOverrideRedirect,
&swa);
// Set the window context to identify the window handle object
if (XSaveContext (display, (XID) windowH, windowHandleXContext, (XPointer) this))
{
// Failed
jassertfalse;
Logger::outputDebugString ("Failed to create context information for window.\n");
XDestroyWindow (display, windowH);
windowH = 0;
return;
}
// Set window manager hints
XWMHints* wmHints = XAllocWMHints();
wmHints->flags = InputHint | StateHint;
wmHints->input = True; // Locally active input model
wmHints->initial_state = NormalState;
XSetWMHints (display, windowH, wmHints);
XFree (wmHints);
// Set the window type
setWindowType();
// Define decoration
if ((styleFlags & windowHasTitleBar) == 0)
removeWindowDecorations (windowH);
else
addWindowButtons (windowH);
setTitle (component.getName());
// Associate the PID, allowing to be shut down when something goes wrong
unsigned long pid = (unsigned long) getpid();
xchangeProperty (windowH, atoms->pid, XA_CARDINAL, 32, &pid, 1);
// Set window manager protocols
xchangeProperty (windowH, atoms->protocols, XA_ATOM, 32, atoms->protocolList, 2);
// Set drag and drop flags
xchangeProperty (windowH, atoms->XdndTypeList, XA_ATOM, 32, atoms->allowedMimeTypes, numElementsInArray (atoms->allowedMimeTypes));
xchangeProperty (windowH, atoms->XdndActionList, XA_ATOM, 32, atoms->allowedActions, numElementsInArray (atoms->allowedActions));
xchangeProperty (windowH, atoms->XdndActionDescription, XA_STRING, 8, "", 0);
xchangeProperty (windowH, atoms->XdndAware, XA_ATOM, 32, &atoms->DndVersion, 1);
initialisePointerMap();
updateModifierMappings();
}
void destroyWindow()
{
ScopedXLock xlock (display);
XPointer handlePointer;
if (keyProxy != 0)
deleteKeyProxy();
if (! XFindContext (display, (XID) windowH, windowHandleXContext, &handlePointer))
XDeleteContext (display, (XID) windowH, windowHandleXContext);
XDestroyWindow (display, windowH);
// Wait for it to complete and then remove any events for this
// window from the event queue.
XSync (display, false);
XEvent event;
while (XCheckWindowEvent (display, windowH, getAllEventsMask(), &event) == True)
{}
}
int getAllEventsMask() const noexcept
{
return NoEventMask | KeyPressMask | KeyReleaseMask
| EnterWindowMask | LeaveWindowMask | PointerMotionMask | KeymapStateMask
| ExposureMask | StructureNotifyMask | FocusChangeMask
| ((styleFlags & windowIgnoresMouseClicks) != 0 ? 0 : (ButtonPressMask | ButtonReleaseMask));
}
template <typename EventType>
static int64 getEventTime (const EventType& t)
{
return getEventTime (t.time);
}
static int64 getEventTime (::Time t)
{
static int64 eventTimeOffset = 0x12345678;
auto thisMessageTime = (int64) t;
if (eventTimeOffset == 0x12345678)
eventTimeOffset = Time::currentTimeMillis() - thisMessageTime;
return eventTimeOffset + thisMessageTime;
}
long getUserTime() const
{
GetXProperty prop (display, windowH, atoms->userTime, 0, 65536, false, XA_CARDINAL);
return prop.success ? *(long*) prop.data : 0;
}
void updateBorderSize()
{
if ((styleFlags & windowHasTitleBar) == 0)
{
windowBorder = BorderSize<int> (0);
}
else if (windowBorder.getTopAndBottom() == 0 && windowBorder.getLeftAndRight() == 0)
{
ScopedXLock xlock (display);
Atom hints = Atoms::getIfExists (display, "_NET_FRAME_EXTENTS");
if (hints != None)
{
GetXProperty prop (display, windowH, hints, 0, 4, false, XA_CARDINAL);
if (prop.success && prop.actualFormat == 32)
{
auto* sizes = (const unsigned long*) prop.data;
windowBorder = BorderSize<int> ((int) sizes[2], (int) sizes[0],
(int) sizes[3], (int) sizes[1]);
}
}
}
}
void updateWindowBounds()
{
jassert (windowH != 0);
if (windowH != 0)
{
Window root, child;
int wx = 0, wy = 0;
unsigned int ww = 0, wh = 0, bw, bitDepth;
ScopedXLock xlock (display);
if (XGetGeometry (display, (::Drawable) windowH, &root, &wx, &wy, &ww, &wh, &bw, &bitDepth))
if (! XTranslateCoordinates (display, windowH, root, 0, 0, &wx, &wy, &child))
wx = wy = 0;
Rectangle<int> physicalBounds (wx, wy, (int) ww, (int) wh);
auto& displays = Desktop::getInstance().getDisplays();
auto newScaleFactor = displays.findDisplayForRect (physicalBounds, true).scale;
if (! approximatelyEqual (newScaleFactor, currentScaleFactor))
{
currentScaleFactor = newScaleFactor;
scaleFactorListeners.call ([&] (ScaleFactorListener& l) { l.nativeScaleFactorChanged (currentScaleFactor); });
}
bounds = displays.physicalToLogical (physicalBounds);
}
}
//==============================================================================
struct DragState
{
DragState (::Display* d)
{
if (isText)
allowedTypes.add (Atoms::getCreating (d, "text/plain"));
else
allowedTypes.add (Atoms::getCreating (d, "text/uri-list"));
}
bool isText = false;
bool dragging = false; // currently performing outgoing external dnd as Xdnd source, have grabbed mouse
bool expectingStatus = false; // XdndPosition sent, waiting for XdndStatus
bool canDrop = false; // target window signals it will accept the drop
Window targetWindow = None; // potential drop target
int xdndVersion = -1; // negotiated version with target
Rectangle<int> silentRect;
String textOrFiles;
Array<Atom> allowedTypes;
std::function<void()> completionCallback;
};
//==============================================================================
void resetDragAndDrop()
{
dragInfo.clear();
dragInfo.position = Point<int> (-1, -1);
dragAndDropCurrentMimeType = 0;
dragAndDropSourceWindow = 0;
srcMimeTypeAtomList.clear();
finishAfterDropDataReceived = false;
}
void resetExternalDragState()
{
dragState.reset (new DragState (display));
}
void sendDragAndDropMessage (XClientMessageEvent& msg)
{
msg.type = ClientMessage;
msg.display = display;
msg.window = dragAndDropSourceWindow;
msg.format = 32;
msg.data.l[0] = (long) windowH;
ScopedXLock xlock (display);
XSendEvent (display, dragAndDropSourceWindow, False, 0, (XEvent*) &msg);
}
bool sendExternalDragAndDropMessage (XClientMessageEvent& msg, Window targetWindow)
{
msg.type = ClientMessage;
msg.display = display;
msg.window = targetWindow;
msg.format = 32;
msg.data.l[0] = (long) windowH;
ScopedXLock xlock (display);
return XSendEvent (display, targetWindow, False, 0, (XEvent*) &msg) != 0;
}
void sendExternalDragAndDropDrop (Window targetWindow)
{
XClientMessageEvent msg;
zerostruct (msg);
msg.message_type = atoms->XdndDrop;
msg.data.l[2] = CurrentTime;
sendExternalDragAndDropMessage (msg, targetWindow);
}
void sendExternalDragAndDropEnter (Window targetWindow)
{
XClientMessageEvent msg;
zerostruct (msg);
msg.message_type = atoms->XdndEnter;
msg.data.l[1] = (dragState->xdndVersion << 24);
for (int i = 0; i < 3; ++i)
msg.data.l[i + 2] = (long) dragState->allowedTypes[i];
sendExternalDragAndDropMessage (msg, targetWindow);
}
void sendExternalDragAndDropPosition (Window targetWindow)
{
XClientMessageEvent msg;
zerostruct (msg);
msg.message_type = atoms->XdndPosition;
Point<int> mousePos (Desktop::getInstance().getMousePosition());
if (dragState->silentRect.contains (mousePos)) // we've been asked to keep silent
return;
auto& displays = Desktop::getInstance().getDisplays();
mousePos = displays.logicalToPhysical (mousePos);
msg.data.l[1] = 0;
msg.data.l[2] = (mousePos.x << 16) | mousePos.y;
msg.data.l[3] = CurrentTime;
msg.data.l[4] = (long) atoms->XdndActionCopy; // this is all JUCE currently supports
dragState->expectingStatus = sendExternalDragAndDropMessage (msg, targetWindow);
}
void sendDragAndDropStatus (bool acceptDrop, Atom dropAction)
{
XClientMessageEvent msg;
zerostruct (msg);
msg.message_type = atoms->XdndStatus;
msg.data.l[1] = (acceptDrop ? 1 : 0) | 2; // 2 indicates that we want to receive position messages
msg.data.l[4] = (long) dropAction;
sendDragAndDropMessage (msg);
}
void sendExternalDragAndDropLeave (Window targetWindow)
{
XClientMessageEvent msg;
zerostruct (msg);
msg.message_type = atoms->XdndLeave;
sendExternalDragAndDropMessage (msg, targetWindow);
}
void sendDragAndDropFinish()
{
XClientMessageEvent msg;
zerostruct (msg);
msg.message_type = atoms->XdndFinished;
sendDragAndDropMessage (msg);
}
void handleExternalSelectionClear()
{
if (dragState->dragging)
externalResetDragAndDrop();
}
void handleExternalSelectionRequest (const XEvent& evt)
{
Atom targetType = evt.xselectionrequest.target;
XEvent s;
s.xselection.type = SelectionNotify;
s.xselection.requestor = evt.xselectionrequest.requestor;
s.xselection.selection = evt.xselectionrequest.selection;
s.xselection.target = targetType;
s.xselection.property = None;
s.xselection.time = evt.xselectionrequest.time;
if (dragState->allowedTypes.contains (targetType))
{
s.xselection.property = evt.xselectionrequest.property;
xchangeProperty (evt.xselectionrequest.requestor,
evt.xselectionrequest.property,
targetType, 8,
dragState->textOrFiles.toRawUTF8(),
(int) dragState->textOrFiles.getNumBytesAsUTF8());
}
XSendEvent (display, evt.xselectionrequest.requestor, True, 0, &s);
}
void handleExternalDragAndDropStatus (const XClientMessageEvent& clientMsg)
{
if (dragState->expectingStatus)
{
dragState->expectingStatus = false;
dragState->canDrop = false;
dragState->silentRect = Rectangle<int>();
if ((clientMsg.data.l[1] & 1) != 0
&& ((Atom) clientMsg.data.l[4] == atoms->XdndActionCopy
|| (Atom) clientMsg.data.l[4] == atoms->XdndActionPrivate))
{
if ((clientMsg.data.l[1] & 2) == 0) // target requests silent rectangle
dragState->silentRect.setBounds ((int) clientMsg.data.l[2] >> 16,
(int) clientMsg.data.l[2] & 0xffff,
(int) clientMsg.data.l[3] >> 16,
(int) clientMsg.data.l[3] & 0xffff);
dragState->canDrop = true;
}
}
}
void handleExternalDragButtonReleaseEvent()
{
if (dragState->dragging)
XUngrabPointer (display, CurrentTime);
if (dragState->canDrop)
{
sendExternalDragAndDropDrop (dragState->targetWindow);
}
else
{
sendExternalDragAndDropLeave (dragState->targetWindow);
externalResetDragAndDrop();
}
}
void handleExternalDragMotionNotify()
{
Window targetWindow = externalFindDragTargetWindow (RootWindow (display, DefaultScreen (display)));
if (dragState->targetWindow != targetWindow)
{
if (dragState->targetWindow != None)
sendExternalDragAndDropLeave (dragState->targetWindow);
dragState->canDrop = false;
dragState->silentRect = Rectangle<int>();
if (targetWindow == None)
return;
GetXProperty prop (display, targetWindow, atoms->XdndAware,
0, 2, false, AnyPropertyType);
if (prop.success
&& prop.data != None
&& prop.actualFormat == 32
&& prop.numItems == 1)
{
dragState->xdndVersion = jmin ((int) prop.data[0], (int) atoms->DndVersion);
}
else
{
dragState->xdndVersion = -1;
return;
}
sendExternalDragAndDropEnter (targetWindow);
dragState->targetWindow = targetWindow;
}
if (! dragState->expectingStatus)
sendExternalDragAndDropPosition (targetWindow);
}
void handleDragAndDropPosition (const XClientMessageEvent& clientMsg)
{
if (dragAndDropSourceWindow == 0)
return;
dragAndDropSourceWindow = (::Window) clientMsg.data.l[0];
Point<int> dropPos ((int) clientMsg.data.l[2] >> 16,
(int) clientMsg.data.l[2] & 0xffff);
dropPos -= bounds.getPosition();
Atom targetAction = atoms->XdndActionCopy;
for (int i = numElementsInArray (atoms->allowedActions); --i >= 0;)
{
if ((Atom) clientMsg.data.l[4] == atoms->allowedActions[i])
{
targetAction = atoms->allowedActions[i];
break;
}
}
sendDragAndDropStatus (true, targetAction);
if (dragInfo.position != dropPos)
{
dragInfo.position = dropPos;
if (dragInfo.isEmpty())
updateDraggedFileList (clientMsg);
if (! dragInfo.isEmpty())
handleDragMove (dragInfo);
}
}
void handleDragAndDropDrop (const XClientMessageEvent& clientMsg)
{
if (dragInfo.isEmpty())
{
// no data, transaction finished in handleDragAndDropSelection()
finishAfterDropDataReceived = true;
updateDraggedFileList (clientMsg);
}
else
{
handleDragAndDropDataReceived(); // data was already received
}
}
void handleDragAndDropDataReceived()
{
DragInfo dragInfoCopy (dragInfo);
sendDragAndDropFinish();
resetDragAndDrop();
if (! dragInfoCopy.isEmpty())
handleDragDrop (dragInfoCopy);
}
void handleDragAndDropEnter (const XClientMessageEvent& clientMsg)
{
dragInfo.clear();
srcMimeTypeAtomList.clear();
dragAndDropCurrentMimeType = 0;
auto dndCurrentVersion = static_cast<unsigned long> (clientMsg.data.l[1] & 0xff000000) >> 24;
if (dndCurrentVersion < 3 || dndCurrentVersion > Atoms::DndVersion)
{
dragAndDropSourceWindow = 0;
return;
}
dragAndDropSourceWindow = (::Window) clientMsg.data.l[0];
if ((clientMsg.data.l[1] & 1) != 0)
{
ScopedXLock xlock (display);
GetXProperty prop (display, dragAndDropSourceWindow, atoms->XdndTypeList, 0, 0x8000000L, false, XA_ATOM);
if (prop.success
&& prop.actualType == XA_ATOM
&& prop.actualFormat == 32
&& prop.numItems != 0)
{
auto* types = (const unsigned long*) prop.data;
for (unsigned long i = 0; i < prop.numItems; ++i)
if (types[i] != None)
srcMimeTypeAtomList.add (types[i]);
}
}
if (srcMimeTypeAtomList.isEmpty())
{
for (int i = 2; i < 5; ++i)
if (clientMsg.data.l[i] != None)
srcMimeTypeAtomList.add ((unsigned long) clientMsg.data.l[i]);
if (srcMimeTypeAtomList.isEmpty())
{
dragAndDropSourceWindow = 0;
return;
}
}
for (int i = 0; i < srcMimeTypeAtomList.size() && dragAndDropCurrentMimeType == 0; ++i)
for (int j = 0; j < numElementsInArray (atoms->allowedMimeTypes); ++j)
if (srcMimeTypeAtomList[i] == atoms->allowedMimeTypes[j])
dragAndDropCurrentMimeType = atoms->allowedMimeTypes[j];
handleDragAndDropPosition (clientMsg);
}
void handleDragAndDropSelection (const XEvent& evt)
{
dragInfo.clear();
if (evt.xselection.property != None)
{
StringArray lines;
{
MemoryBlock dropData;
for (;;)
{
GetXProperty prop (display, evt.xany.window, evt.xselection.property,
dropData.getSize() / 4, 65536, false, AnyPropertyType);
if (! prop.success)
break;
dropData.append (prop.data, prop.numItems * (size_t) prop.actualFormat / 8);
if (prop.bytesLeft <= 0)
break;
}
lines.addLines (dropData.toString());
}
if (Atoms::isMimeTypeFile (display, dragAndDropCurrentMimeType))
{
for (int i = 0; i < lines.size(); ++i)
dragInfo.files.add (URL::removeEscapeChars (lines[i].replace ("file://", String(), true)));
dragInfo.files.trim();
dragInfo.files.removeEmptyStrings();
}
else
{
dragInfo.text = lines.joinIntoString ("\n");
}
if (finishAfterDropDataReceived)
handleDragAndDropDataReceived();
}
}
void updateDraggedFileList (const XClientMessageEvent& clientMsg)
{
jassert (dragInfo.isEmpty());
if (dragAndDropSourceWindow != None
&& dragAndDropCurrentMimeType != None)
{
ScopedXLock xlock (display);
XConvertSelection (display,
atoms->XdndSelection,
dragAndDropCurrentMimeType,
Atoms::getCreating (display, "JXSelectionWindowProperty"),
windowH,
(::Time) clientMsg.data.l[2]);
}
}
bool isWindowDnDAware (Window w) const
{
int numProperties = 0;
auto* properties = XListProperties (display, w, &numProperties);
bool dndAwarePropFound = false;
for (int i = 0; i < numProperties; ++i)
if (properties[i] == atoms->XdndAware)
dndAwarePropFound = true;
if (properties != nullptr)
XFree (properties);
return dndAwarePropFound;
}
Window externalFindDragTargetWindow (Window targetWindow)
{
if (targetWindow == None)
return None;
if (isWindowDnDAware (targetWindow))
return targetWindow;
Window child, phonyWin;
int phony;
unsigned int uphony;
XQueryPointer (display, targetWindow, &phonyWin, &child,
&phony, &phony, &phony, &phony, &uphony);
return externalFindDragTargetWindow (child);
}
bool externalDragInit (bool isText, const String& textOrFiles, std::function<void()> cb)
{
ScopedXLock xlock (display);
resetExternalDragState();
dragState->isText = isText;
dragState->textOrFiles = textOrFiles;
dragState->targetWindow = windowH;
dragState->completionCallback = cb;
const int pointerGrabMask = Button1MotionMask | ButtonReleaseMask;
if (XGrabPointer (display, windowH, True, pointerGrabMask,
GrabModeAsync, GrabModeAsync, None, None, CurrentTime) == GrabSuccess)
{
// No other method of changing the pointer seems to work, this call is needed from this very context
XChangeActivePointerGrab (display, pointerGrabMask, (Cursor) createDraggingHandCursor(), CurrentTime);
XSetSelectionOwner (display, atoms->XdndSelection, windowH, CurrentTime);
// save the available types to XdndTypeList
xchangeProperty (windowH, atoms->XdndTypeList, XA_ATOM, 32,
dragState->allowedTypes.getRawDataPointer(),
dragState->allowedTypes.size());
dragState->dragging = true;
handleExternalDragMotionNotify();
return true;
}
return false;
}
void externalResetDragAndDrop()
{
if (dragState->dragging)
{
ScopedXLock xlock (display);
XUngrabPointer (display, CurrentTime);
}
if (dragState->completionCallback != nullptr)
dragState->completionCallback();
resetExternalDragState();
}
std::unique_ptr<DragState> dragState;
DragInfo dragInfo;
Atom dragAndDropCurrentMimeType;
Window dragAndDropSourceWindow;
bool finishAfterDropDataReceived;
Array<Atom> srcMimeTypeAtomList;
int pointerMap[5] = {};
void initialisePointerMap()
{
const int numButtons = XGetPointerMapping (display, 0, 0);
pointerMap[2] = pointerMap[3] = pointerMap[4] = Keys::NoButton;
if (numButtons == 2)
{
pointerMap[0] = Keys::LeftButton;
pointerMap[1] = Keys::RightButton;
}
else if (numButtons >= 3)
{
pointerMap[0] = Keys::LeftButton;
pointerMap[1] = Keys::MiddleButton;
pointerMap[2] = Keys::RightButton;
if (numButtons >= 5)
{
pointerMap[3] = Keys::WheelUp;
pointerMap[4] = Keys::WheelDown;
}
}
}
static Point<int> lastMousePos;
static void clearLastMousePos() noexcept
{
lastMousePos = Point<int> (0x100000, 0x100000);
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LinuxComponentPeer)
};
bool LinuxComponentPeer::isActiveApplication = false;
Point<int> LinuxComponentPeer::lastMousePos;
::Display* LinuxComponentPeer::display = nullptr;
//==============================================================================
namespace WindowingHelpers
{
static void windowMessageReceive (XEvent& event)
{
if (event.xany.window != None)
{
#if JUCE_X11_SUPPORTS_XEMBED
if (! juce_handleXEmbedEvent (nullptr, &event))
#endif
{
if (auto* peer = LinuxComponentPeer::getPeerFor (event.xany.window))
peer->handleWindowMessage (event);
}
}
else if (event.xany.type == KeymapNotify)
{
auto& keymapEvent = (const XKeymapEvent&) event.xkeymap;
memcpy (Keys::keyStates, keymapEvent.key_vector, 32);
}
}
}
struct WindowingCallbackInitialiser
{
WindowingCallbackInitialiser()
{
dispatchWindowMessage = WindowingHelpers::windowMessageReceive;
}
};
static WindowingCallbackInitialiser windowingInitialiser;
//==============================================================================
JUCE_API bool JUCE_CALLTYPE Process::isForegroundProcess()
{
return LinuxComponentPeer::isActiveApplication;
}
// N/A on Linux as far as I know.
JUCE_API void JUCE_CALLTYPE Process::makeForegroundProcess() {}
JUCE_API void JUCE_CALLTYPE Process::hide() {}
//==============================================================================
void Desktop::setKioskComponent (Component* comp, bool enableOrDisable, bool /* allowMenusAndBars */)
{
if (enableOrDisable)
comp->setBounds (getDisplays().getMainDisplay().totalArea);
}
void Desktop::allowedOrientationsChanged() {}
//==============================================================================
ComponentPeer* Component::createNewPeer (int styleFlags, void* nativeWindowToAttachTo)
{
return new LinuxComponentPeer (*this, styleFlags, (Window) nativeWindowToAttachTo);
}
//==============================================================================
void Displays::findDisplays (float masterScale)
{
ScopedXDisplay xDisplay;
if (auto display = xDisplay.display)
{
#if JUCE_USE_XRANDR
{
int major_opcode, first_event, first_error;
if (XQueryExtension (display, "RANDR", &major_opcode, &first_event, &first_error))
{
auto& xrandr = XRandrWrapper::getInstance();
auto numMonitors = ScreenCount (display);
auto mainDisplay = xrandr.getOutputPrimary (display, RootWindow (display, 0));
for (int i = 0; i < numMonitors; ++i)
{
if (auto* screens = xrandr.getScreenResources (display, RootWindow (display, i)))
{
for (int j = 0; j < screens->noutput; ++j)
{
if (screens->outputs[j])
{
// Xrandr on the raspberry pi fails to determine the main display (mainDisplay == 0)!
// Detect this edge case and make the first found display the main display
if (! mainDisplay)
mainDisplay = screens->outputs[j];
if (auto* output = xrandr.getOutputInfo (display, screens, screens->outputs[j]))
{
if (output->crtc)
{
if (auto* crtc = xrandr.getCrtcInfo (display, screens, output->crtc))
{
Display d;
d.totalArea = Rectangle<int> (crtc->x, crtc->y,
(int) crtc->width, (int) crtc->height);
d.isMain = (mainDisplay == screens->outputs[j]) && (i == 0);
d.dpi = getDisplayDPI (display, 0);
// The raspberry pi returns a zero sized display, so we need to guard for divide-by-zero
if (output->mm_width > 0 && output->mm_height > 0)
d.dpi = ((static_cast<double> (crtc->width) * 25.4 * 0.5) / static_cast<double> (output->mm_width))
+ ((static_cast<double> (crtc->height) * 25.4 * 0.5) / static_cast<double> (output->mm_height));
double scale = getScaleForDisplay (output->name, d.dpi);
scale = (scale <= 0.1 ? 1.0 : scale);
d.scale = masterScale * scale;
if (d.isMain)
displays.insert (0, d);
else
displays.add (d);
xrandr.freeCrtcInfo (crtc);
}
}
xrandr.freeOutputInfo (output);
}
}
}
xrandr.freeScreenResources (screens);
}
}
}
}
if (displays.isEmpty())
#endif
#if JUCE_USE_XINERAMA
{
auto screens = XineramaQueryDisplays (display);
int numMonitors = screens.size();
for (int index = 0; index < numMonitors; ++index)
{
for (int j = numMonitors; --j >= 0;)
{
if (screens[j].screen_number == index)
{
Display d;
d.totalArea = Rectangle<int> (screens[j].x_org,
screens[j].y_org,
screens[j].width,
screens[j].height);
d.isMain = (index == 0);
d.scale = masterScale;
d.dpi = getDisplayDPI (display, 0); // (all screens share the same DPI)
displays.add (d);
}
}
}
}
if (displays.isEmpty())
#endif
{
Atom hints = Atoms::getIfExists (display, "_NET_WORKAREA");
if (hints != None)
{
auto numMonitors = ScreenCount (display);
for (int i = 0; i < numMonitors; ++i)
{
GetXProperty prop (display, RootWindow (display, i), hints, 0, 4, false, XA_CARDINAL);
if (prop.success && prop.actualType == XA_CARDINAL && prop.actualFormat == 32 && prop.numItems == 4)
{
auto position = (const long*) prop.data;
Display d;
d.totalArea = Rectangle<int> ((int) position[0], (int) position[1],
(int) position[2], (int) position[3]);
d.isMain = displays.isEmpty();
d.scale = masterScale;
d.dpi = getDisplayDPI (display, i);
displays.add (d);
}
}
}
if (displays.isEmpty())
{
Display d;
d.totalArea = Rectangle<int> (DisplayWidth (display, DefaultScreen (display)),
DisplayHeight (display, DefaultScreen (display)));
d.isMain = true;
d.scale = masterScale;
d.dpi = getDisplayDPI (display, 0);
displays.add (d);
}
}
for (auto& d : displays)
d.userArea = d.totalArea; // JUCE currently does not support requesting the user area on Linux
updateToLogical();
}
}
//==============================================================================
bool MouseInputSource::SourceList::addSource()
{
if (sources.isEmpty())
{
addSource (0, MouseInputSource::InputSourceType::mouse);
return true;
}
return false;
}
bool MouseInputSource::SourceList::canUseTouch()
{
return false;
}
bool Desktop::canUseSemiTransparentWindows() noexcept
{
#if JUCE_USE_XRENDER
if (XRender::hasCompositingWindowManager())
{
int matchedDepth = 0, desiredDepth = 32;
return Visuals::findVisualFormat (display, desiredDepth, matchedDepth) != 0
&& matchedDepth == desiredDepth;
}
#endif
return false;
}
Point<float> MouseInputSource::getCurrentRawMousePosition()
{
ScopedXDisplay xDisplay;
auto display = xDisplay.display;
if (display == nullptr)
return {};
Window root, child;
int x, y, winx, winy;
unsigned int mask;
ScopedXLock xlock (display);
if (XQueryPointer (display,
RootWindow (display, DefaultScreen (display)),
&root, &child,
&x, &y, &winx, &winy, &mask) == False)
{
// Pointer not on the default screen
x = y = -1;
}
return Desktop::getInstance().getDisplays().physicalToLogical (Point<float> ((float) x, (float) y));
}
void MouseInputSource::setRawMousePosition (Point<float> newPosition)
{
ScopedXDisplay xDisplay;
if (auto display = xDisplay.display)
{
ScopedXLock xlock (display);
Window root = RootWindow (display, DefaultScreen (display));
newPosition = Desktop::getInstance().getDisplays().logicalToPhysical (newPosition);
XWarpPointer (display, None, root, 0, 0, 0, 0, roundToInt (newPosition.getX()), roundToInt (newPosition.getY()));
}
}
double Desktop::getDefaultMasterScale()
{
return 1.0;
}
Desktop::DisplayOrientation Desktop::getCurrentOrientation() const
{
return upright;
}
//==============================================================================
static bool screenSaverAllowed = true;
void Desktop::setScreenSaverEnabled (bool isEnabled)
{
if (screenSaverAllowed != isEnabled)
{
screenSaverAllowed = isEnabled;
ScopedXDisplay xDisplay;
if (auto display = xDisplay.display)
{
typedef void (*tXScreenSaverSuspend) (Display*, Bool);
static tXScreenSaverSuspend xScreenSaverSuspend = nullptr;
if (xScreenSaverSuspend == nullptr)
if (void* h = dlopen ("libXss.so.1", RTLD_GLOBAL | RTLD_NOW))
xScreenSaverSuspend = (tXScreenSaverSuspend) dlsym (h, "XScreenSaverSuspend");
ScopedXLock xlock (display);
if (xScreenSaverSuspend != nullptr)
xScreenSaverSuspend (display, ! isEnabled);
}
}
}
bool Desktop::isScreenSaverEnabled()
{
return screenSaverAllowed;
}
//==============================================================================
Image juce_createIconForFile (const File& /* file */)
{
return {};
}
//==============================================================================
void LookAndFeel::playAlertSound()
{
std::cout << "\a" << std::flush;
}
//==============================================================================
Rectangle<int> juce_LinuxScaledToPhysicalBounds (ComponentPeer* peer, Rectangle<int> bounds)
{
if (auto* linuxPeer = dynamic_cast<LinuxComponentPeer*> (peer))
bounds *= linuxPeer->getPlatformScaleFactor();
return bounds;
}
void juce_LinuxAddRepaintListener (ComponentPeer* peer, Component* dummy)
{
if (auto* linuxPeer = dynamic_cast<LinuxComponentPeer*> (peer))
linuxPeer->addOpenGLRepaintListener (dummy);
}
void juce_LinuxRemoveRepaintListener (ComponentPeer* peer, Component* dummy)
{
if (auto* linuxPeer = dynamic_cast<LinuxComponentPeer*> (peer))
linuxPeer->removeOpenGLRepaintListener (dummy);
}
unsigned long juce_createKeyProxyWindow (ComponentPeer* peer)
{
if (auto* linuxPeer = dynamic_cast<LinuxComponentPeer*> (peer))
return linuxPeer->createKeyProxy();
return 0;
}
void juce_deleteKeyProxyWindow (ComponentPeer* peer)
{
if (auto* linuxPeer = dynamic_cast<LinuxComponentPeer*> (peer))
linuxPeer->deleteKeyProxy();
}
//==============================================================================
#if JUCE_MODAL_LOOPS_PERMITTED
void JUCE_CALLTYPE NativeMessageBox::showMessageBox (AlertWindow::AlertIconType iconType,
const String& title, const String& message,
Component* /* associatedComponent */)
{
AlertWindow::showMessageBox (iconType, title, message);
}
#endif
void JUCE_CALLTYPE NativeMessageBox::showMessageBoxAsync (AlertWindow::AlertIconType iconType,
const String& title, const String& message,
Component* associatedComponent,
ModalComponentManager::Callback* callback)
{
AlertWindow::showMessageBoxAsync (iconType, title, message, String(), associatedComponent, callback);
}
bool JUCE_CALLTYPE NativeMessageBox::showOkCancelBox (AlertWindow::AlertIconType iconType,
const String& title, const String& message,
Component* associatedComponent,
ModalComponentManager::Callback* callback)
{
return AlertWindow::showOkCancelBox (iconType, title, message, String(), String(),
associatedComponent, callback);
}
int JUCE_CALLTYPE NativeMessageBox::showYesNoCancelBox (AlertWindow::AlertIconType iconType,
const String& title, const String& message,
Component* associatedComponent,
ModalComponentManager::Callback* callback)
{
return AlertWindow::showYesNoCancelBox (iconType, title, message,
String(), String(), String(),
associatedComponent, callback);
}
int JUCE_CALLTYPE NativeMessageBox::showYesNoBox (AlertWindow::AlertIconType iconType,
const String& title, const String& message,
Component* associatedComponent,
ModalComponentManager::Callback* callback)
{
return AlertWindow::showOkCancelBox (iconType, title, message, TRANS ("Yes"), TRANS ("No"),
associatedComponent, callback);
}
//============================== X11 - MouseCursor =============================
void* CustomMouseCursorInfo::create() const
{
ScopedXDisplay xDisplay;
auto display = xDisplay.display;
if (display == nullptr)
return nullptr;
ScopedXLock xlock (display);
auto imageW = (unsigned int) image.getWidth();
auto imageH = (unsigned int) image.getHeight();
int hotspotX = hotspot.x;
int hotspotY = hotspot.y;
#if JUCE_USE_XCURSOR
{
using tXcursorSupportsARGB = XcursorBool (*) (Display*);
using tXcursorImageCreate = XcursorImage* (*) (int, int);
using tXcursorImageDestroy = void (*) (XcursorImage*);
using tXcursorImageLoadCursor = Cursor (*) (Display*, const XcursorImage*);
static tXcursorSupportsARGB xcursorSupportsARGB = nullptr;
static tXcursorImageCreate xcursorImageCreate = nullptr;
static tXcursorImageDestroy xcursorImageDestroy = nullptr;
static tXcursorImageLoadCursor xcursorImageLoadCursor = nullptr;
static bool hasBeenLoaded = false;
if (! hasBeenLoaded)
{
hasBeenLoaded = true;
if (void* h = dlopen ("libXcursor.so.1", RTLD_GLOBAL | RTLD_NOW))
{
xcursorSupportsARGB = (tXcursorSupportsARGB) dlsym (h, "XcursorSupportsARGB");
xcursorImageCreate = (tXcursorImageCreate) dlsym (h, "XcursorImageCreate");
xcursorImageLoadCursor = (tXcursorImageLoadCursor) dlsym (h, "XcursorImageLoadCursor");
xcursorImageDestroy = (tXcursorImageDestroy) dlsym (h, "XcursorImageDestroy");
if (xcursorSupportsARGB == nullptr || xcursorImageCreate == nullptr
|| xcursorImageLoadCursor == nullptr || xcursorImageDestroy == nullptr
|| ! xcursorSupportsARGB (display))
xcursorSupportsARGB = nullptr;
}
}
if (xcursorSupportsARGB != nullptr)
{
if (XcursorImage* xcImage = xcursorImageCreate ((int) imageW, (int) imageH))
{
xcImage->xhot = (XcursorDim) hotspotX;
xcImage->yhot = (XcursorDim) hotspotY;
XcursorPixel* dest = xcImage->pixels;
for (int y = 0; y < (int) imageH; ++y)
for (int x = 0; x < (int) imageW; ++x)
*dest++ = image.getPixelAt (x, y).getARGB();
void* result = (void*) xcursorImageLoadCursor (display, xcImage);
xcursorImageDestroy (xcImage);
if (result != nullptr)
return result;
}
}
}
#endif
Window root = RootWindow (display, DefaultScreen (display));
unsigned int cursorW, cursorH;
if (! XQueryBestCursor (display, root, imageW, imageH, &cursorW, &cursorH))
return nullptr;
Image im (Image::ARGB, (int) cursorW, (int) cursorH, true);
{
Graphics g (im);
if (imageW > cursorW || imageH > cursorH)
{
hotspotX = (hotspotX * (int) cursorW) / (int) imageW;
hotspotY = (hotspotY * (int) cursorH) / (int) imageH;
g.drawImage (image, Rectangle<float> ((float) imageW, (float) imageH),
RectanglePlacement::xLeft | RectanglePlacement::yTop | RectanglePlacement::onlyReduceInSize);
}
else
{
g.drawImageAt (image, 0, 0);
}
}
const unsigned int stride = (cursorW + 7) >> 3;
HeapBlock<char> maskPlane, sourcePlane;
maskPlane.calloc (stride * cursorH);
sourcePlane.calloc (stride * cursorH);
const bool msbfirst = (BitmapBitOrder (display) == MSBFirst);
for (int y = (int) cursorH; --y >= 0;)
{
for (int x = (int) cursorW; --x >= 0;)
{
auto mask = (char) (1 << (msbfirst ? (7 - (x & 7)) : (x & 7)));
auto offset = (unsigned int) y * stride + ((unsigned int) x >> 3);
auto c = im.getPixelAt (x, y);
if (c.getAlpha() >= 128) maskPlane[offset] |= mask;
if (c.getBrightness() >= 0.5f) sourcePlane[offset] |= mask;
}
}
Pixmap sourcePixmap = XCreatePixmapFromBitmapData (display, root, sourcePlane.getData(), cursorW, cursorH, 0xffff, 0, 1);
Pixmap maskPixmap = XCreatePixmapFromBitmapData (display, root, maskPlane.getData(), cursorW, cursorH, 0xffff, 0, 1);
XColor white, black;
black.red = black.green = black.blue = 0;
white.red = white.green = white.blue = 0xffff;
void* result = (void*) XCreatePixmapCursor (display, sourcePixmap, maskPixmap, &white, &black,
(unsigned int) hotspotX, (unsigned int) hotspotY);
XFreePixmap (display, sourcePixmap);
XFreePixmap (display, maskPixmap);
return result;
}
void MouseCursor::deleteMouseCursor (void* cursorHandle, bool)
{
if (cursorHandle != nullptr)
{
ScopedXDisplay xDisplay;
if (auto display = xDisplay.display)
{
ScopedXLock xlock (display);
XFreeCursor (display, (Cursor) cursorHandle);
}
}
}
void* MouseCursor::createStandardMouseCursor (MouseCursor::StandardCursorType type)
{
ScopedXDisplay xDisplay;
auto display = xDisplay.display;
if (display == nullptr)
return None;
unsigned int shape;
switch (type)
{
case NormalCursor:
case ParentCursor: return None; // Use parent cursor
case NoCursor: return CustomMouseCursorInfo (Image (Image::ARGB, 16, 16, true), {}).create();
case WaitCursor: shape = XC_watch; break;
case IBeamCursor: shape = XC_xterm; break;
case PointingHandCursor: shape = XC_hand2; break;
case LeftRightResizeCursor: shape = XC_sb_h_double_arrow; break;
case UpDownResizeCursor: shape = XC_sb_v_double_arrow; break;
case UpDownLeftRightResizeCursor: shape = XC_fleur; break;
case TopEdgeResizeCursor: shape = XC_top_side; break;
case BottomEdgeResizeCursor: shape = XC_bottom_side; break;
case LeftEdgeResizeCursor: shape = XC_left_side; break;
case RightEdgeResizeCursor: shape = XC_right_side; break;
case TopLeftCornerResizeCursor: shape = XC_top_left_corner; break;
case TopRightCornerResizeCursor: shape = XC_top_right_corner; break;
case BottomLeftCornerResizeCursor: shape = XC_bottom_left_corner; break;
case BottomRightCornerResizeCursor: shape = XC_bottom_right_corner; break;
case CrosshairCursor: shape = XC_crosshair; break;
case DraggingHandCursor: return createDraggingHandCursor();
case CopyingCursor:
{
static unsigned char copyCursorData[] = { 71,73,70,56,57,97,21,0,21,0,145,0,0,0,0,0,255,255,255,0,
128,128,255,255,255,33,249,4,1,0,0,3,0,44,0,0,0,0,21,0, 21,0,0,2,72,4,134,169,171,16,199,98,11,79,90,71,161,93,56,111,
78,133,218,215,137,31,82,154,100,200,86,91,202,142,12,108,212,87,235,174, 15,54,214,126,237,226,37,96,59,141,16,37,18,201,142,157,230,204,51,112,
252,114,147,74,83,5,50,68,147,208,217,16,71,149,252,124,5,0,59,0,0 };
const int copyCursorSize = 119;
return CustomMouseCursorInfo (ImageFileFormat::loadFrom (copyCursorData, copyCursorSize), { 1, 3 }).create();
}
default:
jassertfalse;
return None;
}
ScopedXLock xlock (display);
return (void*) XCreateFontCursor (display, shape);
}
void MouseCursor::showInWindow (ComponentPeer* peer) const
{
if (auto* lp = dynamic_cast<LinuxComponentPeer*> (peer))
lp->showMouseCursor ((Cursor) getHandle());
}
void MouseCursor::showInAllWindows() const
{
for (int i = ComponentPeer::getNumPeers(); --i >= 0;)
showInWindow (ComponentPeer::getPeer (i));
}
//=================================== X11 - DND ================================
static LinuxComponentPeer* getPeerForDragEvent (Component* sourceComp)
{
if (sourceComp == nullptr)
if (auto* draggingSource = Desktop::getInstance().getDraggingMouseSource(0))
sourceComp = draggingSource->getComponentUnderMouse();
if (sourceComp != nullptr)
if (auto* lp = dynamic_cast<LinuxComponentPeer*> (sourceComp->getPeer()))
return lp;
jassertfalse; // This method must be called in response to a component's mouseDown or mouseDrag event!
return nullptr;
}
bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& files, bool canMoveFiles,
Component* sourceComp, std::function<void()> callback)
{
if (files.isEmpty())
return false;
if (auto* lp = getPeerForDragEvent (sourceComp))
return lp->externalDragFileInit (files, canMoveFiles, callback);
// This method must be called in response to a component's mouseDown or mouseDrag event!
jassertfalse;
return false;
}
bool DragAndDropContainer::performExternalDragDropOfText (const String& text, Component* sourceComp,
std::function<void()> callback)
{
if (text.isEmpty())
return false;
if (auto* lp = getPeerForDragEvent (sourceComp))
return lp->externalDragTextInit (text, callback);
// This method must be called in response to a component's mouseDown or mouseDrag event!
jassertfalse;
return false;
}
} // namespace juce
| [
"pierre@osar.fr"
] | pierre@osar.fr |
2c6f7629ddf1f3f628c9bf22abed418bd84909b7 | baf8a111c8f8f40c95ab532c867d40f99ae0a8aa | /Agenda/pessoajuridica.cpp | 63f9f7467a8edbb64dba4251b8f927d901b328d9 | [] | no_license | nafash/program | 34745c220057004bc637e888d92033a10c4f40ee | afa6296e8cfbf3618df0f946db63bb0a0da44962 | refs/heads/main | 2023-07-12T19:20:06.188155 | 2021-08-20T19:30:35 | 2021-08-20T19:30:35 | 398,376,845 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,286 | cpp | #include "pessoajuridica.h"
namespace tp2 {
PessoaJuridica::PessoaJuridica():
inscricaoSocial(0),
razaoSocial(""),
CNPJ("")
{
}
PessoaJuridica::PessoaJuridica(QString nome, QString endereco, QString email, QString CNPJ, int inscricaoSocial, QString razaoSocial):
inscricaoSocial(inscricaoSocial),
razaoSocial(razaoSocial),
CNPJ(CNPJ)
{
setNome(nome);
setLocalDeMoradia(endereco);
setEmail(email);
}
void PessoaJuridica::setInscricaoSocial(int inscricaoSocial)
{
if(inscricaoSocial <= 0) throw QString("Inscrição social inválida");
this->inscricaoSocial = inscricaoSocial;
}
void PessoaJuridica::setDocumento(QString documento)
{
if(documento.size()<0)throw QString("CNPJ inválido");
CNPJ = documento;
}
QString PessoaJuridica::printf()
{
QString saida = "";
saida += pessoa::printf();
saida += "CNPJ: ";
saida += getDocumento();
saida += "\n";
saida += "CNPJ: ";
saida += QString::number(getInscricaoSocial());
saida += "\n";
saida += "Razão Social: ";
saida += getRazaoSocial();
saida += "\n";
return saida;
}
}
| [
"75043839+nafash@users.noreply.github.com"
] | 75043839+nafash@users.noreply.github.com |
ae857c7393343bd15cb55dee6006b74b01eb845b | 3b9b4049a8e7d38b49e07bb752780b2f1d792851 | /src/mash/app_driver/app_driver.cc | 24d4651f3868c513aa5dd9ad904acccedab5d97f | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | webosce/chromium53 | f8e745e91363586aee9620c609aacf15b3261540 | 9171447efcf0bb393d41d1dc877c7c13c46d8e38 | refs/heads/webosce | 2020-03-26T23:08:14.416858 | 2018-08-23T08:35:17 | 2018-09-20T14:25:18 | 145,513,343 | 0 | 2 | Apache-2.0 | 2019-08-21T22:44:55 | 2018-08-21T05:52:31 | null | UTF-8 | C++ | false | false | 4,323 | cc | // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "mash/app_driver/app_driver.h"
#include <stdint.h>
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "components/mus/common/event_matcher_util.h"
#include "mash/public/interfaces/launchable.mojom.h"
#include "services/shell/public/cpp/connection.h"
#include "services/shell/public/cpp/connector.h"
using mash::mojom::LaunchablePtr;
using mash::mojom::LaunchMode;
namespace mash {
namespace app_driver {
namespace {
enum class Accelerator : uint32_t {
NewChromeWindow,
NewChromeTab,
NewChromeIncognitoWindow,
ShowTaskManager,
};
struct AcceleratorSpec {
Accelerator id;
ui::mojom::KeyboardCode keyboard_code;
// A bitfield of kEventFlag* and kMouseEventFlag* values in
// input_event_constants.mojom.
int event_flags;
};
AcceleratorSpec g_spec[] = {
{Accelerator::NewChromeWindow, ui::mojom::KeyboardCode::N,
ui::mojom::kEventFlagControlDown},
{Accelerator::NewChromeTab, ui::mojom::KeyboardCode::T,
ui::mojom::kEventFlagControlDown},
{Accelerator::NewChromeIncognitoWindow, ui::mojom::KeyboardCode::N,
ui::mojom::kEventFlagControlDown | ui::mojom::kEventFlagShiftDown},
{Accelerator::ShowTaskManager, ui::mojom::KeyboardCode::ESCAPE,
ui::mojom::kEventFlagShiftDown},
};
void AssertTrue(bool success) {
DCHECK(success);
}
void DoNothing() {}
} // namespace
AppDriver::AppDriver()
: connector_(nullptr), binding_(this), weak_factory_(this) {}
AppDriver::~AppDriver() {}
void AppDriver::OnAvailableCatalogEntries(
mojo::Array<catalog::mojom::EntryPtr> entries) {
if (entries.empty()) {
LOG(ERROR) << "Unable to install accelerators for launching chrome.";
return;
}
mus::mojom::AcceleratorRegistrarPtr registrar;
connector_->ConnectToInterface(entries[0]->name, ®istrar);
if (binding_.is_bound())
binding_.Unbind();
registrar->SetHandler(binding_.CreateInterfacePtrAndBind());
// If the window manager restarts, the handler pipe will close and we'll need
// to re-add our accelerators when the window manager comes back up.
binding_.set_connection_error_handler(
base::Bind(&AppDriver::AddAccelerators, weak_factory_.GetWeakPtr()));
for (const AcceleratorSpec& spec : g_spec) {
registrar->AddAccelerator(
static_cast<uint32_t>(spec.id),
mus::CreateKeyMatcher(spec.keyboard_code, spec.event_flags),
base::Bind(&AssertTrue));
}
}
void AppDriver::Initialize(shell::Connector* connector,
const shell::Identity& identity,
uint32_t id) {
connector_ = connector;
AddAccelerators();
}
bool AppDriver::AcceptConnection(shell::Connection* connection) {
return true;
}
bool AppDriver::ShellConnectionLost() {
// Prevent the code in AddAccelerators() from keeping this app alive.
binding_.set_connection_error_handler(base::Bind(&DoNothing));
return true;
}
void AppDriver::OnAccelerator(uint32_t id, std::unique_ptr<ui::Event> event) {
struct LaunchOptions {
uint32_t option;
const char* app;
LaunchMode mode;
};
std::map<Accelerator, LaunchOptions> options{
{Accelerator::NewChromeWindow,
{mojom::kWindow, "exe:chrome", LaunchMode::MAKE_NEW}},
{Accelerator::NewChromeTab,
{mojom::kDocument, "exe:chrome", LaunchMode::MAKE_NEW}},
{Accelerator::NewChromeIncognitoWindow,
{mojom::kIncognitoWindow, "exe:chrome", LaunchMode::MAKE_NEW}},
{Accelerator::ShowTaskManager,
{mojom::kWindow, "mojo:task_viewer", LaunchMode::DEFAULT}},
};
const auto iter = options.find(static_cast<Accelerator>(id));
DCHECK(iter != options.end());
const LaunchOptions& entry = iter->second;
LaunchablePtr launchable;
connector_->ConnectToInterface(entry.app, &launchable);
launchable->Launch(entry.option, entry.mode);
}
void AppDriver::AddAccelerators() {
connector_->ConnectToInterface("mojo:catalog", &catalog_);
catalog_->GetEntriesProvidingClass(
"mus:window_manager", base::Bind(&AppDriver::OnAvailableCatalogEntries,
weak_factory_.GetWeakPtr()));
}
} // namespace app_driver
} // namespace mash
| [
"changhyeok.bae@lge.com"
] | changhyeok.bae@lge.com |
a827030f694e81788ff4def61f8a97d6ba9ddf55 | efed5d60bf0e4b9cca6a64dc4d5da460848eac46 | /jp2_pc/Source/Lib/Renderer/RenderType.hpp | fba6a72b015f447c017ba507c5a0dbade9d66475 | [] | no_license | Rikoshet-234/JurassicParkTrespasser | 515b2e0d967384a312d972e9e3278954a7440f63 | 42f886d99ece2054ff234c017c07e336720534d5 | refs/heads/master | 2022-04-24T01:16:37.700865 | 2020-03-28T01:21:14 | 2020-03-28T01:21:14 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 7,441 | hpp | /***********************************************************************************************
*
* Copyright © DreamWorks Interactive. 1996
*
* Contents:
* Base class for renderer's types that are within a scene.
*
* Bugs:
*
* To do:
* Replace virtual rptr_const<CBioMesh>* rpbmCast() const with the right thing.
* Move prdtFindShared from Loader.cpp to some more reasonable place.
*
***********************************************************************************************
*
* $Log:: /JP2_PC/Source/Lib/Renderer/RenderType.hpp $
*
* 14 98.09.08 2:35p Mmouni
* Made changes to support creation of non CMesh objects for invisible geometry.
*
* 13 5/14/98 8:06p Agrant
* Removed the defunct poval_renderer argument form rendertype constructor
*
* 12 10/02/97 6:13p Agrant
* CRenderType descends frim CFetchable
*
* 11 97/08/18 16:18 Speter
* Removed useless statement in ptCastRenderType.
*
* 10 97/06/23 19:25 Speter
* Changed wad of shit to rptr_const_static_cast.
*
* 9 5/15/97 7:05p Agrant
* Improved cast functionality
* a FindShared function for rendertype loading with text properties.
*
* 8 4/16/97 2:24p Agrant
* Hacked biomesh cast function
*
* 7 97/03/24 15:10 Speter
* Made camera a CInstance rather than a CRenderType.
*
* 6 97/01/26 19:52 Speter
* Changed ptGet() to ptPtrRaw() in rptr casting functions.
*
* 5 97/01/07 11:27 Speter
* Put all CRenderTypes in rptr<>.
*
* 4 11/26/96 6:28p Mlange
* The bounding volume function now returns a CBoundVol instead of a CBoundVolCompound.
*
* 3 11/23/96 5:48p Mlange
* Made the bvcGet(0 function const. The 'cast' class now also handles null pointers.
*
* 2 11/21/96 4:18p Mlange
* Added copy function. Made various things const.
*
* 1 11/21/96 12:37p Mlange
* Initial implementation.
*
**********************************************************************************************/
#ifndef HEADER_LIB_RENDERER_RENDERTYPE_HPP
#define HEADER_LIB_RENDERER_RENDERTYPE_HPP
#include "Lib/Loader/Fetchable.hpp"
#include "Lib/Transform/Vector.hpp"
//*********************************************************************************************
//
// Forward declarations for CRenderType.
//
class CLight;
class CShape;
class CMesh;
class CBioMesh;
class CBoundVol;
// For loading/creating render types in the loader....
class CGroffObjectName;
class CLoadWorld;
class CHandle;
class CObjectValue;
class CValueTable;
//*********************************************************************************************
//
class CRenderType: public CRefObj, public CFetchable
//
// Base class for the rendering types that are the elements of a scene.
//
// Prefix: rdt
//
// Notes:
//
//**************************************
{
public:
//*****************************************************************************************
//
// Constructors and destructor.
//
// Default constructor.
CRenderType()
{
}
//*****************************************************************************************
//
// Member functions.
//
//*****************************************************************************************
//
virtual const CBoundVol& bvGet
(
) const = 0;
//
// Obtain the extents.
//
// Returns:
// A bounding volume that describes the extents of this class.
//
//**********************************
//*****************************************************************************************
//
virtual rptr<CRenderType> prdtCopy
(
) = 0;
//
// Copies this, returning a unique, non-instanced object outside of the instancing system.
//
// Returns:
// A new (unique) copy of this.
//
//**************************
//*****************************************************************************************
//
virtual CVector3<> v3GetPhysicsBox
(
) const;
//
// Obtain the extents of the physics box for this thing.
//
// Returns:
// A vector that specifies the extents of the physics box.
//
//**********************************
//*****************************************************************************************
//
virtual CVector3<> v3GetPivot
(
) const;
//
// Obtain the pivot point for this thing.
//
// Returns:
// A vector that specifies the pivot point in local space.
//
//**********************************
//
// Identifier functions.
//
//*****************************************************************************************
virtual void Cast(rptr_const<CRenderType>* pprdt) const
{
*pprdt = rptr_const_this(this);
}
//*****************************************************************************************
virtual void Cast(rptr_const<CLight>* pplt) const
{
*pplt = rptr0;
}
//*****************************************************************************************
virtual void Cast(rptr_const<CShape>* ppsh) const
{
*ppsh = rptr0;
}
//*****************************************************************************************
virtual void Cast(rptr_const<CMesh>* ppsh) const
{
*ppsh = rptr0;
}
//*****************************************************************************************
virtual void Cast(rptr_const<CBioMesh>* ppsh) const
{
*ppsh = rptr0;
}
//*****************************************************************************************
// HACK HACK HACK
//
// Can't figure out how to avoid
//
// error C2664: 'Cast' : cannot convert parameter 1 from 'class rptr_const<class CBioMesh> *' to 'class rptr_const<class CShape> *'
//
virtual rptr_const<CBioMesh> rpbmCast() const
{
return rptr0;
}
public:
//*****************************************************************************************
//
static const rptr<CRenderType> prdtFindShared
(
const CGroffObjectName* pgon, // Pointer to GROFF name.
CLoadWorld* pload, // Pointer to loader.
const CHandle& h_obj, // Handle to the base object in the value table.
CValueTable* pvtable // Pointer to the value table.
);
// Obtain a RenderType that has the requested data.
//
// Notes:
// Uses the value table entries to determine what kind of render type to create.
// Instances and shares data wherever possible.
//
//**************************
};
//*********************************************************************************************
//
template<class T_TYPE> class ptCastRenderType
//
// Class that behaves like the dynamic_cast<> operator for classes derived from CRenderType.
//
// Prefix: N/A
//
// Example:
// rptr<CShape> psh;
//
// rptr<CRenderType> prdt = psh;
//
// rptr<CShape> psh = ptCastRenderType<CShape>(psh);
//
//**************************
{
rptr_const<T_TYPE> ptVal; // The return value.
public:
//*****************************************************************************************
//
// Constructors and destructors.
//
ptCastRenderType(rptr_const<CRenderType> prdt)
{
// Skip the cast function call if a null pointer is passed.
if (prdt != 0)
prdt->Cast(&ptVal);
}
//*****************************************************************************************
//
// Overloaded operators.
//
operator rptr<T_TYPE>() const
{
return rptr_nonconst(ptVal);
}
operator rptr_const<T_TYPE>() const
{
return ptVal;
}
operator bool() const
{
return ptVal;
}
};
#endif
| [
"crackedcomputerstudios@gmail.com"
] | crackedcomputerstudios@gmail.com |
91b56fc21987a7b0f55b66ff056846708075046b | 16cb55beea26cf910d8360a252d00578403d5044 | /leetcode_cpp/include/leetcode/problem_38.hpp | afec74e07ac1ef7a09f524f7edc294657cbc291b | [] | no_license | hbina/leetcode-solutions | 463141b28521b5983fe27b94652a6dcd2dd8e7d4 | e823d03a2723fa9599144056a2958ddb35aef2d7 | refs/heads/master | 2021-08-19T00:57:07.699954 | 2020-04-03T17:54:53 | 2020-04-03T17:54:53 | 152,827,421 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,069 | hpp | #pragma once
#include "util/generic/group_by.hpp"
#include <string>
#include <vector>
#include <algorithm>
// TODO :: Reimplement this using for-loops instead of recursion
namespace leetcode
{
template <
typename NumType,
typename OutputType = std::string>
static constexpr auto
countAndSay(const NumType &n)
-> OutputType
{
OutputType result = "1";
for (auto a = 1; a < n; a++)
{
const auto grouped =
util::generic::group_by<std::vector<std::string>>(
result.cbegin(),
result.cend(),
[](const auto &lhs, const auto &rhs) -> bool {
return lhs == rhs;
});
const auto transformed = std::accumulate(
std::cbegin(grouped),
std::cend(grouped),
std::string{},
[](std::string &acc, const std::string &value) {
return acc + std::to_string(value.size()) + value.front();
});
result = transformed;
}
return result;
}
} // namespace leetcode
| [
"hanif.ariffin.4326@gmail.com"
] | hanif.ariffin.4326@gmail.com |
25b0d843773f8cefdf70ca004a60783d4d60259d | 470b2d817157d060789dd49926802344fa07f5c3 | /wificrack/FileSystemWatcher.cpp | 01ed59ca3d4f73f14d25047d1414cdcc63005254 | [] | no_license | xiangshuijiao/wificrack | 9d7bd63f4cf664757aee1153b5c58d6217b15726 | ac7a969935424b7400487c69c2d88b3bb9db9f6c | refs/heads/master | 2020-08-17T22:53:43.341468 | 2019-11-07T17:56:26 | 2019-11-07T17:56:26 | 215,720,535 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,880 | cpp | /*
* how to use:
* 可以通过
* #include "FileSystemWatcher.h"
* FileSystemWatcher *a =new FileSystemWatcher();
* a->addWatchPath("E:/Test")来监控指定的文件/目录,监控之后,就可以在对应的路径进行更新测试了。
*
* */
#include "FileSystemWatcher.h"
#include <QDir>
#include <QFileInfo>
#include <QDebug>
#include <QTextStream>
//FileSystemWatcher* FileSystemWatcher::m_pInstance = NULL;
FileSystemWatcher::FileSystemWatcher(QObject *parent) : QObject(parent)
{
}
FileSystemWatcher::~FileSystemWatcher()
{
}
void FileSystemWatcher::addWatchPath(QString path)
{
qDebug() << QString("Add to watch: %1").arg(path);
// if (m_pInstance == NULL)
// {
m_pInstance = new FileSystemWatcher();
m_pInstance->m_pSystemWatcher = new QFileSystemWatcher();
// 连接QFileSystemWatcher的directoryChanged和fileChanged信号到相应的槽
connect(m_pInstance->m_pSystemWatcher, SIGNAL(directoryChanged(QString)), m_pInstance, SLOT(directoryUpdated(QString)));
connect(m_pInstance->m_pSystemWatcher, SIGNAL(fileChanged(QString)), m_pInstance, SLOT(fileUpdated(QString)));
connect(m_pInstance->m_pSystemWatcher, SIGNAL(fileChanged(QString)), this, SIGNAL(emit_signal_file_changed(QString)));
// }
// 添加监控路径
m_pInstance->m_pSystemWatcher->addPath(path);
// 如果添加路径是一个目录,保存当前内容列表
QFileInfo file(path);
if (file.isDir())
{
const QDir dirw(path);
m_pInstance->m_currentContentsMap[path] = dirw.entryList(QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Files, QDir::DirsFirst);
}
}
void FileSystemWatcher::directoryUpdated(const QString &path)
{
qDebug() << QString("Directory updated: %1").arg(path);
// 比较最新的内容和保存的内容找出区别(变化)
QStringList currEntryList = m_currentContentsMap[path];
const QDir dir(path);
QStringList newEntryList = dir.entryList(QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Files, QDir::DirsFirst);
QSet<QString> newDirSet = QSet<QString>::fromList(newEntryList);
QSet<QString> currentDirSet = QSet<QString>::fromList(currEntryList);
// 添加了文件
QSet<QString> newFiles = newDirSet - currentDirSet;
QStringList newFile = newFiles.toList();
// 文件已被移除
QSet<QString> deletedFiles = currentDirSet - newDirSet;
QStringList deleteFile = deletedFiles.toList();
// 更新当前设置
m_currentContentsMap[path] = newEntryList;
if (!newFile.isEmpty() && !deleteFile.isEmpty())
{
// 文件/目录重命名
if ((newFile.count() == 1) && (deleteFile.count() == 1)) {
qDebug() << QString("File Renamed from %1 to %2").arg(deleteFile.first()).arg(newFile.first());
}
} else
{
// 添加新文件/目录至Dir
if (!newFile.isEmpty())
{
qDebug() << "New Files/Dirs added: " << newFile;
foreach (QString file, newFile)
{
// 处理操作每个新文件....
}
}
// 从Dir中删除文件/目录
if (!deleteFile.isEmpty())
{
qDebug() << "Files/Dirs deleted: " << deleteFile;
foreach(QString file, deleteFile)
{
// 处理操作每个被删除的文件....
}
}
}
}
void FileSystemWatcher::fileUpdated(const QString &path)
{
QFileInfo file(path);
QString strPath = file.absolutePath();
QString strName = file.fileName();
qDebug() << QString("The file %1 at path %2 is updated").arg(strName).arg(strPath);
}
| [
"you@example.com"
] | you@example.com |
5ef59f679b32d01f83370dbd60e94e4f8460c292 | 6b53372edb28341e5314e0939700e607063654ef | /src/fireengine.native.player/src/graphics/filtermode.h | 6c4044157199277b27a42129f66cedc94bd77481 | [
"MIT"
] | permissive | iamkevinf/FireEngine | a4d571eccb320ed75787bc31457940c86f755849 | abf440f7a1e5596165b08fcc691ce894dfe2faef | refs/heads/master | 2022-12-17T23:20:15.019484 | 2020-09-15T05:15:44 | 2020-09-15T05:15:44 | 282,367,530 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 182 | h | #ifndef __FILTER_MODE_H__
#define __FILTER_MODE_H__
namespace FireEngine
{
enum class FilterMode
{
Point,
Bilinear,
Trilinear
};
}
#endif // __FILTER_MODE_H__ | [
"fyc@time-vr.com"
] | fyc@time-vr.com |
e513771a8137a23fac6b19e5e638be90dc3b9b48 | 1f2959f7840e1656f9d051b5bec147b43254e2d7 | /oop/task8/imageleapscounter.cpp | 8adbe31e155e3764727f2112e240903f9a67ff72 | [] | no_license | zerlok/nsu-prog-all | 521509738f8b2b91e86b5589eea8f4397fcd5976 | 2ff5ebe8d40326d731fb4c7d2b2fc37f44831364 | refs/heads/master | 2022-11-13T21:45:48.072579 | 2017-09-20T19:05:08 | 2017-09-20T19:05:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,417 | cpp | #include "affinetransformation.h"
#include "imageleapscounter.h"
const double ImageLeapsCounter::_default_dx = 1.0;
const double ImageLeapsCounter::_default_dy = 0.0;
ImageLeapsCounter::ImageLeapsCounter(const ImagePNG &img)
: img(img),
width(img.get_width()),
height(img.get_height()),
_dx(_default_dx),
_dy(_default_dy),
_leaps_num(0),
_rows_num(0)
{
}
ImageLeapsCounter::~ImageLeapsCounter()
{
}
void ImageLeapsCounter::set_direction(const int degrees)
{
_dx = _default_dx;
_dy = _default_dy;
RotationTransformation(degrees).transform(_dx, _dy);
}
size_t ImageLeapsCounter::get_counted_leaps() const
{
return _leaps_num;
}
size_t ImageLeapsCounter::get_counted_rows() const
{
return _rows_num;
}
size_t ImageLeapsCounter::reset()
{
size_t tmp = _leaps_num;
_leaps_num = 0;
_rows_num = 0;
return tmp;
}
size_t ImageLeapsCounter::count_total_leaps(fptr_counter f_counter)
{
// Rows from top edge.
for (size_t row_begin_x = width - 1; int(row_begin_x) >= 0; --row_begin_x)
{
_leaps_num += _get_row_leaps_data(f_counter, row_begin_x, 0.0).leaps_num;
++_rows_num;
}
// Rows from left edge.
for (size_t row_begin_y = 0; row_begin_y <= height; ++row_begin_y)
{
_leaps_num += _get_row_leaps_data(f_counter, 0.0, row_begin_y).leaps_num;
++_rows_num;
}
// Rows from bottom edge.
for (size_t row_begin_x = 0; row_begin_x < width; ++row_begin_x)
{
_leaps_num += _get_row_leaps_data(f_counter, row_begin_x, height).leaps_num;
++_rows_num;
}
return _leaps_num;
}
ImgHistogram ImageLeapsCounter::count_leaps_to_histogram(fptr_counter f_counter)
{
ImgHistogram histogram;
RowData data;
// Rows from top edge.
for (size_t row_begin_x = width - 1; int(row_begin_x) >= 0; --row_begin_x)
{
data = _get_row_leaps_data(f_counter, row_begin_x, 0.0);
_leaps_num += data.leaps_num;
++_rows_num;
histogram.add_bin(data.leaps_num * 100.0 / data.length);
}
// Rows from left edge.
for (size_t row_begin_y = 0; row_begin_y <= height; ++row_begin_y)
{
data = _get_row_leaps_data(f_counter, 0.0, row_begin_y);
_leaps_num += data.leaps_num;
++_rows_num;
histogram.add_bin(data.leaps_num * 100.0 / data.length);
}
// Rows from bottom edge.
for (size_t row_begin_x = 0; row_begin_x < width; ++row_begin_x)
{
data = _get_row_leaps_data(f_counter, row_begin_x, height);
_leaps_num += data.leaps_num;
++_rows_num;
histogram.add_bin(data.leaps_num * 100.0 / data.length);
}
return std::move(histogram);
}
ImageLeapsCounter::RowData ImageLeapsCounter::_get_row_leaps_data(fptr_counter f_counter, double curr_x, double curr_y) const
{
double next_x = curr_x + _dx;
double next_y = curr_y + _dy;
bool next_intensity;
bool current_intensity = f_counter(img.get_pixel(curr_x, curr_y));
size_t leaps = 0;
size_t len = 0;
while ((int(curr_x) >= 0)
&& (int(curr_y) >= 0)
&& (int(next_x) >= 0)
&& (int(next_y) >= 0)
&& (int(curr_x) < int(width))
&& (int(curr_y) < int(height))
&& (int(next_x) < int(width))
&& (int(next_y) < int(height)))
{
next_intensity = f_counter(img.get_pixel(next_x, next_y));
if (current_intensity != next_intensity)
++leaps;
curr_x = next_x;
curr_y = next_y;
while ((int(curr_x) == int(next_x))
&& (int(curr_y) == int(next_y)))
{
next_x += _dx;
next_y += _dy;
}
current_intensity = next_intensity;
++len;
}
return {leaps, len};
}
| [
"denergytro@gmail.com"
] | denergytro@gmail.com |
46507623acd440c826f32461d977c43ed3cb3415 | 1624de67cbed074dd130a1250b6e02965c399a2f | /C++PhotoEditor/C++PhotoEditor/Rectangle.cpp | cd38fc149394739499fe80e682bed6e93f6cc952 | [] | no_license | Ognjenjebot/PhotoEditor | 445e7213af6b5374f6c432a802ff919a815f8af8 | 4ec7a5f684b60043222279eafdcbbb6918b36ac8 | refs/heads/main | 2023-07-04T00:48:13.693377 | 2021-07-22T15:20:37 | 2021-07-22T15:20:37 | 388,486,159 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 381 | cpp | #include "Rectangle.h"
Rectangle::Rectangle(int x, int y, int width, int height)
{
this->x = x; this->y = y; this->width = width; this->height = height;
}
int Rectangle::getX() const
{
return this->x;
}
int Rectangle::getY() const
{
return this->y;
}
int Rectangle::getWidth() const
{
return this->width;
}
int Rectangle::getHeight() const
{
return this->height;
}
| [
"ognjen.stanojevic321@gmail.com"
] | ognjen.stanojevic321@gmail.com |
65dc0dbe13f0e05cf70c6dea42757c8ec933e691 | a92b18defb50c5d1118a11bc364f17b148312028 | /src/prod/src/data/interop/ReliableCollectionRuntimeImpl/StoreKeyValueEnumeratorCExports.cpp | f55aa32532fa2cd4140aeac6b5675726c1400bb0 | [
"MIT"
] | permissive | KDSBest/service-fabric | 34694e150fde662286e25f048fb763c97606382e | fe61c45b15a30fb089ad891c68c893b3a976e404 | refs/heads/master | 2023-01-28T23:19:25.040275 | 2020-11-30T11:11:58 | 2020-11-30T11:11:58 | 301,365,601 | 1 | 0 | MIT | 2020-11-30T11:11:59 | 2020-10-05T10:05:53 | null | UTF-8 | C++ | false | false | 4,930 | cpp | // ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------
#include "stdafx.h"
using namespace Data;
using namespace Data::Utilities;
using namespace Data::Interop;
// TODO remove this
KAllocator& GetAllocator()
{
KtlSystemCore* ktlsystem = KtlSystemCoreImp::TryGetDefaultKtlSystemCore();
return ktlsystem->PagedAllocator();
}
void StoreKeyValueEnumeratorCurrent(
__in IAsyncEnumerator<KeyValuePair<KString::SPtr, KeyValuePair<LONG64, KBuffer::SPtr>>>* enumerator,
__out LPCWSTR* key,
__out size_t *objectHandle,
__out Buffer* value,
__out LONG64* versionSequenceNumber)
{
char* buffer;
ULONG bufferLength;
auto result = enumerator->GetCurrent();
*key = static_cast<LPCWSTR>(*(result.Key));
*versionSequenceNumber = result.Value.Key;
KBuffer::SPtr kBufferSptr = result.Value.Value;
buffer = (char*)kBufferSptr->GetBuffer();
bufferLength = kBufferSptr->QuerySize();
#ifdef FEATURE_CACHE_OBJHANDLE
*objectHandle = *(size_t*)buffer;
buffer += sizeof(size_t);
bufferLength -= sizeof(size_t);
#else
*objectHandle = 0;
#endif
value->Bytes = buffer;
value->Length = bufferLength;
value->Handle = kBufferSptr.RawPtr();
kBufferSptr.Detach();
}
extern "C" void StoreKeyValueEnumerator_Release(
__in StoreKeyValueAsyncEnumeratorHandle enumerator)
{
IAsyncEnumerator<KeyValuePair<KString::SPtr, KeyValuePair<LONG64, KBuffer::SPtr>>>::SPtr enumeratorSPtr;
enumeratorSPtr.Attach((IAsyncEnumerator<KeyValuePair<KString::SPtr, KeyValuePair<LONG64, KBuffer::SPtr>>>*)enumerator);
enumeratorSPtr->Dispose();
}
ktl::Task StoreKeyValueEnumeratorMoveNextAsyncInternal(
__in IAsyncEnumerator<KeyValuePair<KString::SPtr, KeyValuePair<LONG64, KBuffer::SPtr>>>* enumerator,
__out ktl::CancellationTokenSource** cts,
__out BOOL* advanced,
__out LPCWSTR* key,
__out size_t *objectHandle,
__out Buffer* value,
__out LONG64* versionSequenceNumber,
__in fnNotifyStoreKeyValueEnumeratorMoveNextAsyncCompletion callback,
__in void* ctx,
__out NTSTATUS& status,
__out BOOL& synchronousComplete)
{
ktl::CancellationToken cancellationToken = ktl::CancellationToken::None;
ktl::CancellationTokenSource::SPtr cancellationTokenSource = nullptr;
bool returnKeyValues = true;
if (key == nullptr)
returnKeyValues = false;
status = STATUS_SUCCESS;
synchronousComplete = false;
if (cts != nullptr)
{
status = ktl::CancellationTokenSource::Create(GetAllocator(), RELIABLECOLLECTIONRUNTIME_TAG, cancellationTokenSource);
CO_RETURN_VOID_ON_FAILURE(status);
cancellationToken = cancellationTokenSource->Token;
}
auto awaitable = enumerator->MoveNextAsync(cancellationToken);
if (IsComplete(awaitable))
{
synchronousComplete = true;
EXCEPTION_TO_STATUS(*advanced = co_await awaitable, status);
// if key is null then don't care about key values
if (returnKeyValues && *advanced)
{
StoreKeyValueEnumeratorCurrent(enumerator, key, objectHandle, value, versionSequenceNumber);
}
co_return;
}
if (cts != nullptr)
*cts = cancellationTokenSource.Detach();
NTSTATUS ntstatus = STATUS_SUCCESS;
BOOL _advanced = false;
LPCWSTR _key = nullptr;
size_t _objectHandle = 0;
Buffer buffer = {};
LONG64 _versionSequenceNumber = -1;
EXCEPTION_TO_STATUS(_advanced = co_await awaitable, ntstatus);
if (returnKeyValues && _advanced)
{
StoreKeyValueEnumeratorCurrent(enumerator, &_key, &_objectHandle, &buffer, &_versionSequenceNumber);
}
callback(ctx, StatusConverter::ToHResult(ntstatus), _advanced, _key, _objectHandle, buffer.Bytes, buffer.Length, _versionSequenceNumber);
KBuffer::SPtr kBuffer;
kBuffer.Attach((KBuffer*)buffer.Handle);
}
extern "C" HRESULT StoreKeyValueEnumerator_MoveNextAsync(
__in StoreKeyValueAsyncEnumeratorHandle enumerator,
__out CancellationTokenSourceHandle* cts,
__out BOOL* advanced,
__out LPCWSTR* key,
__out size_t* objectHandle,
__out Buffer* value,
__out int64_t* versionSequenceNumber,
__in fnNotifyStoreKeyValueEnumeratorMoveNextAsyncCompletion callback,
__in void* ctx,
__out BOOL* synchronousComplete)
{
NTSTATUS status;
StoreKeyValueEnumeratorMoveNextAsyncInternal(
(IAsyncEnumerator<KeyValuePair<KString::SPtr, KeyValuePair<LONG64, KBuffer::SPtr>>>*)enumerator,
(ktl::CancellationTokenSource**)cts,
advanced, key, objectHandle, value,
versionSequenceNumber, callback, ctx, status, *synchronousComplete);
return StatusConverter::ToHResult(status);
}
| [
"noreply-sfteam@microsoft.com"
] | noreply-sfteam@microsoft.com |
01108c17e0c72b945714aec614a5e9d4750996c2 | 0483566b99e476dde4ec91ad912a90d8c2763ba8 | /camera.h | 97d3dfc0edd600473dd6040fe4cf5446d1dad736 | [
"MIT"
] | permissive | Joel714/GameProject | 4a1343276be948f6da575a930dc7b3acaf4e8072 | 417b0f65d2f2c9dde2d2bf68f6ac092501dfcabc | refs/heads/master | 2016-09-10T21:57:41.192169 | 2015-10-21T07:32:53 | 2015-10-21T07:32:53 | 42,841,848 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 326 | h | #ifndef _CAMERA_H_
#define _CAMERA_H_
#include <GL/gl.h>
class Camera{
private:
public:
int x, y;
Camera();
void drawSprite(int spriteX, int spriteY, int spriteHeight, int spriteWidth, float texCoords[][8], int texIndex);
void updatePosition(int playerX, int playerY, int mapHeight, int mapWidth);
};
#endif
| [
"joel.pedroza714@gmail.com"
] | joel.pedroza714@gmail.com |
d39e480a86ac36ab9b33e1731f5081861135d5bf | a9e308c81c27a80c53c899ce806d6d7b4a9bbbf3 | /engine/xray/core/sources/script_engine_wrapper.h | 56d256b22150a4a4bde187a4d867011fea0753ab | [] | no_license | NikitaNikson/xray-2_0 | 00d8e78112d7b3d5ec1cb790c90f614dc732f633 | 82b049d2d177aac15e1317cbe281e8c167b8f8d1 | refs/heads/master | 2023-06-25T16:51:26.243019 | 2020-09-29T15:49:23 | 2020-09-29T15:49:23 | 390,966,305 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,910 | h | ////////////////////////////////////////////////////////////////////////////
// Created : 06.03.2009
// Author : Dmitriy Iassenev
// Copyright (C) GSC Game World - 2009
////////////////////////////////////////////////////////////////////////////
#ifndef SCRIPT_ENGINE_WRAPPER_H_INCLUDED
#define SCRIPT_ENGINE_WRAPPER_H_INCLUDED
#define CS_STATIC_LIBRARIES
#include <cs/script/engine.h>
namespace xray {
namespace core {
class script_engine_wrapper : public ::cs::script::engine {
public:
script_engine_wrapper ( pcstr resource_path, pcstr underscore_G_path );
private:
virtual void CS_SCRIPT_CALL log ( cs::message_initiator const &message_initiator, cs::core::message_type const &message_type, const char *string);
virtual bool CS_SCRIPT_CALL file_exists ( int file_type, const char *file_name);
virtual cs::script::file_handle CS_SCRIPT_CALL open_file_buffer ( int file_type, const char *file_name, cs::script::file_buffer &file_buffer, u32& buffer_size);
virtual void CS_SCRIPT_CALL close_file_buffer ( cs::script::file_handle file_handle);
virtual bool CS_SCRIPT_CALL create_file ( int file_type, const char *file_name, const cs::script::file_buffer &file_buffer, u32 const& buffer_size);
virtual void CS_SCRIPT_CALL lua_studio_backend_file_path ( int file_type, const char *file_name, char *path, u32 const& max_size);
virtual bool CS_SCRIPT_CALL use_debug_engine ( ) const { return false; }
virtual bool CS_SCRIPT_CALL use_logging ( ) const { return false; }
private:
pcstr get_file_name ( int const file_type, pcstr const file_name, pstr const result, u32 const result_size, bool add_extension );
private:
string_path m_resource_path;
string_path m_underscore_G_path;
}; // class script_engine_wrapper
} // namespace core
} // namespace xray
#endif // #ifndef SCRIPT_ENGINE_WRAPPER_H_INCLUDED | [
"loxotron@bk.ru"
] | loxotron@bk.ru |
f9690a97eff483cef5e131e3de61d137ba9662ae | e9eba901385b6fe7ae22b1b4c466a858ec4e4cd4 | /nachos_lab/lab5/lab5未完成challenge之前/filesys/filesys.cc | ee6bf81a5d9fdb260c56289b5fc1ab583998fcc1 | [] | no_license | Ydongd/nachos_lab | 733504ffecde0e1b0638c4246b885ecc5753c130 | dfeb7b516536e4673a4d26bf403a3d6ae832c13d | refs/heads/master | 2021-10-06T11:17:35.360895 | 2021-09-28T07:13:57 | 2021-09-28T07:13:57 | 175,534,618 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,392 | cc | // filesys.cc
// Routines to manage the overall operation of the file system.
// Implements routines to map from textual file names to files.
//
// Each file in the file system has:
// A file header, stored in a sector on disk
// (the size of the file header data structure is arranged
// to be precisely the size of 1 disk sector)
// A number of data blocks
// An entry in the file system directory
//
// The file system consists of several data structures:
// A bitmap of free disk sectors (cf. bitmap.h)
// A directory of file names and file headers
//
// Both the bitmap and the directory are represented as normal
// files. Their file headers are located in specific sectors
// (sector 0 and sector 1), so that the file system can find them
// on bootup.
//
// The file system assumes that the bitmap and directory files are
// kept "open" continuously while Nachos is running.
//
// For those operations (such as Create, Remove) that modify the
// directory and/or bitmap, if the operation succeeds, the changes
// are written immediately back to disk (the two files are kept
// open during all this time). If the operation fails, and we have
// modified part of the directory and/or bitmap, we simply discard
// the changed version, without writing it back to disk.
//
// Our implementation at this point has the following restrictions:
//
// there is no synchronization for concurrent accesses
// files have a fixed size, set when the file is created
// files cannot be bigger than about 3KB in size
// there is no hierarchical directory structure, and only a limited
// number of files can be added to the system
// there is no attempt to make the system robust to failures
// (if Nachos exits in the middle of an operation that modifies
// the file system, it may corrupt the disk)
//
// Copyright (c) 1992-1993 The Regents of the University of California.
// All rights reserved. See copyright.h for copyright notice and limitation
// of liability and disclaimer of warranty provisions.
#include "copyright.h"
#include "time.h"
#include "disk.h"
#include "bitmap.h"
#include "directory.h"
#include "filehdr.h"
#include "filesys.h"
#include "system.h"
// Sectors containing the file headers for the bitmap of free sectors,
// and the directory of files. These file headers are placed in well-known
// sectors, so that they can be located on boot-up.
#define FreeMapSector 0
#define DirectorySector 1
#define NameSector 2
#define CurDirecSector 3
// Initial file sizes for the bitmap and directory; until the file system
// supports extensible files, the directory size sets the maximum number
// of files that can be loaded onto the disk.
#define FreeMapFileSize (NumSectors / BitsInByte)
#define NumDirEntries 10
#define DirectoryFileSize (sizeof(DirectoryEntry) * NumDirEntries)
//----------------------------------------------------------------------
// FileSystem::FileSystem
// Initialize the file system. If format = TRUE, the disk has
// nothing on it, and we need to initialize the disk to contain
// an empty directory, and a bitmap of free sectors (with almost but
// not all of the sectors marked as free).
//
// If format = FALSE, we just have to open the files
// representing the bitmap and the directory.
//
// "format" -- should we initialize the disk?
//----------------------------------------------------------------------
FileSystem::FileSystem(bool format)
{
DEBUG('f', "Initializing the file system.\n");
if (format) {
BitMap *freeMap = new BitMap(NumSectors);
Directory *directory = new Directory(NumDirEntries);
FileHeader *mapHdr = new FileHeader;
FileHeader *dirHdr = new FileHeader;
FileHeader *namHdr = new FileHeader;
FileHeader *curHdr = new FileHeader;
DEBUG('f', "Formatting the file system.\n");
// First, allocate space for FileHeaders for the directory and bitmap
// (make sure no one else grabs these!)
freeMap->Mark(FreeMapSector);
freeMap->Mark(DirectorySector);
freeMap->Mark(NameSector);
freeMap->Mark(CurDirecSector);
// Second, allocate space for the data blocks containing the contents
// of the directory and bitmap files. There better be enough space!
ASSERT(mapHdr->Allocate(freeMap, FreeMapFileSize));
ASSERT(dirHdr->Allocate(freeMap, DirectoryFileSize));
ASSERT(namHdr->Allocate(freeMap, 0));
ASSERT(curHdr->Allocate(freeMap, DirectoryFileSize));
namHdr->hdr_sector = NameSector;
curHdr->hdr_sector = 1;
dirHdr->hdr_sector = DirectorySector;
// Flush the bitmap and directory FileHeaders back to disk
// We need to do this before we can "Open" the file, since open
// reads the file header off of disk (and currently the disk has garbage
// on it!).
DEBUG('f', "Writing headers back to disk.\n");
mapHdr->WriteBack(FreeMapSector);
dirHdr->WriteBack(DirectorySector);
namHdr->WriteBack(NameSector);
curHdr->WriteBack(CurDirecSector);
// OK to open the bitmap and directory files now
// The file system operations assume these two files are left open
// while Nachos is running.
freeMapFile = new OpenFile(FreeMapSector);
directoryFile = new OpenFile(DirectorySector);
nameFile = new OpenFile(NameSector);
curDirectoryFile = new OpenFile(CurDirecSector);
//curDirectoryFile->hdr->hdr_sector = 1;
// Once we have the files "open", we can write the initial version
// of each file back to disk. The directory at this point is completely
// empty; but the bitmap has been changed to reflect the fact that
// sectors on the disk have been allocated for the file headers and
// to hold the file data for the directory and bitmap.
DEBUG('f', "Writing bitmap and directory back to disk.\n");
freeMap->WriteBack(freeMapFile); // flush changes to disk
char buffer[] = "root";
nameFile->Write(buffer, strlen(buffer));
directory->table[0].inUse = TRUE;
directory->table[0].offset = 0;
directory->table[0].length = 4;
directory->table[0].sector = 1;
directory->WriteBack(directoryFile);
directory->WriteBack(curDirectoryFile);
if (DebugIsEnabled('f')) {
freeMap->Print();
directory->Print();
delete freeMap;
delete directory;
delete mapHdr;
delete dirHdr;
delete namHdr;
delete curHdr;
}
} else {
// if we are not formatting the disk, just open the files representing
// the bitmap and directory; these are left open while Nachos is running
freeMapFile = new OpenFile(FreeMapSector);
directoryFile = new OpenFile(DirectorySector);
nameFile = new OpenFile(NameSector);
curDirectoryFile = new OpenFile(CurDirecSector);
}
}
//----------------------------------------------------------------------
// FileSystem::Create
// Create a file in the Nachos file system (similar to UNIX create).
// Since we can't increase the size of files dynamically, we have
// to give Create the initial size of the file.
//
// The steps to create a file are:
// Make sure the file doesn't already exist
// Allocate a sector for the file header
// Allocate space on disk for the data blocks for the file
// Add the name to the directory
// Store the new file header on disk
// Flush the changes to the bitmap and the directory back to disk
//
// Return TRUE if everything goes ok, otherwise, return FALSE.
//
// Create fails if:
// file is already in directory
// no free space for file header
// no free entry for file in directory
// no free space for data blocks for the file
//
// Note that this implementation assumes there is no concurrent access
// to the file system!
//
// "name" -- name of file to be created
// "initialSize" -- size of file to be created
//----------------------------------------------------------------------
bool
FileSystem::Create(char *name, int initialSize)
{
Directory *directory;
BitMap *freeMap;
FileHeader *hdr;
int sector;
bool success;
DEBUG('f', "Creating file %s, size %d\n", name, initialSize);
directory = new Directory(NumDirEntries);
//directory->FetchFrom(directoryFile);
directory->FetchFrom(curDirectoryFile);
if (directory->Find(name) != -1)
success = FALSE; // file is already in directory
else {
freeMap = new BitMap(NumSectors);
freeMap->FetchFrom(freeMapFile);
sector = freeMap->Find(); // find a sector to hold the file header
if (sector == -1)
success = FALSE; // no free block for file header
else if (!directory->Add(name, sector, FALSE))
success = FALSE; // no space in directory
else {
hdr = new FileHeader;
if (!hdr->Allocate(freeMap, initialSize))
success = FALSE; // no space on disk for data
else {
success = TRUE;
// everthing worked, flush all changes back to disk
time_t timep;
time(&timep);
char *tmptime = asctime(gmtime((&timep)));
hdr->setCreateTime(tmptime);
hdr->setLastVisitTime(tmptime);
hdr->setLastModifyTime(tmptime);
hdr->setType(name);
hdr->hdr_sector = sector;
hdr->WriteBack(sector);
//directory->WriteBack(directoryFile);
directory->WriteBack(curDirectoryFile);
freeMap->WriteBack(freeMapFile);
}
delete hdr;
}
delete freeMap;
}
delete directory;
return success;
}
bool
FileSystem::CreateDir(char *name, int initialSize)
{
Directory *directory;
BitMap *freeMap;
FileHeader *hdr;
int sector;
bool success;
FileHeader *curHdr = new FileHeader;
curHdr->FetchFrom(3);
DEBUG('f', "Creating file %s, size %d\n", name, initialSize);
directory = new Directory(NumDirEntries);
//directory->FetchFrom(directoryFile);
directory->FetchFrom(curDirectoryFile);
if (directory->Find(name) != -1)
success = FALSE; // file is already in directory
else {
freeMap = new BitMap(NumSectors);
freeMap->FetchFrom(freeMapFile);
sector = freeMap->Find(); // find a sector to hold the file header
if (sector == -1)
success = FALSE; // no free block for file header
else if (!directory->Add(name, sector, TRUE))
success = FALSE; // no space in directory
else {
hdr = new FileHeader;
initialSize = DirectoryFileSize;
if (!hdr->Allocate(freeMap, initialSize))
success = FALSE; // no space on disk for data
else {
success = TRUE;
// everthing worked, flush all changes back to disk
time_t timep;
time(&timep);
char *tmptime = asctime(gmtime((&timep)));
hdr->setCreateTime(tmptime);
hdr->setLastVisitTime(tmptime);
hdr->setLastModifyTime(tmptime);
hdr->setType(name);
hdr->hdr_sector = sector;
hdr->WriteBack(sector);
//if(type){
//Directory *directory = new Directory(NumDirEntries);
OpenFile* namFile = new OpenFile(2);
int filelen = namFile->hdr->FileLength();
char *buffer = new char[filelen+1];
namFile->ReadAt(buffer, filelen, 0);
int ll = strlen(name);
int j;
char *tname = new char[ll + directory->table[0].length + 2];
for(j=0; j<directory->table[0].length; ++j){
tname[j] = buffer[directory->table[0].offset + j];
}
tname[j] = '/';
j++;
for(int i=0; i<ll; ++i, ++j){
tname[j] = name[i];
}
tname[j]='\0';
Directory *dd = new Directory(NumDirEntries);
dd->table[0].inUse = TRUE;
namFile->setPosition(namFile->hdr->FileLength());
int len = strlen(tname);
dd->table[0].offset = namFile->hdr->FileLength();
dd->table[0].length = len;
dd->table[0].sector = curHdr->hdr_sector;
namFile->Write(tname, strlen(tname));
OpenFile* fff = new OpenFile(sector);
dd->WriteBack(fff);
//}
curHdr->WriteBack(3);
hdr->WriteBack(sector);
//directory->WriteBack(directoryFile);
directory->WriteBack(curDirectoryFile);
freeMap->WriteBack(freeMapFile);
}
delete hdr;
}
delete freeMap;
}
delete directory;
return success;
}
//----------------------------------------------------------------------
// FileSystem::Open
// Open a file for reading and writing.
// To open a file:
// Find the location of the file's header, using the directory
// Bring the header into memory
//
// "name" -- the text name of the file to be opened
//----------------------------------------------------------------------
OpenFile *
FileSystem::Open(char *name)
{
Directory *directory = new Directory(NumDirEntries);
OpenFile *openFile = NULL;
int sector;
DEBUG('f', "Opening file %s\n", name);
//directory->FetchFrom(directoryFile);
directory->FetchFrom(curDirectoryFile);
sector = directory->Find(name);
if (sector >= 0)
openFile = new OpenFile(sector); // name was found in directory
delete directory;
return openFile; // return NULL if not found
}
//----------------------------------------------------------------------
// FileSystem::Remove
// Delete a file from the file system. This requires:
// Remove it from the directory
// Delete the space for its header
// Delete the space for its data blocks
// Write changes to directory, bitmap back to disk
//
// Return TRUE if the file was deleted, FALSE if the file wasn't
// in the file system.
//
// "name" -- the text name of the file to be removed
//----------------------------------------------------------------------
bool
FileSystem::Remove(char *name)
{
Directory *directory;
BitMap *freeMap;
FileHeader *fileHdr;
int sector;
directory = new Directory(NumDirEntries);
//directory->FetchFrom(directoryFile);
directory->FetchFrom(curDirectoryFile);
sector = directory->Find(name);
if (sector == -1) {
delete directory;
return FALSE; // file not found
}
if(synchDisk->openCnt[sector] > 0){
printf("Cannot remove this file, %d openfiles still use it..\n",
synchDisk->openCnt[sector]);
return FALSE;
}
synchDisk->P(sector);
fileHdr = new FileHeader;
fileHdr->FetchFrom(sector);
freeMap = new BitMap(NumSectors);
freeMap->FetchFrom(freeMapFile);
fileHdr->Deallocate(freeMap); // remove data blocks
freeMap->Clear(sector); // remove header block
directory->Remove(name);
freeMap->WriteBack(freeMapFile); // flush to disk
//directory->WriteBack(directoryFile); // flush to disk
directory->WriteBack(curDirectoryFile);
synchDisk->V(sector);
delete fileHdr;
delete directory;
delete freeMap;
return TRUE;
}
//----------------------------------------------------------------------
// FileSystem::List
// List all the files in the file system directory.
//----------------------------------------------------------------------
void
FileSystem::List()
{
Directory *directory = new Directory(NumDirEntries);
directory->FetchFrom(directoryFile);
directory->List();
delete directory;
}
//----------------------------------------------------------------------
// FileSystem::Print
// Print everything about the file system:
// the contents of the bitmap
// the contents of the directory
// for each file in the directory,
// the contents of the file header
// the data in the file
//----------------------------------------------------------------------
void
FileSystem::Print()
{
FileHeader *bitHdr = new FileHeader;
FileHeader *dirHdr = new FileHeader;
FileHeader *namHdr = new FileHeader;
FileHeader *curHdr = new FileHeader;
BitMap *freeMap = new BitMap(NumSectors);
Directory *directory = new Directory(NumDirEntries);
printf("Bit map file header:\n");
bitHdr->FetchFrom(FreeMapSector);
bitHdr->Print();
printf("Name file header:\n");
namHdr->FetchFrom(NameSector);
namHdr->Print();
printf("Directory file header:\n");
dirHdr->FetchFrom(DirectorySector);
dirHdr->Print();
printf("Current Directory file header:\n");
curHdr->FetchFrom(CurDirecSector);
curHdr->Print();
freeMap->FetchFrom(freeMapFile);
freeMap->Print();
printf("\n");
//directory->FetchFrom(directoryFile);
directory->FetchFrom(curDirectoryFile);
directory->Print();
delete bitHdr;
delete dirHdr;
delete namHdr;
delete freeMap;
delete directory;
}
void
FileSystem::Change(char *name){
Directory *directory;
int sector;
FileHeader *curHdr = new FileHeader;
curHdr->FetchFrom(3);
directory = new Directory(NumDirEntries);
//directory->FetchFrom(directoryFile);
directory->FetchFrom(curDirectoryFile);
int oriSector = curHdr->hdr_sector;
OpenFile *ddd = new OpenFile(oriSector);
directory->WriteBack(ddd);
if(!strcmp(name, ".."))
sector = directory->table[0].sector;
else
sector = directory->Find(name);
OpenFile *dd = new OpenFile(sector);
directory->FetchFrom(dd);
directory->WriteBack(curDirectoryFile);
curHdr->hdr_sector = sector;
curHdr->WriteBack(3);
}
| [
"1600012776@pku.edu.cn"
] | 1600012776@pku.edu.cn |
a4571d43e3118139834e1a5ccfa3c4f28de775f7 | 6a9c13837bcf73fa64d1974eb3ae383aace3cf37 | /thirdparty_builtin/googletest/googlemock/test/gmock-matchers-misc_test.cc | 0c7aa4994222d11ec4b5d35201fdf4fa6349344c | [
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | LLNL/blt | 93fb69ddf7fe86bbc1a3c975d4b36f70dbf0fec9 | d57f7995ff8299e4612e74ec94e35eacde93cf40 | refs/heads/develop | 2023-09-06T07:51:57.666876 | 2023-08-23T22:23:17 | 2023-08-23T22:23:17 | 83,483,519 | 228 | 66 | BSD-3-Clause | 2023-08-23T22:23:19 | 2017-02-28T21:59:28 | C++ | UTF-8 | C++ | false | false | 61,799 | cc | // Copyright 2007, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes.
//
// This file tests some commonly used argument matchers.
#include "gtest/gtest.h"
// Silence warning C4244: 'initializing': conversion from 'int' to 'short',
// possible loss of data and C4100, unreferenced local parameter
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100)
#include "test/gmock-matchers_test.h"
namespace testing {
namespace gmock_matchers_test {
namespace {
TEST(AddressTest, NonConst) {
int n = 1;
const Matcher<int> m = Address(Eq(&n));
EXPECT_TRUE(m.Matches(n));
int other = 5;
EXPECT_FALSE(m.Matches(other));
int& n_ref = n;
EXPECT_TRUE(m.Matches(n_ref));
}
TEST(AddressTest, Const) {
const int n = 1;
const Matcher<int> m = Address(Eq(&n));
EXPECT_TRUE(m.Matches(n));
int other = 5;
EXPECT_FALSE(m.Matches(other));
}
TEST(AddressTest, MatcherDoesntCopy) {
std::unique_ptr<int> n(new int(1));
const Matcher<std::unique_ptr<int>> m = Address(Eq(&n));
EXPECT_TRUE(m.Matches(n));
}
TEST(AddressTest, Describe) {
Matcher<int> matcher = Address(_);
EXPECT_EQ("has address that is anything", Describe(matcher));
EXPECT_EQ("does not have address that is anything",
DescribeNegation(matcher));
}
// The following two tests verify that values without a public copy
// ctor can be used as arguments to matchers like Eq(), Ge(), and etc
// with the help of ByRef().
class NotCopyable {
public:
explicit NotCopyable(int a_value) : value_(a_value) {}
int value() const { return value_; }
bool operator==(const NotCopyable& rhs) const {
return value() == rhs.value();
}
bool operator>=(const NotCopyable& rhs) const {
return value() >= rhs.value();
}
private:
int value_;
NotCopyable(const NotCopyable&) = delete;
NotCopyable& operator=(const NotCopyable&) = delete;
};
TEST(ByRefTest, AllowsNotCopyableConstValueInMatchers) {
const NotCopyable const_value1(1);
const Matcher<const NotCopyable&> m = Eq(ByRef(const_value1));
const NotCopyable n1(1), n2(2);
EXPECT_TRUE(m.Matches(n1));
EXPECT_FALSE(m.Matches(n2));
}
TEST(ByRefTest, AllowsNotCopyableValueInMatchers) {
NotCopyable value2(2);
const Matcher<NotCopyable&> m = Ge(ByRef(value2));
NotCopyable n1(1), n2(2);
EXPECT_FALSE(m.Matches(n1));
EXPECT_TRUE(m.Matches(n2));
}
TEST(IsEmptyTest, ImplementsIsEmpty) {
vector<int> container;
EXPECT_THAT(container, IsEmpty());
container.push_back(0);
EXPECT_THAT(container, Not(IsEmpty()));
container.push_back(1);
EXPECT_THAT(container, Not(IsEmpty()));
}
TEST(IsEmptyTest, WorksWithString) {
std::string text;
EXPECT_THAT(text, IsEmpty());
text = "foo";
EXPECT_THAT(text, Not(IsEmpty()));
text = std::string("\0", 1);
EXPECT_THAT(text, Not(IsEmpty()));
}
TEST(IsEmptyTest, CanDescribeSelf) {
Matcher<vector<int>> m = IsEmpty();
EXPECT_EQ("is empty", Describe(m));
EXPECT_EQ("isn't empty", DescribeNegation(m));
}
TEST(IsEmptyTest, ExplainsResult) {
Matcher<vector<int>> m = IsEmpty();
vector<int> container;
EXPECT_EQ("", Explain(m, container));
container.push_back(0);
EXPECT_EQ("whose size is 1", Explain(m, container));
}
TEST(IsEmptyTest, WorksWithMoveOnly) {
ContainerHelper helper;
EXPECT_CALL(helper, Call(IsEmpty()));
helper.Call({});
}
TEST(IsTrueTest, IsTrueIsFalse) {
EXPECT_THAT(true, IsTrue());
EXPECT_THAT(false, IsFalse());
EXPECT_THAT(true, Not(IsFalse()));
EXPECT_THAT(false, Not(IsTrue()));
EXPECT_THAT(0, Not(IsTrue()));
EXPECT_THAT(0, IsFalse());
EXPECT_THAT(nullptr, Not(IsTrue()));
EXPECT_THAT(nullptr, IsFalse());
EXPECT_THAT(-1, IsTrue());
EXPECT_THAT(-1, Not(IsFalse()));
EXPECT_THAT(1, IsTrue());
EXPECT_THAT(1, Not(IsFalse()));
EXPECT_THAT(2, IsTrue());
EXPECT_THAT(2, Not(IsFalse()));
int a = 42;
EXPECT_THAT(a, IsTrue());
EXPECT_THAT(a, Not(IsFalse()));
EXPECT_THAT(&a, IsTrue());
EXPECT_THAT(&a, Not(IsFalse()));
EXPECT_THAT(false, Not(IsTrue()));
EXPECT_THAT(true, Not(IsFalse()));
EXPECT_THAT(std::true_type(), IsTrue());
EXPECT_THAT(std::true_type(), Not(IsFalse()));
EXPECT_THAT(std::false_type(), IsFalse());
EXPECT_THAT(std::false_type(), Not(IsTrue()));
EXPECT_THAT(nullptr, Not(IsTrue()));
EXPECT_THAT(nullptr, IsFalse());
std::unique_ptr<int> null_unique;
std::unique_ptr<int> nonnull_unique(new int(0));
EXPECT_THAT(null_unique, Not(IsTrue()));
EXPECT_THAT(null_unique, IsFalse());
EXPECT_THAT(nonnull_unique, IsTrue());
EXPECT_THAT(nonnull_unique, Not(IsFalse()));
}
#ifdef GTEST_HAS_TYPED_TEST
// Tests ContainerEq with different container types, and
// different element types.
template <typename T>
class ContainerEqTest : public testing::Test {};
typedef testing::Types<set<int>, vector<size_t>, multiset<size_t>, list<int>>
ContainerEqTestTypes;
TYPED_TEST_SUITE(ContainerEqTest, ContainerEqTestTypes);
// Tests that the filled container is equal to itself.
TYPED_TEST(ContainerEqTest, EqualsSelf) {
static const int vals[] = {1, 1, 2, 3, 5, 8};
TypeParam my_set(vals, vals + 6);
const Matcher<TypeParam> m = ContainerEq(my_set);
EXPECT_TRUE(m.Matches(my_set));
EXPECT_EQ("", Explain(m, my_set));
}
// Tests that missing values are reported.
TYPED_TEST(ContainerEqTest, ValueMissing) {
static const int vals[] = {1, 1, 2, 3, 5, 8};
static const int test_vals[] = {2, 1, 8, 5};
TypeParam my_set(vals, vals + 6);
TypeParam test_set(test_vals, test_vals + 4);
const Matcher<TypeParam> m = ContainerEq(my_set);
EXPECT_FALSE(m.Matches(test_set));
EXPECT_EQ("which doesn't have these expected elements: 3",
Explain(m, test_set));
}
// Tests that added values are reported.
TYPED_TEST(ContainerEqTest, ValueAdded) {
static const int vals[] = {1, 1, 2, 3, 5, 8};
static const int test_vals[] = {1, 2, 3, 5, 8, 46};
TypeParam my_set(vals, vals + 6);
TypeParam test_set(test_vals, test_vals + 6);
const Matcher<const TypeParam&> m = ContainerEq(my_set);
EXPECT_FALSE(m.Matches(test_set));
EXPECT_EQ("which has these unexpected elements: 46", Explain(m, test_set));
}
// Tests that added and missing values are reported together.
TYPED_TEST(ContainerEqTest, ValueAddedAndRemoved) {
static const int vals[] = {1, 1, 2, 3, 5, 8};
static const int test_vals[] = {1, 2, 3, 8, 46};
TypeParam my_set(vals, vals + 6);
TypeParam test_set(test_vals, test_vals + 5);
const Matcher<TypeParam> m = ContainerEq(my_set);
EXPECT_FALSE(m.Matches(test_set));
EXPECT_EQ(
"which has these unexpected elements: 46,\n"
"and doesn't have these expected elements: 5",
Explain(m, test_set));
}
// Tests duplicated value -- expect no explanation.
TYPED_TEST(ContainerEqTest, DuplicateDifference) {
static const int vals[] = {1, 1, 2, 3, 5, 8};
static const int test_vals[] = {1, 2, 3, 5, 8};
TypeParam my_set(vals, vals + 6);
TypeParam test_set(test_vals, test_vals + 5);
const Matcher<const TypeParam&> m = ContainerEq(my_set);
// Depending on the container, match may be true or false
// But in any case there should be no explanation.
EXPECT_EQ("", Explain(m, test_set));
}
#endif // GTEST_HAS_TYPED_TEST
// Tests that multiple missing values are reported.
// Using just vector here, so order is predictable.
TEST(ContainerEqExtraTest, MultipleValuesMissing) {
static const int vals[] = {1, 1, 2, 3, 5, 8};
static const int test_vals[] = {2, 1, 5};
vector<int> my_set(vals, vals + 6);
vector<int> test_set(test_vals, test_vals + 3);
const Matcher<vector<int>> m = ContainerEq(my_set);
EXPECT_FALSE(m.Matches(test_set));
EXPECT_EQ("which doesn't have these expected elements: 3, 8",
Explain(m, test_set));
}
// Tests that added values are reported.
// Using just vector here, so order is predictable.
TEST(ContainerEqExtraTest, MultipleValuesAdded) {
static const int vals[] = {1, 1, 2, 3, 5, 8};
static const int test_vals[] = {1, 2, 92, 3, 5, 8, 46};
list<size_t> my_set(vals, vals + 6);
list<size_t> test_set(test_vals, test_vals + 7);
const Matcher<const list<size_t>&> m = ContainerEq(my_set);
EXPECT_FALSE(m.Matches(test_set));
EXPECT_EQ("which has these unexpected elements: 92, 46",
Explain(m, test_set));
}
// Tests that added and missing values are reported together.
TEST(ContainerEqExtraTest, MultipleValuesAddedAndRemoved) {
static const int vals[] = {1, 1, 2, 3, 5, 8};
static const int test_vals[] = {1, 2, 3, 92, 46};
list<size_t> my_set(vals, vals + 6);
list<size_t> test_set(test_vals, test_vals + 5);
const Matcher<const list<size_t>> m = ContainerEq(my_set);
EXPECT_FALSE(m.Matches(test_set));
EXPECT_EQ(
"which has these unexpected elements: 92, 46,\n"
"and doesn't have these expected elements: 5, 8",
Explain(m, test_set));
}
// Tests to see that duplicate elements are detected,
// but (as above) not reported in the explanation.
TEST(ContainerEqExtraTest, MultiSetOfIntDuplicateDifference) {
static const int vals[] = {1, 1, 2, 3, 5, 8};
static const int test_vals[] = {1, 2, 3, 5, 8};
vector<int> my_set(vals, vals + 6);
vector<int> test_set(test_vals, test_vals + 5);
const Matcher<vector<int>> m = ContainerEq(my_set);
EXPECT_TRUE(m.Matches(my_set));
EXPECT_FALSE(m.Matches(test_set));
// There is nothing to report when both sets contain all the same values.
EXPECT_EQ("", Explain(m, test_set));
}
// Tests that ContainerEq works for non-trivial associative containers,
// like maps.
TEST(ContainerEqExtraTest, WorksForMaps) {
map<int, std::string> my_map;
my_map[0] = "a";
my_map[1] = "b";
map<int, std::string> test_map;
test_map[0] = "aa";
test_map[1] = "b";
const Matcher<const map<int, std::string>&> m = ContainerEq(my_map);
EXPECT_TRUE(m.Matches(my_map));
EXPECT_FALSE(m.Matches(test_map));
EXPECT_EQ(
"which has these unexpected elements: (0, \"aa\"),\n"
"and doesn't have these expected elements: (0, \"a\")",
Explain(m, test_map));
}
TEST(ContainerEqExtraTest, WorksForNativeArray) {
int a1[] = {1, 2, 3};
int a2[] = {1, 2, 3};
int b[] = {1, 2, 4};
EXPECT_THAT(a1, ContainerEq(a2));
EXPECT_THAT(a1, Not(ContainerEq(b)));
}
TEST(ContainerEqExtraTest, WorksForTwoDimensionalNativeArray) {
const char a1[][3] = {"hi", "lo"};
const char a2[][3] = {"hi", "lo"};
const char b[][3] = {"lo", "hi"};
// Tests using ContainerEq() in the first dimension.
EXPECT_THAT(a1, ContainerEq(a2));
EXPECT_THAT(a1, Not(ContainerEq(b)));
// Tests using ContainerEq() in the second dimension.
EXPECT_THAT(a1, ElementsAre(ContainerEq(a2[0]), ContainerEq(a2[1])));
EXPECT_THAT(a1, ElementsAre(Not(ContainerEq(b[0])), ContainerEq(a2[1])));
}
TEST(ContainerEqExtraTest, WorksForNativeArrayAsTuple) {
const int a1[] = {1, 2, 3};
const int a2[] = {1, 2, 3};
const int b[] = {1, 2, 3, 4};
const int* const p1 = a1;
EXPECT_THAT(std::make_tuple(p1, 3), ContainerEq(a2));
EXPECT_THAT(std::make_tuple(p1, 3), Not(ContainerEq(b)));
const int c[] = {1, 3, 2};
EXPECT_THAT(std::make_tuple(p1, 3), Not(ContainerEq(c)));
}
TEST(ContainerEqExtraTest, CopiesNativeArrayParameter) {
std::string a1[][3] = {{"hi", "hello", "ciao"}, {"bye", "see you", "ciao"}};
std::string a2[][3] = {{"hi", "hello", "ciao"}, {"bye", "see you", "ciao"}};
const Matcher<const std::string(&)[2][3]> m = ContainerEq(a2);
EXPECT_THAT(a1, m);
a2[0][0] = "ha";
EXPECT_THAT(a1, m);
}
namespace {
// Used as a check on the more complex max flow method used in the
// real testing::internal::FindMaxBipartiteMatching. This method is
// compatible but runs in worst-case factorial time, so we only
// use it in testing for small problem sizes.
template <typename Graph>
class BacktrackingMaxBPMState {
public:
// Does not take ownership of 'g'.
explicit BacktrackingMaxBPMState(const Graph* g) : graph_(g) {}
ElementMatcherPairs Compute() {
if (graph_->LhsSize() == 0 || graph_->RhsSize() == 0) {
return best_so_far_;
}
lhs_used_.assign(graph_->LhsSize(), kUnused);
rhs_used_.assign(graph_->RhsSize(), kUnused);
for (size_t irhs = 0; irhs < graph_->RhsSize(); ++irhs) {
matches_.clear();
RecurseInto(irhs);
if (best_so_far_.size() == graph_->RhsSize()) break;
}
return best_so_far_;
}
private:
static const size_t kUnused = static_cast<size_t>(-1);
void PushMatch(size_t lhs, size_t rhs) {
matches_.push_back(ElementMatcherPair(lhs, rhs));
lhs_used_[lhs] = rhs;
rhs_used_[rhs] = lhs;
if (matches_.size() > best_so_far_.size()) {
best_so_far_ = matches_;
}
}
void PopMatch() {
const ElementMatcherPair& back = matches_.back();
lhs_used_[back.first] = kUnused;
rhs_used_[back.second] = kUnused;
matches_.pop_back();
}
bool RecurseInto(size_t irhs) {
if (rhs_used_[irhs] != kUnused) {
return true;
}
for (size_t ilhs = 0; ilhs < graph_->LhsSize(); ++ilhs) {
if (lhs_used_[ilhs] != kUnused) {
continue;
}
if (!graph_->HasEdge(ilhs, irhs)) {
continue;
}
PushMatch(ilhs, irhs);
if (best_so_far_.size() == graph_->RhsSize()) {
return false;
}
for (size_t mi = irhs + 1; mi < graph_->RhsSize(); ++mi) {
if (!RecurseInto(mi)) return false;
}
PopMatch();
}
return true;
}
const Graph* graph_; // not owned
std::vector<size_t> lhs_used_;
std::vector<size_t> rhs_used_;
ElementMatcherPairs matches_;
ElementMatcherPairs best_so_far_;
};
template <typename Graph>
const size_t BacktrackingMaxBPMState<Graph>::kUnused;
} // namespace
// Implement a simple backtracking algorithm to determine if it is possible
// to find one element per matcher, without reusing elements.
template <typename Graph>
ElementMatcherPairs FindBacktrackingMaxBPM(const Graph& g) {
return BacktrackingMaxBPMState<Graph>(&g).Compute();
}
class BacktrackingBPMTest : public ::testing::Test {};
// Tests the MaxBipartiteMatching algorithm with square matrices.
// The single int param is the # of nodes on each of the left and right sides.
class BipartiteTest : public ::testing::TestWithParam<size_t> {};
// Verify all match graphs up to some moderate number of edges.
TEST_P(BipartiteTest, Exhaustive) {
size_t nodes = GetParam();
MatchMatrix graph(nodes, nodes);
do {
ElementMatcherPairs matches = internal::FindMaxBipartiteMatching(graph);
EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(), matches.size())
<< "graph: " << graph.DebugString();
// Check that all elements of matches are in the graph.
// Check that elements of first and second are unique.
std::vector<bool> seen_element(graph.LhsSize());
std::vector<bool> seen_matcher(graph.RhsSize());
SCOPED_TRACE(PrintToString(matches));
for (size_t i = 0; i < matches.size(); ++i) {
size_t ilhs = matches[i].first;
size_t irhs = matches[i].second;
EXPECT_TRUE(graph.HasEdge(ilhs, irhs));
EXPECT_FALSE(seen_element[ilhs]);
EXPECT_FALSE(seen_matcher[irhs]);
seen_element[ilhs] = true;
seen_matcher[irhs] = true;
}
} while (graph.NextGraph());
}
INSTANTIATE_TEST_SUITE_P(AllGraphs, BipartiteTest,
::testing::Range(size_t{0}, size_t{5}));
// Parameterized by a pair interpreted as (LhsSize, RhsSize).
class BipartiteNonSquareTest
: public ::testing::TestWithParam<std::pair<size_t, size_t>> {};
TEST_F(BipartiteNonSquareTest, SimpleBacktracking) {
// .......
// 0:-----\ :
// 1:---\ | :
// 2:---\ | :
// 3:-\ | | :
// :.......:
// 0 1 2
MatchMatrix g(4, 3);
constexpr std::array<std::array<size_t, 2>, 4> kEdges = {
{{{0, 2}}, {{1, 1}}, {{2, 1}}, {{3, 0}}}};
for (size_t i = 0; i < kEdges.size(); ++i) {
g.SetEdge(kEdges[i][0], kEdges[i][1], true);
}
EXPECT_THAT(FindBacktrackingMaxBPM(g),
ElementsAre(Pair(3, 0), Pair(AnyOf(1, 2), 1), Pair(0, 2)))
<< g.DebugString();
}
// Verify a few nonsquare matrices.
TEST_P(BipartiteNonSquareTest, Exhaustive) {
size_t nlhs = GetParam().first;
size_t nrhs = GetParam().second;
MatchMatrix graph(nlhs, nrhs);
do {
EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(),
internal::FindMaxBipartiteMatching(graph).size())
<< "graph: " << graph.DebugString()
<< "\nbacktracking: " << PrintToString(FindBacktrackingMaxBPM(graph))
<< "\nmax flow: "
<< PrintToString(internal::FindMaxBipartiteMatching(graph));
} while (graph.NextGraph());
}
INSTANTIATE_TEST_SUITE_P(
AllGraphs, BipartiteNonSquareTest,
testing::Values(std::make_pair(1, 2), std::make_pair(2, 1),
std::make_pair(3, 2), std::make_pair(2, 3),
std::make_pair(4, 1), std::make_pair(1, 4),
std::make_pair(4, 3), std::make_pair(3, 4)));
class BipartiteRandomTest
: public ::testing::TestWithParam<std::pair<int, int>> {};
// Verifies a large sample of larger graphs.
TEST_P(BipartiteRandomTest, LargerNets) {
int nodes = GetParam().first;
int iters = GetParam().second;
MatchMatrix graph(static_cast<size_t>(nodes), static_cast<size_t>(nodes));
auto seed = static_cast<uint32_t>(GTEST_FLAG_GET(random_seed));
if (seed == 0) {
seed = static_cast<uint32_t>(time(nullptr));
}
for (; iters > 0; --iters, ++seed) {
srand(static_cast<unsigned int>(seed));
graph.Randomize();
EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(),
internal::FindMaxBipartiteMatching(graph).size())
<< " graph: " << graph.DebugString()
<< "\nTo reproduce the failure, rerun the test with the flag"
" --"
<< GTEST_FLAG_PREFIX_ << "random_seed=" << seed;
}
}
// Test argument is a std::pair<int, int> representing (nodes, iters).
INSTANTIATE_TEST_SUITE_P(Samples, BipartiteRandomTest,
testing::Values(std::make_pair(5, 10000),
std::make_pair(6, 5000),
std::make_pair(7, 2000),
std::make_pair(8, 500),
std::make_pair(9, 100)));
// Tests IsReadableTypeName().
TEST(IsReadableTypeNameTest, ReturnsTrueForShortNames) {
EXPECT_TRUE(IsReadableTypeName("int"));
EXPECT_TRUE(IsReadableTypeName("const unsigned char*"));
EXPECT_TRUE(IsReadableTypeName("MyMap<int, void*>"));
EXPECT_TRUE(IsReadableTypeName("void (*)(int, bool)"));
}
TEST(IsReadableTypeNameTest, ReturnsTrueForLongNonTemplateNonFunctionNames) {
EXPECT_TRUE(IsReadableTypeName("my_long_namespace::MyClassName"));
EXPECT_TRUE(IsReadableTypeName("int [5][6][7][8][9][10][11]"));
EXPECT_TRUE(IsReadableTypeName("my_namespace::MyOuterClass::MyInnerClass"));
}
TEST(IsReadableTypeNameTest, ReturnsFalseForLongTemplateNames) {
EXPECT_FALSE(
IsReadableTypeName("basic_string<char, std::char_traits<char> >"));
EXPECT_FALSE(IsReadableTypeName("std::vector<int, std::alloc_traits<int> >"));
}
TEST(IsReadableTypeNameTest, ReturnsFalseForLongFunctionTypeNames) {
EXPECT_FALSE(IsReadableTypeName("void (&)(int, bool, char, float)"));
}
// Tests FormatMatcherDescription().
TEST(FormatMatcherDescriptionTest, WorksForEmptyDescription) {
EXPECT_EQ("is even",
FormatMatcherDescription(false, "IsEven", {}, Strings()));
EXPECT_EQ("not (is even)",
FormatMatcherDescription(true, "IsEven", {}, Strings()));
EXPECT_EQ("equals (a: 5)",
FormatMatcherDescription(false, "Equals", {"a"}, {"5"}));
EXPECT_EQ(
"is in range (a: 5, b: 8)",
FormatMatcherDescription(false, "IsInRange", {"a", "b"}, {"5", "8"}));
}
INSTANTIATE_GTEST_MATCHER_TEST_P(MatcherTupleTest);
TEST_P(MatcherTupleTestP, ExplainsMatchFailure) {
stringstream ss1;
ExplainMatchFailureTupleTo(
std::make_tuple(Matcher<char>(Eq('a')), GreaterThan(5)),
std::make_tuple('a', 10), &ss1);
EXPECT_EQ("", ss1.str()); // Successful match.
stringstream ss2;
ExplainMatchFailureTupleTo(
std::make_tuple(GreaterThan(5), Matcher<char>(Eq('a'))),
std::make_tuple(2, 'b'), &ss2);
EXPECT_EQ(
" Expected arg #0: is > 5\n"
" Actual: 2, which is 3 less than 5\n"
" Expected arg #1: is equal to 'a' (97, 0x61)\n"
" Actual: 'b' (98, 0x62)\n",
ss2.str()); // Failed match where both arguments need explanation.
stringstream ss3;
ExplainMatchFailureTupleTo(
std::make_tuple(GreaterThan(5), Matcher<char>(Eq('a'))),
std::make_tuple(2, 'a'), &ss3);
EXPECT_EQ(
" Expected arg #0: is > 5\n"
" Actual: 2, which is 3 less than 5\n",
ss3.str()); // Failed match where only one argument needs
// explanation.
}
// Sample optional type implementation with minimal requirements for use with
// Optional matcher.
template <typename T>
class SampleOptional {
public:
using value_type = T;
explicit SampleOptional(T value)
: value_(std::move(value)), has_value_(true) {}
SampleOptional() : value_(), has_value_(false) {}
operator bool() const { return has_value_; }
const T& operator*() const { return value_; }
private:
T value_;
bool has_value_;
};
TEST(OptionalTest, DescribesSelf) {
const Matcher<SampleOptional<int>> m = Optional(Eq(1));
EXPECT_EQ("value is equal to 1", Describe(m));
}
TEST(OptionalTest, ExplainsSelf) {
const Matcher<SampleOptional<int>> m = Optional(Eq(1));
EXPECT_EQ("whose value 1 matches", Explain(m, SampleOptional<int>(1)));
EXPECT_EQ("whose value 2 doesn't match", Explain(m, SampleOptional<int>(2)));
}
TEST(OptionalTest, MatchesNonEmptyOptional) {
const Matcher<SampleOptional<int>> m1 = Optional(1);
const Matcher<SampleOptional<int>> m2 = Optional(Eq(2));
const Matcher<SampleOptional<int>> m3 = Optional(Lt(3));
SampleOptional<int> opt(1);
EXPECT_TRUE(m1.Matches(opt));
EXPECT_FALSE(m2.Matches(opt));
EXPECT_TRUE(m3.Matches(opt));
}
TEST(OptionalTest, DoesNotMatchNullopt) {
const Matcher<SampleOptional<int>> m = Optional(1);
SampleOptional<int> empty;
EXPECT_FALSE(m.Matches(empty));
}
TEST(OptionalTest, WorksWithMoveOnly) {
Matcher<SampleOptional<std::unique_ptr<int>>> m = Optional(Eq(nullptr));
EXPECT_TRUE(m.Matches(SampleOptional<std::unique_ptr<int>>(nullptr)));
}
class SampleVariantIntString {
public:
SampleVariantIntString(int i) : i_(i), has_int_(true) {}
SampleVariantIntString(const std::string& s) : s_(s), has_int_(false) {}
template <typename T>
friend bool holds_alternative(const SampleVariantIntString& value) {
return value.has_int_ == std::is_same<T, int>::value;
}
template <typename T>
friend const T& get(const SampleVariantIntString& value) {
return value.get_impl(static_cast<T*>(nullptr));
}
private:
const int& get_impl(int*) const { return i_; }
const std::string& get_impl(std::string*) const { return s_; }
int i_;
std::string s_;
bool has_int_;
};
TEST(VariantTest, DescribesSelf) {
const Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
EXPECT_THAT(Describe(m), ContainsRegex("is a variant<> with value of type "
"'.*' and the value is equal to 1"));
}
TEST(VariantTest, ExplainsSelf) {
const Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
EXPECT_THAT(Explain(m, SampleVariantIntString(1)),
ContainsRegex("whose value 1"));
EXPECT_THAT(Explain(m, SampleVariantIntString("A")),
HasSubstr("whose value is not of type '"));
EXPECT_THAT(Explain(m, SampleVariantIntString(2)),
"whose value 2 doesn't match");
}
TEST(VariantTest, FullMatch) {
Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
EXPECT_TRUE(m.Matches(SampleVariantIntString(1)));
m = VariantWith<std::string>(Eq("1"));
EXPECT_TRUE(m.Matches(SampleVariantIntString("1")));
}
TEST(VariantTest, TypeDoesNotMatch) {
Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
EXPECT_FALSE(m.Matches(SampleVariantIntString("1")));
m = VariantWith<std::string>(Eq("1"));
EXPECT_FALSE(m.Matches(SampleVariantIntString(1)));
}
TEST(VariantTest, InnerDoesNotMatch) {
Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
EXPECT_FALSE(m.Matches(SampleVariantIntString(2)));
m = VariantWith<std::string>(Eq("1"));
EXPECT_FALSE(m.Matches(SampleVariantIntString("2")));
}
class SampleAnyType {
public:
explicit SampleAnyType(int i) : index_(0), i_(i) {}
explicit SampleAnyType(const std::string& s) : index_(1), s_(s) {}
template <typename T>
friend const T* any_cast(const SampleAnyType* any) {
return any->get_impl(static_cast<T*>(nullptr));
}
private:
int index_;
int i_;
std::string s_;
const int* get_impl(int*) const { return index_ == 0 ? &i_ : nullptr; }
const std::string* get_impl(std::string*) const {
return index_ == 1 ? &s_ : nullptr;
}
};
TEST(AnyWithTest, FullMatch) {
Matcher<SampleAnyType> m = AnyWith<int>(Eq(1));
EXPECT_TRUE(m.Matches(SampleAnyType(1)));
}
TEST(AnyWithTest, TestBadCastType) {
Matcher<SampleAnyType> m = AnyWith<std::string>(Eq("fail"));
EXPECT_FALSE(m.Matches(SampleAnyType(1)));
}
TEST(AnyWithTest, TestUseInContainers) {
std::vector<SampleAnyType> a;
a.emplace_back(1);
a.emplace_back(2);
a.emplace_back(3);
EXPECT_THAT(
a, ElementsAreArray({AnyWith<int>(1), AnyWith<int>(2), AnyWith<int>(3)}));
std::vector<SampleAnyType> b;
b.emplace_back("hello");
b.emplace_back("merhaba");
b.emplace_back("salut");
EXPECT_THAT(b, ElementsAreArray({AnyWith<std::string>("hello"),
AnyWith<std::string>("merhaba"),
AnyWith<std::string>("salut")}));
}
TEST(AnyWithTest, TestCompare) {
EXPECT_THAT(SampleAnyType(1), AnyWith<int>(Gt(0)));
}
TEST(AnyWithTest, DescribesSelf) {
const Matcher<const SampleAnyType&> m = AnyWith<int>(Eq(1));
EXPECT_THAT(Describe(m), ContainsRegex("is an 'any' type with value of type "
"'.*' and the value is equal to 1"));
}
TEST(AnyWithTest, ExplainsSelf) {
const Matcher<const SampleAnyType&> m = AnyWith<int>(Eq(1));
EXPECT_THAT(Explain(m, SampleAnyType(1)), ContainsRegex("whose value 1"));
EXPECT_THAT(Explain(m, SampleAnyType("A")),
HasSubstr("whose value is not of type '"));
EXPECT_THAT(Explain(m, SampleAnyType(2)), "whose value 2 doesn't match");
}
// Tests Args<k0, ..., kn>(m).
TEST(ArgsTest, AcceptsZeroTemplateArg) {
const std::tuple<int, bool> t(5, true);
EXPECT_THAT(t, Args<>(Eq(std::tuple<>())));
EXPECT_THAT(t, Not(Args<>(Ne(std::tuple<>()))));
}
TEST(ArgsTest, AcceptsOneTemplateArg) {
const std::tuple<int, bool> t(5, true);
EXPECT_THAT(t, Args<0>(Eq(std::make_tuple(5))));
EXPECT_THAT(t, Args<1>(Eq(std::make_tuple(true))));
EXPECT_THAT(t, Not(Args<1>(Eq(std::make_tuple(false)))));
}
TEST(ArgsTest, AcceptsTwoTemplateArgs) {
const std::tuple<short, int, long> t(short{4}, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 1>(Lt())));
EXPECT_THAT(t, (Args<1, 2>(Lt())));
EXPECT_THAT(t, Not(Args<0, 2>(Gt())));
}
TEST(ArgsTest, AcceptsRepeatedTemplateArgs) {
const std::tuple<short, int, long> t(short{4}, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 0>(Eq())));
EXPECT_THAT(t, Not(Args<1, 1>(Ne())));
}
TEST(ArgsTest, AcceptsDecreasingTemplateArgs) {
const std::tuple<short, int, long> t(short{4}, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<2, 0>(Gt())));
EXPECT_THAT(t, Not(Args<2, 1>(Lt())));
}
MATCHER(SumIsZero, "") {
return std::get<0>(arg) + std::get<1>(arg) + std::get<2>(arg) == 0;
}
TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) {
EXPECT_THAT(std::make_tuple(-1, 2), (Args<0, 0, 1>(SumIsZero())));
EXPECT_THAT(std::make_tuple(1, 2), Not(Args<0, 0, 1>(SumIsZero())));
}
TEST(ArgsTest, CanBeNested) {
const std::tuple<short, int, long, int> t(short{4}, 5, 6L, 6); // NOLINT
EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq()))));
EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt()))));
}
TEST(ArgsTest, CanMatchTupleByValue) {
typedef std::tuple<char, int, int> Tuple3;
const Matcher<Tuple3> m = Args<1, 2>(Lt());
EXPECT_TRUE(m.Matches(Tuple3('a', 1, 2)));
EXPECT_FALSE(m.Matches(Tuple3('b', 2, 2)));
}
TEST(ArgsTest, CanMatchTupleByReference) {
typedef std::tuple<char, char, int> Tuple3;
const Matcher<const Tuple3&> m = Args<0, 1>(Lt());
EXPECT_TRUE(m.Matches(Tuple3('a', 'b', 2)));
EXPECT_FALSE(m.Matches(Tuple3('b', 'b', 2)));
}
// Validates that arg is printed as str.
MATCHER_P(PrintsAs, str, "") { return testing::PrintToString(arg) == str; }
TEST(ArgsTest, AcceptsTenTemplateArgs) {
EXPECT_THAT(std::make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
(Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>(
PrintsAs("(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)"))));
EXPECT_THAT(std::make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
Not(Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>(
PrintsAs("(0, 8, 7, 6, 5, 4, 3, 2, 1, 0)"))));
}
TEST(ArgsTest, DescirbesSelfCorrectly) {
const Matcher<std::tuple<int, bool, char>> m = Args<2, 0>(Lt());
EXPECT_EQ(
"are a tuple whose fields (#2, #0) are a pair where "
"the first < the second",
Describe(m));
}
TEST(ArgsTest, DescirbesNestedArgsCorrectly) {
const Matcher<const std::tuple<int, bool, char, int>&> m =
Args<0, 2, 3>(Args<2, 0>(Lt()));
EXPECT_EQ(
"are a tuple whose fields (#0, #2, #3) are a tuple "
"whose fields (#2, #0) are a pair where the first < the second",
Describe(m));
}
TEST(ArgsTest, DescribesNegationCorrectly) {
const Matcher<std::tuple<int, char>> m = Args<1, 0>(Gt());
EXPECT_EQ(
"are a tuple whose fields (#1, #0) aren't a pair "
"where the first > the second",
DescribeNegation(m));
}
TEST(ArgsTest, ExplainsMatchResultWithoutInnerExplanation) {
const Matcher<std::tuple<bool, int, int>> m = Args<1, 2>(Eq());
EXPECT_EQ("whose fields (#1, #2) are (42, 42)",
Explain(m, std::make_tuple(false, 42, 42)));
EXPECT_EQ("whose fields (#1, #2) are (42, 43)",
Explain(m, std::make_tuple(false, 42, 43)));
}
// For testing Args<>'s explanation.
class LessThanMatcher : public MatcherInterface<std::tuple<char, int>> {
public:
void DescribeTo(::std::ostream* /*os*/) const override {}
bool MatchAndExplain(std::tuple<char, int> value,
MatchResultListener* listener) const override {
const int diff = std::get<0>(value) - std::get<1>(value);
if (diff > 0) {
*listener << "where the first value is " << diff
<< " more than the second";
}
return diff < 0;
}
};
Matcher<std::tuple<char, int>> LessThan() {
return MakeMatcher(new LessThanMatcher);
}
TEST(ArgsTest, ExplainsMatchResultWithInnerExplanation) {
const Matcher<std::tuple<char, int, int>> m = Args<0, 2>(LessThan());
EXPECT_EQ(
"whose fields (#0, #2) are ('a' (97, 0x61), 42), "
"where the first value is 55 more than the second",
Explain(m, std::make_tuple('a', 42, 42)));
EXPECT_EQ("whose fields (#0, #2) are ('\\0', 43)",
Explain(m, std::make_tuple('\0', 42, 43)));
}
// Tests for the MATCHER*() macro family.
// Tests that a simple MATCHER() definition works.
MATCHER(IsEven, "") { return (arg % 2) == 0; }
TEST(MatcherMacroTest, Works) {
const Matcher<int> m = IsEven();
EXPECT_TRUE(m.Matches(6));
EXPECT_FALSE(m.Matches(7));
EXPECT_EQ("is even", Describe(m));
EXPECT_EQ("not (is even)", DescribeNegation(m));
EXPECT_EQ("", Explain(m, 6));
EXPECT_EQ("", Explain(m, 7));
}
// This also tests that the description string can reference 'negation'.
MATCHER(IsEven2, negation ? "is odd" : "is even") {
if ((arg % 2) == 0) {
// Verifies that we can stream to result_listener, a listener
// supplied by the MATCHER macro implicitly.
*result_listener << "OK";
return true;
} else {
*result_listener << "% 2 == " << (arg % 2);
return false;
}
}
// This also tests that the description string can reference matcher
// parameters.
MATCHER_P2(EqSumOf, x, y,
std::string(negation ? "doesn't equal" : "equals") + " the sum of " +
PrintToString(x) + " and " + PrintToString(y)) {
if (arg == (x + y)) {
*result_listener << "OK";
return true;
} else {
// Verifies that we can stream to the underlying stream of
// result_listener.
if (result_listener->stream() != nullptr) {
*result_listener->stream() << "diff == " << (x + y - arg);
}
return false;
}
}
// Tests that the matcher description can reference 'negation' and the
// matcher parameters.
TEST(MatcherMacroTest, DescriptionCanReferenceNegationAndParameters) {
const Matcher<int> m1 = IsEven2();
EXPECT_EQ("is even", Describe(m1));
EXPECT_EQ("is odd", DescribeNegation(m1));
const Matcher<int> m2 = EqSumOf(5, 9);
EXPECT_EQ("equals the sum of 5 and 9", Describe(m2));
EXPECT_EQ("doesn't equal the sum of 5 and 9", DescribeNegation(m2));
}
// Tests explaining match result in a MATCHER* macro.
TEST(MatcherMacroTest, CanExplainMatchResult) {
const Matcher<int> m1 = IsEven2();
EXPECT_EQ("OK", Explain(m1, 4));
EXPECT_EQ("% 2 == 1", Explain(m1, 5));
const Matcher<int> m2 = EqSumOf(1, 2);
EXPECT_EQ("OK", Explain(m2, 3));
EXPECT_EQ("diff == -1", Explain(m2, 4));
}
// Tests that the body of MATCHER() can reference the type of the
// value being matched.
MATCHER(IsEmptyString, "") {
StaticAssertTypeEq<::std::string, arg_type>();
return arg.empty();
}
MATCHER(IsEmptyStringByRef, "") {
StaticAssertTypeEq<const ::std::string&, arg_type>();
return arg.empty();
}
TEST(MatcherMacroTest, CanReferenceArgType) {
const Matcher<::std::string> m1 = IsEmptyString();
EXPECT_TRUE(m1.Matches(""));
const Matcher<const ::std::string&> m2 = IsEmptyStringByRef();
EXPECT_TRUE(m2.Matches(""));
}
// Tests that MATCHER() can be used in a namespace.
namespace matcher_test {
MATCHER(IsOdd, "") { return (arg % 2) != 0; }
} // namespace matcher_test
TEST(MatcherMacroTest, WorksInNamespace) {
Matcher<int> m = matcher_test::IsOdd();
EXPECT_FALSE(m.Matches(4));
EXPECT_TRUE(m.Matches(5));
}
// Tests that Value() can be used to compose matchers.
MATCHER(IsPositiveOdd, "") {
return Value(arg, matcher_test::IsOdd()) && arg > 0;
}
TEST(MatcherMacroTest, CanBeComposedUsingValue) {
EXPECT_THAT(3, IsPositiveOdd());
EXPECT_THAT(4, Not(IsPositiveOdd()));
EXPECT_THAT(-1, Not(IsPositiveOdd()));
}
// Tests that a simple MATCHER_P() definition works.
MATCHER_P(IsGreaterThan32And, n, "") { return arg > 32 && arg > n; }
TEST(MatcherPMacroTest, Works) {
const Matcher<int> m = IsGreaterThan32And(5);
EXPECT_TRUE(m.Matches(36));
EXPECT_FALSE(m.Matches(5));
EXPECT_EQ("is greater than 32 and (n: 5)", Describe(m));
EXPECT_EQ("not (is greater than 32 and (n: 5))", DescribeNegation(m));
EXPECT_EQ("", Explain(m, 36));
EXPECT_EQ("", Explain(m, 5));
}
// Tests that the description is calculated correctly from the matcher name.
MATCHER_P(_is_Greater_Than32and_, n, "") { return arg > 32 && arg > n; }
TEST(MatcherPMacroTest, GeneratesCorrectDescription) {
const Matcher<int> m = _is_Greater_Than32and_(5);
EXPECT_EQ("is greater than 32 and (n: 5)", Describe(m));
EXPECT_EQ("not (is greater than 32 and (n: 5))", DescribeNegation(m));
EXPECT_EQ("", Explain(m, 36));
EXPECT_EQ("", Explain(m, 5));
}
// Tests that a MATCHER_P matcher can be explicitly instantiated with
// a reference parameter type.
class UncopyableFoo {
public:
explicit UncopyableFoo(char value) : value_(value) { (void)value_; }
UncopyableFoo(const UncopyableFoo&) = delete;
void operator=(const UncopyableFoo&) = delete;
private:
char value_;
};
MATCHER_P(ReferencesUncopyable, variable, "") { return &arg == &variable; }
TEST(MatcherPMacroTest, WorksWhenExplicitlyInstantiatedWithReference) {
UncopyableFoo foo1('1'), foo2('2');
const Matcher<const UncopyableFoo&> m =
ReferencesUncopyable<const UncopyableFoo&>(foo1);
EXPECT_TRUE(m.Matches(foo1));
EXPECT_FALSE(m.Matches(foo2));
// We don't want the address of the parameter printed, as most
// likely it will just annoy the user. If the address is
// interesting, the user should consider passing the parameter by
// pointer instead.
EXPECT_EQ("references uncopyable (variable: 1-byte object <31>)",
Describe(m));
}
// Tests that the body of MATCHER_Pn() can reference the parameter
// types.
MATCHER_P3(ParamTypesAreIntLongAndChar, foo, bar, baz, "") {
StaticAssertTypeEq<int, foo_type>();
StaticAssertTypeEq<long, bar_type>(); // NOLINT
StaticAssertTypeEq<char, baz_type>();
return arg == 0;
}
TEST(MatcherPnMacroTest, CanReferenceParamTypes) {
EXPECT_THAT(0, ParamTypesAreIntLongAndChar(10, 20L, 'a'));
}
// Tests that a MATCHER_Pn matcher can be explicitly instantiated with
// reference parameter types.
MATCHER_P2(ReferencesAnyOf, variable1, variable2, "") {
return &arg == &variable1 || &arg == &variable2;
}
TEST(MatcherPnMacroTest, WorksWhenExplicitlyInstantiatedWithReferences) {
UncopyableFoo foo1('1'), foo2('2'), foo3('3');
const Matcher<const UncopyableFoo&> const_m =
ReferencesAnyOf<const UncopyableFoo&, const UncopyableFoo&>(foo1, foo2);
EXPECT_TRUE(const_m.Matches(foo1));
EXPECT_TRUE(const_m.Matches(foo2));
EXPECT_FALSE(const_m.Matches(foo3));
const Matcher<UncopyableFoo&> m =
ReferencesAnyOf<UncopyableFoo&, UncopyableFoo&>(foo1, foo2);
EXPECT_TRUE(m.Matches(foo1));
EXPECT_TRUE(m.Matches(foo2));
EXPECT_FALSE(m.Matches(foo3));
}
TEST(MatcherPnMacroTest,
GeneratesCorretDescriptionWhenExplicitlyInstantiatedWithReferences) {
UncopyableFoo foo1('1'), foo2('2');
const Matcher<const UncopyableFoo&> m =
ReferencesAnyOf<const UncopyableFoo&, const UncopyableFoo&>(foo1, foo2);
// We don't want the addresses of the parameters printed, as most
// likely they will just annoy the user. If the addresses are
// interesting, the user should consider passing the parameters by
// pointers instead.
EXPECT_EQ(
"references any of (variable1: 1-byte object <31>, variable2: 1-byte "
"object <32>)",
Describe(m));
}
// Tests that a simple MATCHER_P2() definition works.
MATCHER_P2(IsNotInClosedRange, low, hi, "") { return arg < low || arg > hi; }
TEST(MatcherPnMacroTest, Works) {
const Matcher<const long&> m = IsNotInClosedRange(10, 20); // NOLINT
EXPECT_TRUE(m.Matches(36L));
EXPECT_FALSE(m.Matches(15L));
EXPECT_EQ("is not in closed range (low: 10, hi: 20)", Describe(m));
EXPECT_EQ("not (is not in closed range (low: 10, hi: 20))",
DescribeNegation(m));
EXPECT_EQ("", Explain(m, 36L));
EXPECT_EQ("", Explain(m, 15L));
}
// Tests that MATCHER*() definitions can be overloaded on the number
// of parameters; also tests MATCHER_Pn() where n >= 3.
MATCHER(EqualsSumOf, "") { return arg == 0; }
MATCHER_P(EqualsSumOf, a, "") { return arg == a; }
MATCHER_P2(EqualsSumOf, a, b, "") { return arg == a + b; }
MATCHER_P3(EqualsSumOf, a, b, c, "") { return arg == a + b + c; }
MATCHER_P4(EqualsSumOf, a, b, c, d, "") { return arg == a + b + c + d; }
MATCHER_P5(EqualsSumOf, a, b, c, d, e, "") { return arg == a + b + c + d + e; }
MATCHER_P6(EqualsSumOf, a, b, c, d, e, f, "") {
return arg == a + b + c + d + e + f;
}
MATCHER_P7(EqualsSumOf, a, b, c, d, e, f, g, "") {
return arg == a + b + c + d + e + f + g;
}
MATCHER_P8(EqualsSumOf, a, b, c, d, e, f, g, h, "") {
return arg == a + b + c + d + e + f + g + h;
}
MATCHER_P9(EqualsSumOf, a, b, c, d, e, f, g, h, i, "") {
return arg == a + b + c + d + e + f + g + h + i;
}
MATCHER_P10(EqualsSumOf, a, b, c, d, e, f, g, h, i, j, "") {
return arg == a + b + c + d + e + f + g + h + i + j;
}
TEST(MatcherPnMacroTest, CanBeOverloadedOnNumberOfParameters) {
EXPECT_THAT(0, EqualsSumOf());
EXPECT_THAT(1, EqualsSumOf(1));
EXPECT_THAT(12, EqualsSumOf(10, 2));
EXPECT_THAT(123, EqualsSumOf(100, 20, 3));
EXPECT_THAT(1234, EqualsSumOf(1000, 200, 30, 4));
EXPECT_THAT(12345, EqualsSumOf(10000, 2000, 300, 40, 5));
EXPECT_THAT("abcdef",
EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f'));
EXPECT_THAT("abcdefg",
EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f', 'g'));
EXPECT_THAT("abcdefgh", EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e",
'f', 'g', "h"));
EXPECT_THAT("abcdefghi", EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e",
'f', 'g', "h", 'i'));
EXPECT_THAT("abcdefghij",
EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f', 'g', "h",
'i', ::std::string("j")));
EXPECT_THAT(1, Not(EqualsSumOf()));
EXPECT_THAT(-1, Not(EqualsSumOf(1)));
EXPECT_THAT(-12, Not(EqualsSumOf(10, 2)));
EXPECT_THAT(-123, Not(EqualsSumOf(100, 20, 3)));
EXPECT_THAT(-1234, Not(EqualsSumOf(1000, 200, 30, 4)));
EXPECT_THAT(-12345, Not(EqualsSumOf(10000, 2000, 300, 40, 5)));
EXPECT_THAT("abcdef ",
Not(EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f')));
EXPECT_THAT("abcdefg ", Not(EqualsSumOf(::std::string("a"), 'b', 'c', "d",
"e", 'f', 'g')));
EXPECT_THAT("abcdefgh ", Not(EqualsSumOf(::std::string("a"), 'b', 'c', "d",
"e", 'f', 'g', "h")));
EXPECT_THAT("abcdefghi ", Not(EqualsSumOf(::std::string("a"), 'b', 'c', "d",
"e", 'f', 'g', "h", 'i')));
EXPECT_THAT("abcdefghij ",
Not(EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f', 'g',
"h", 'i', ::std::string("j"))));
}
// Tests that a MATCHER_Pn() definition can be instantiated with any
// compatible parameter types.
TEST(MatcherPnMacroTest, WorksForDifferentParameterTypes) {
EXPECT_THAT(123, EqualsSumOf(100L, 20, static_cast<char>(3)));
EXPECT_THAT("abcd", EqualsSumOf(::std::string("a"), "b", 'c', "d"));
EXPECT_THAT(124, Not(EqualsSumOf(100L, 20, static_cast<char>(3))));
EXPECT_THAT("abcde", Not(EqualsSumOf(::std::string("a"), "b", 'c', "d")));
}
// Tests that the matcher body can promote the parameter types.
MATCHER_P2(EqConcat, prefix, suffix, "") {
// The following lines promote the two parameters to desired types.
std::string prefix_str(prefix);
char suffix_char = static_cast<char>(suffix);
return arg == prefix_str + suffix_char;
}
TEST(MatcherPnMacroTest, SimpleTypePromotion) {
Matcher<std::string> no_promo = EqConcat(std::string("foo"), 't');
Matcher<const std::string&> promo = EqConcat("foo", static_cast<int>('t'));
EXPECT_FALSE(no_promo.Matches("fool"));
EXPECT_FALSE(promo.Matches("fool"));
EXPECT_TRUE(no_promo.Matches("foot"));
EXPECT_TRUE(promo.Matches("foot"));
}
// Verifies the type of a MATCHER*.
TEST(MatcherPnMacroTest, TypesAreCorrect) {
// EqualsSumOf() must be assignable to a EqualsSumOfMatcher variable.
EqualsSumOfMatcher a0 = EqualsSumOf();
// EqualsSumOf(1) must be assignable to a EqualsSumOfMatcherP variable.
EqualsSumOfMatcherP<int> a1 = EqualsSumOf(1);
// EqualsSumOf(p1, ..., pk) must be assignable to a EqualsSumOfMatcherPk
// variable, and so on.
EqualsSumOfMatcherP2<int, char> a2 = EqualsSumOf(1, '2');
EqualsSumOfMatcherP3<int, int, char> a3 = EqualsSumOf(1, 2, '3');
EqualsSumOfMatcherP4<int, int, int, char> a4 = EqualsSumOf(1, 2, 3, '4');
EqualsSumOfMatcherP5<int, int, int, int, char> a5 =
EqualsSumOf(1, 2, 3, 4, '5');
EqualsSumOfMatcherP6<int, int, int, int, int, char> a6 =
EqualsSumOf(1, 2, 3, 4, 5, '6');
EqualsSumOfMatcherP7<int, int, int, int, int, int, char> a7 =
EqualsSumOf(1, 2, 3, 4, 5, 6, '7');
EqualsSumOfMatcherP8<int, int, int, int, int, int, int, char> a8 =
EqualsSumOf(1, 2, 3, 4, 5, 6, 7, '8');
EqualsSumOfMatcherP9<int, int, int, int, int, int, int, int, char> a9 =
EqualsSumOf(1, 2, 3, 4, 5, 6, 7, 8, '9');
EqualsSumOfMatcherP10<int, int, int, int, int, int, int, int, int, char> a10 =
EqualsSumOf(1, 2, 3, 4, 5, 6, 7, 8, 9, '0');
// Avoid "unused variable" warnings.
(void)a0;
(void)a1;
(void)a2;
(void)a3;
(void)a4;
(void)a5;
(void)a6;
(void)a7;
(void)a8;
(void)a9;
(void)a10;
}
// Tests that matcher-typed parameters can be used in Value() inside a
// MATCHER_Pn definition.
// Succeeds if arg matches exactly 2 of the 3 matchers.
MATCHER_P3(TwoOf, m1, m2, m3, "") {
const int count = static_cast<int>(Value(arg, m1)) +
static_cast<int>(Value(arg, m2)) +
static_cast<int>(Value(arg, m3));
return count == 2;
}
TEST(MatcherPnMacroTest, CanUseMatcherTypedParameterInValue) {
EXPECT_THAT(42, TwoOf(Gt(0), Lt(50), Eq(10)));
EXPECT_THAT(0, Not(TwoOf(Gt(-1), Lt(1), Eq(0))));
}
// Tests Contains().Times().
INSTANTIATE_GTEST_MATCHER_TEST_P(ContainsTimes);
TEST(ContainsTimes, ListMatchesWhenElementQuantityMatches) {
list<int> some_list;
some_list.push_back(3);
some_list.push_back(1);
some_list.push_back(2);
some_list.push_back(3);
EXPECT_THAT(some_list, Contains(3).Times(2));
EXPECT_THAT(some_list, Contains(2).Times(1));
EXPECT_THAT(some_list, Contains(Ge(2)).Times(3));
EXPECT_THAT(some_list, Contains(Ge(2)).Times(Gt(2)));
EXPECT_THAT(some_list, Contains(4).Times(0));
EXPECT_THAT(some_list, Contains(_).Times(4));
EXPECT_THAT(some_list, Not(Contains(5).Times(1)));
EXPECT_THAT(some_list, Contains(5).Times(_)); // Times(_) always matches
EXPECT_THAT(some_list, Not(Contains(3).Times(1)));
EXPECT_THAT(some_list, Contains(3).Times(Not(1)));
EXPECT_THAT(list<int>{}, Not(Contains(_)));
}
TEST_P(ContainsTimesP, ExplainsMatchResultCorrectly) {
const int a[2] = {1, 2};
Matcher<const int(&)[2]> m = Contains(2).Times(3);
EXPECT_EQ(
"whose element #1 matches but whose match quantity of 1 does not match",
Explain(m, a));
m = Contains(3).Times(0);
EXPECT_EQ("has no element that matches and whose match quantity of 0 matches",
Explain(m, a));
m = Contains(3).Times(4);
EXPECT_EQ(
"has no element that matches and whose match quantity of 0 does not "
"match",
Explain(m, a));
m = Contains(2).Times(4);
EXPECT_EQ(
"whose element #1 matches but whose match quantity of 1 does not "
"match",
Explain(m, a));
m = Contains(GreaterThan(0)).Times(2);
EXPECT_EQ("whose elements (0, 1) match and whose match quantity of 2 matches",
Explain(m, a));
m = Contains(GreaterThan(10)).Times(Gt(1));
EXPECT_EQ(
"has no element that matches and whose match quantity of 0 does not "
"match",
Explain(m, a));
m = Contains(GreaterThan(0)).Times(GreaterThan<size_t>(5));
EXPECT_EQ(
"whose elements (0, 1) match but whose match quantity of 2 does not "
"match, which is 3 less than 5",
Explain(m, a));
}
TEST(ContainsTimes, DescribesItselfCorrectly) {
Matcher<vector<int>> m = Contains(1).Times(2);
EXPECT_EQ("quantity of elements that match is equal to 1 is equal to 2",
Describe(m));
Matcher<vector<int>> m2 = Not(m);
EXPECT_EQ("quantity of elements that match is equal to 1 isn't equal to 2",
Describe(m2));
}
// Tests AllOfArray()
TEST(AllOfArrayTest, BasicForms) {
// Iterator
std::vector<int> v0{};
std::vector<int> v1{1};
std::vector<int> v2{2, 3};
std::vector<int> v3{4, 4, 4};
EXPECT_THAT(0, AllOfArray(v0.begin(), v0.end()));
EXPECT_THAT(1, AllOfArray(v1.begin(), v1.end()));
EXPECT_THAT(2, Not(AllOfArray(v1.begin(), v1.end())));
EXPECT_THAT(3, Not(AllOfArray(v2.begin(), v2.end())));
EXPECT_THAT(4, AllOfArray(v3.begin(), v3.end()));
// Pointer + size
int ar[6] = {1, 2, 3, 4, 4, 4};
EXPECT_THAT(0, AllOfArray(ar, 0));
EXPECT_THAT(1, AllOfArray(ar, 1));
EXPECT_THAT(2, Not(AllOfArray(ar, 1)));
EXPECT_THAT(3, Not(AllOfArray(ar + 1, 3)));
EXPECT_THAT(4, AllOfArray(ar + 3, 3));
// Array
// int ar0[0]; Not usable
int ar1[1] = {1};
int ar2[2] = {2, 3};
int ar3[3] = {4, 4, 4};
// EXPECT_THAT(0, Not(AllOfArray(ar0))); // Cannot work
EXPECT_THAT(1, AllOfArray(ar1));
EXPECT_THAT(2, Not(AllOfArray(ar1)));
EXPECT_THAT(3, Not(AllOfArray(ar2)));
EXPECT_THAT(4, AllOfArray(ar3));
// Container
EXPECT_THAT(0, AllOfArray(v0));
EXPECT_THAT(1, AllOfArray(v1));
EXPECT_THAT(2, Not(AllOfArray(v1)));
EXPECT_THAT(3, Not(AllOfArray(v2)));
EXPECT_THAT(4, AllOfArray(v3));
// Initializer
EXPECT_THAT(0, AllOfArray<int>({})); // Requires template arg.
EXPECT_THAT(1, AllOfArray({1}));
EXPECT_THAT(2, Not(AllOfArray({1})));
EXPECT_THAT(3, Not(AllOfArray({2, 3})));
EXPECT_THAT(4, AllOfArray({4, 4, 4}));
}
TEST(AllOfArrayTest, Matchers) {
// vector
std::vector<Matcher<int>> matchers{Ge(1), Lt(2)};
EXPECT_THAT(0, Not(AllOfArray(matchers)));
EXPECT_THAT(1, AllOfArray(matchers));
EXPECT_THAT(2, Not(AllOfArray(matchers)));
// initializer_list
EXPECT_THAT(0, Not(AllOfArray({Ge(0), Ge(1)})));
EXPECT_THAT(1, AllOfArray({Ge(0), Ge(1)}));
}
INSTANTIATE_GTEST_MATCHER_TEST_P(AnyOfArrayTest);
TEST(AnyOfArrayTest, BasicForms) {
// Iterator
std::vector<int> v0{};
std::vector<int> v1{1};
std::vector<int> v2{2, 3};
EXPECT_THAT(0, Not(AnyOfArray(v0.begin(), v0.end())));
EXPECT_THAT(1, AnyOfArray(v1.begin(), v1.end()));
EXPECT_THAT(2, Not(AnyOfArray(v1.begin(), v1.end())));
EXPECT_THAT(3, AnyOfArray(v2.begin(), v2.end()));
EXPECT_THAT(4, Not(AnyOfArray(v2.begin(), v2.end())));
// Pointer + size
int ar[3] = {1, 2, 3};
EXPECT_THAT(0, Not(AnyOfArray(ar, 0)));
EXPECT_THAT(1, AnyOfArray(ar, 1));
EXPECT_THAT(2, Not(AnyOfArray(ar, 1)));
EXPECT_THAT(3, AnyOfArray(ar + 1, 2));
EXPECT_THAT(4, Not(AnyOfArray(ar + 1, 2)));
// Array
// int ar0[0]; Not usable
int ar1[1] = {1};
int ar2[2] = {2, 3};
// EXPECT_THAT(0, Not(AnyOfArray(ar0))); // Cannot work
EXPECT_THAT(1, AnyOfArray(ar1));
EXPECT_THAT(2, Not(AnyOfArray(ar1)));
EXPECT_THAT(3, AnyOfArray(ar2));
EXPECT_THAT(4, Not(AnyOfArray(ar2)));
// Container
EXPECT_THAT(0, Not(AnyOfArray(v0)));
EXPECT_THAT(1, AnyOfArray(v1));
EXPECT_THAT(2, Not(AnyOfArray(v1)));
EXPECT_THAT(3, AnyOfArray(v2));
EXPECT_THAT(4, Not(AnyOfArray(v2)));
// Initializer
EXPECT_THAT(0, Not(AnyOfArray<int>({}))); // Requires template arg.
EXPECT_THAT(1, AnyOfArray({1}));
EXPECT_THAT(2, Not(AnyOfArray({1})));
EXPECT_THAT(3, AnyOfArray({2, 3}));
EXPECT_THAT(4, Not(AnyOfArray({2, 3})));
}
TEST(AnyOfArrayTest, Matchers) {
// We negate test AllOfArrayTest.Matchers.
// vector
std::vector<Matcher<int>> matchers{Lt(1), Ge(2)};
EXPECT_THAT(0, AnyOfArray(matchers));
EXPECT_THAT(1, Not(AnyOfArray(matchers)));
EXPECT_THAT(2, AnyOfArray(matchers));
// initializer_list
EXPECT_THAT(0, AnyOfArray({Lt(0), Lt(1)}));
EXPECT_THAT(1, Not(AllOfArray({Lt(0), Lt(1)})));
}
TEST_P(AnyOfArrayTestP, ExplainsMatchResultCorrectly) {
// AnyOfArray and AllOfArray use the same underlying template-template,
// thus it is sufficient to test one here.
const std::vector<int> v0{};
const std::vector<int> v1{1};
const std::vector<int> v2{2, 3};
const Matcher<int> m0 = AnyOfArray(v0);
const Matcher<int> m1 = AnyOfArray(v1);
const Matcher<int> m2 = AnyOfArray(v2);
EXPECT_EQ("", Explain(m0, 0));
EXPECT_EQ("", Explain(m1, 1));
EXPECT_EQ("", Explain(m1, 2));
EXPECT_EQ("", Explain(m2, 3));
EXPECT_EQ("", Explain(m2, 4));
EXPECT_EQ("()", Describe(m0));
EXPECT_EQ("(is equal to 1)", Describe(m1));
EXPECT_EQ("(is equal to 2) or (is equal to 3)", Describe(m2));
EXPECT_EQ("()", DescribeNegation(m0));
EXPECT_EQ("(isn't equal to 1)", DescribeNegation(m1));
EXPECT_EQ("(isn't equal to 2) and (isn't equal to 3)", DescribeNegation(m2));
// Explain with matchers
const Matcher<int> g1 = AnyOfArray({GreaterThan(1)});
const Matcher<int> g2 = AnyOfArray({GreaterThan(1), GreaterThan(2)});
// Explains the first positive match and all prior negative matches...
EXPECT_EQ("which is 1 less than 1", Explain(g1, 0));
EXPECT_EQ("which is the same as 1", Explain(g1, 1));
EXPECT_EQ("which is 1 more than 1", Explain(g1, 2));
EXPECT_EQ("which is 1 less than 1, and which is 2 less than 2",
Explain(g2, 0));
EXPECT_EQ("which is the same as 1, and which is 1 less than 2",
Explain(g2, 1));
EXPECT_EQ("which is 1 more than 1", // Only the first
Explain(g2, 2));
}
MATCHER(IsNotNull, "") { return arg != nullptr; }
// Verifies that a matcher defined using MATCHER() can work on
// move-only types.
TEST(MatcherMacroTest, WorksOnMoveOnlyType) {
std::unique_ptr<int> p(new int(3));
EXPECT_THAT(p, IsNotNull());
EXPECT_THAT(std::unique_ptr<int>(), Not(IsNotNull()));
}
MATCHER_P(UniquePointee, pointee, "") { return *arg == pointee; }
// Verifies that a matcher defined using MATCHER_P*() can work on
// move-only types.
TEST(MatcherPMacroTest, WorksOnMoveOnlyType) {
std::unique_ptr<int> p(new int(3));
EXPECT_THAT(p, UniquePointee(3));
EXPECT_THAT(p, Not(UniquePointee(2)));
}
MATCHER(EnsureNoUnusedButMarkedUnusedWarning, "") { return (arg % 2) == 0; }
TEST(MockMethodMockFunctionTest, EnsureNoUnusedButMarkedUnusedWarning) {
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic error "-Wused-but-marked-unused"
#endif
// https://github.com/google/googletest/issues/4055
EXPECT_THAT(0, EnsureNoUnusedButMarkedUnusedWarning());
#ifdef __clang__
#pragma clang diagnostic pop
#endif
}
#if GTEST_HAS_EXCEPTIONS
// std::function<void()> is used below for compatibility with older copies of
// GCC. Normally, a raw lambda is all that is needed.
// Test that examples from documentation compile
TEST(ThrowsTest, Examples) {
EXPECT_THAT(
std::function<void()>([]() { throw std::runtime_error("message"); }),
Throws<std::runtime_error>());
EXPECT_THAT(
std::function<void()>([]() { throw std::runtime_error("message"); }),
ThrowsMessage<std::runtime_error>(HasSubstr("message")));
}
TEST(ThrowsTest, PrintsExceptionWhat) {
EXPECT_THAT(
std::function<void()>([]() { throw std::runtime_error("ABC123XYZ"); }),
ThrowsMessage<std::runtime_error>(HasSubstr("ABC123XYZ")));
}
TEST(ThrowsTest, DoesNotGenerateDuplicateCatchClauseWarning) {
EXPECT_THAT(std::function<void()>([]() { throw std::exception(); }),
Throws<std::exception>());
}
TEST(ThrowsTest, CallableExecutedExactlyOnce) {
size_t a = 0;
EXPECT_THAT(std::function<void()>([&a]() {
a++;
throw 10;
}),
Throws<int>());
EXPECT_EQ(a, 1u);
EXPECT_THAT(std::function<void()>([&a]() {
a++;
throw std::runtime_error("message");
}),
Throws<std::runtime_error>());
EXPECT_EQ(a, 2u);
EXPECT_THAT(std::function<void()>([&a]() {
a++;
throw std::runtime_error("message");
}),
ThrowsMessage<std::runtime_error>(HasSubstr("message")));
EXPECT_EQ(a, 3u);
EXPECT_THAT(std::function<void()>([&a]() {
a++;
throw std::runtime_error("message");
}),
Throws<std::runtime_error>(
Property(&std::runtime_error::what, HasSubstr("message"))));
EXPECT_EQ(a, 4u);
}
TEST(ThrowsTest, Describe) {
Matcher<std::function<void()>> matcher = Throws<std::runtime_error>();
std::stringstream ss;
matcher.DescribeTo(&ss);
auto explanation = ss.str();
EXPECT_THAT(explanation, HasSubstr("std::runtime_error"));
}
TEST(ThrowsTest, Success) {
Matcher<std::function<void()>> matcher = Throws<std::runtime_error>();
StringMatchResultListener listener;
EXPECT_TRUE(matcher.MatchAndExplain(
[]() { throw std::runtime_error("error message"); }, &listener));
EXPECT_THAT(listener.str(), HasSubstr("std::runtime_error"));
}
TEST(ThrowsTest, FailWrongType) {
Matcher<std::function<void()>> matcher = Throws<std::runtime_error>();
StringMatchResultListener listener;
EXPECT_FALSE(matcher.MatchAndExplain(
[]() { throw std::logic_error("error message"); }, &listener));
EXPECT_THAT(listener.str(), HasSubstr("std::logic_error"));
EXPECT_THAT(listener.str(), HasSubstr("\"error message\""));
}
TEST(ThrowsTest, FailWrongTypeNonStd) {
Matcher<std::function<void()>> matcher = Throws<std::runtime_error>();
StringMatchResultListener listener;
EXPECT_FALSE(matcher.MatchAndExplain([]() { throw 10; }, &listener));
EXPECT_THAT(listener.str(),
HasSubstr("throws an exception of an unknown type"));
}
TEST(ThrowsTest, FailNoThrow) {
Matcher<std::function<void()>> matcher = Throws<std::runtime_error>();
StringMatchResultListener listener;
EXPECT_FALSE(matcher.MatchAndExplain([]() { (void)0; }, &listener));
EXPECT_THAT(listener.str(), HasSubstr("does not throw any exception"));
}
class ThrowsPredicateTest
: public TestWithParam<Matcher<std::function<void()>>> {};
TEST_P(ThrowsPredicateTest, Describe) {
Matcher<std::function<void()>> matcher = GetParam();
std::stringstream ss;
matcher.DescribeTo(&ss);
auto explanation = ss.str();
EXPECT_THAT(explanation, HasSubstr("std::runtime_error"));
EXPECT_THAT(explanation, HasSubstr("error message"));
}
TEST_P(ThrowsPredicateTest, Success) {
Matcher<std::function<void()>> matcher = GetParam();
StringMatchResultListener listener;
EXPECT_TRUE(matcher.MatchAndExplain(
[]() { throw std::runtime_error("error message"); }, &listener));
EXPECT_THAT(listener.str(), HasSubstr("std::runtime_error"));
}
TEST_P(ThrowsPredicateTest, FailWrongType) {
Matcher<std::function<void()>> matcher = GetParam();
StringMatchResultListener listener;
EXPECT_FALSE(matcher.MatchAndExplain(
[]() { throw std::logic_error("error message"); }, &listener));
EXPECT_THAT(listener.str(), HasSubstr("std::logic_error"));
EXPECT_THAT(listener.str(), HasSubstr("\"error message\""));
}
TEST_P(ThrowsPredicateTest, FailWrongTypeNonStd) {
Matcher<std::function<void()>> matcher = GetParam();
StringMatchResultListener listener;
EXPECT_FALSE(matcher.MatchAndExplain([]() { throw 10; }, &listener));
EXPECT_THAT(listener.str(),
HasSubstr("throws an exception of an unknown type"));
}
TEST_P(ThrowsPredicateTest, FailNoThrow) {
Matcher<std::function<void()>> matcher = GetParam();
StringMatchResultListener listener;
EXPECT_FALSE(matcher.MatchAndExplain([]() {}, &listener));
EXPECT_THAT(listener.str(), HasSubstr("does not throw any exception"));
}
INSTANTIATE_TEST_SUITE_P(
AllMessagePredicates, ThrowsPredicateTest,
Values(Matcher<std::function<void()>>(
ThrowsMessage<std::runtime_error>(HasSubstr("error message")))));
// Tests that Throws<E1>(Matcher<E2>{}) compiles even when E2 != const E1&.
TEST(ThrowsPredicateCompilesTest, ExceptionMatcherAcceptsBroadType) {
{
Matcher<std::function<void()>> matcher =
ThrowsMessage<std::runtime_error>(HasSubstr("error message"));
EXPECT_TRUE(
matcher.Matches([]() { throw std::runtime_error("error message"); }));
EXPECT_FALSE(
matcher.Matches([]() { throw std::runtime_error("wrong message"); }));
}
{
Matcher<uint64_t> inner = Eq(10);
Matcher<std::function<void()>> matcher = Throws<uint32_t>(inner);
EXPECT_TRUE(matcher.Matches([]() { throw (uint32_t)10; }));
EXPECT_FALSE(matcher.Matches([]() { throw (uint32_t)11; }));
}
}
// Tests that ThrowsMessage("message") is equivalent
// to ThrowsMessage(Eq<std::string>("message")).
TEST(ThrowsPredicateCompilesTest, MessageMatcherAcceptsNonMatcher) {
Matcher<std::function<void()>> matcher =
ThrowsMessage<std::runtime_error>("error message");
EXPECT_TRUE(
matcher.Matches([]() { throw std::runtime_error("error message"); }));
EXPECT_FALSE(matcher.Matches(
[]() { throw std::runtime_error("wrong error message"); }));
}
#endif // GTEST_HAS_EXCEPTIONS
} // namespace
} // namespace gmock_matchers_test
} // namespace testing
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4244 4100
| [
"a.bernede@woptim.dev"
] | a.bernede@woptim.dev |
e7778d50218d393dbcda3a679c3566da81572816 | 589751b2c5b2ff224645a229cd1a46efc9410baf | /zlibrary/core/src/util/ZLKeyUtil.cpp | 512fd780a52e7837ba5f65ae8dadbc2765c75d42 | [] | no_license | temper8/Tizen-FBReader | aec1f4f880ef548cbafbe88d057048b32a863b01 | fe7b46bbd7ff33ea5aab13c81c30b3e7c91efa20 | refs/heads/master | 2020-04-12T07:33:46.833871 | 2014-12-23T01:36:48 | 2014-12-23T01:36:48 | 27,797,376 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,267 | cpp | /*
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#include <stdlib.h>
#include <cctype>
#include <ZLUnicodeUtil.h>
#include <ZLStringUtil.h>
#include <ZLFile.h>
//#include <ZLXMLReader.h>
#include <ZLibrary.h>
#include "ZLKeyUtil.h"
bool ZLKeyUtil::ourInitialized = false;
bool ZLKeyUtil::ourUseAutoNames = true;
std::map<int,std::string> ZLKeyUtil::ourNames;
std::map<int,std::string> ZLKeyUtil::ourModifiers;
std::string ZLKeyUtil::ourKeyNamesFileName = "keynames.xml";
void ZLKeyUtil::setKeyNamesFileName(const std::string &fileName) {
ourKeyNamesFileName = fileName;
}
/*
class KeyNamesReader : public ZLXMLReader {
private:
void startElementHandler(const char *tag, const char **attributes);
};
void KeyNamesReader::startElementHandler(const char *tag, const char **attributes) {
static const std::string KEY = "key";
static const std::string MODIFIER = "modifier";
const char *disableAutoNames = attributeValue(attributes, "disableAutoNames");
if ((disableAutoNames != 0) && ((std::string("true") == disableAutoNames))) {
ZLKeyUtil::ourUseAutoNames = false;
}
const char *codeString = attributeValue(attributes, "code");
const char *name = attributeValue(attributes, "name");
if ((codeString != 0) && (name != 0)) {
if (KEY == tag) {
ZLKeyUtil::ourNames[strtol(codeString, 0, 16)] = name;
} else if (MODIFIER == tag) {
ZLKeyUtil::ourModifiers[strtol(codeString, 0, 16)] = name;
}
}
}
*/
std::string ZLKeyUtil::keyName(int unicode, int key, int modifiersMask) {
if (!ourInitialized) {
//TODO KeyNamesReader().readDocument(ZLFile(ZLibrary::ZLibraryDirectory() + ZLibrary::FileNameDelimiter + ourKeyNamesFileName));
ourInitialized = true;
}
std::string name;
std::map<int,std::string>::const_iterator it = ourNames.find(key);
if (it != ourNames.end()) {
name = it->second;
}
if (ourUseAutoNames && name.empty()) {
if (((unicode < 128) && isprint(unicode) && !isspace(unicode)) || ZLUnicodeUtil::isLetter(unicode)) {
name += '<';
char buf[5];
name.append(buf, ZLUnicodeUtil::ucs4ToUtf8(buf, ZLUnicodeUtil::toUpper(unicode)));
name += '>';
}
}
if (name.empty()) {
name += '[';
ZLStringUtil::appendNumber(name, key);
name += ']';
}
for (std::map<int,std::string>::iterator it = ourModifiers.begin(); it != ourModifiers.end(); ++it) {
if ((modifiersMask & it->first) == it->first) {
name = it->second + "+" + name;
}
}
return name;
}
| [
"temper8@gmail.com"
] | temper8@gmail.com |
0c12b6343ad9b9675b50a63b53d36f43b78da3b8 | 0911178d2bafe0e4c7aad63a7702327c44dc8fb5 | /src/devel/include/franka_gripper/HomingActionResult.h | 58712aa6b66a1e12dc20eda44e1ef5532ac1e312 | [] | no_license | yscholty/yannic_robot | 18f1f8b269064209bc939430f2fd1a2f02499bc0 | ed065951bc554968e134db3766671ef004f10408 | refs/heads/main | 2023-06-20T15:00:27.871702 | 2021-07-15T14:07:39 | 2021-07-15T14:07:39 | 363,857,722 | 1 | 0 | null | 2021-06-14T13:34:19 | 2021-05-03T08:00:48 | Makefile | UTF-8 | C++ | false | false | 9,405 | h | // Generated by gencpp from file franka_gripper/HomingActionResult.msg
// DO NOT EDIT!
#ifndef FRANKA_GRIPPER_MESSAGE_HOMINGACTIONRESULT_H
#define FRANKA_GRIPPER_MESSAGE_HOMINGACTIONRESULT_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
#include <std_msgs/Header.h>
#include <actionlib_msgs/GoalStatus.h>
#include <franka_gripper/HomingResult.h>
namespace franka_gripper
{
template <class ContainerAllocator>
struct HomingActionResult_
{
typedef HomingActionResult_<ContainerAllocator> Type;
HomingActionResult_()
: header()
, status()
, result() {
}
HomingActionResult_(const ContainerAllocator& _alloc)
: header(_alloc)
, status(_alloc)
, result(_alloc) {
(void)_alloc;
}
typedef ::std_msgs::Header_<ContainerAllocator> _header_type;
_header_type header;
typedef ::actionlib_msgs::GoalStatus_<ContainerAllocator> _status_type;
_status_type status;
typedef ::franka_gripper::HomingResult_<ContainerAllocator> _result_type;
_result_type result;
typedef boost::shared_ptr< ::franka_gripper::HomingActionResult_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::franka_gripper::HomingActionResult_<ContainerAllocator> const> ConstPtr;
}; // struct HomingActionResult_
typedef ::franka_gripper::HomingActionResult_<std::allocator<void> > HomingActionResult;
typedef boost::shared_ptr< ::franka_gripper::HomingActionResult > HomingActionResultPtr;
typedef boost::shared_ptr< ::franka_gripper::HomingActionResult const> HomingActionResultConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::franka_gripper::HomingActionResult_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::franka_gripper::HomingActionResult_<ContainerAllocator> >::stream(s, "", v);
return s;
}
template<typename ContainerAllocator1, typename ContainerAllocator2>
bool operator==(const ::franka_gripper::HomingActionResult_<ContainerAllocator1> & lhs, const ::franka_gripper::HomingActionResult_<ContainerAllocator2> & rhs)
{
return lhs.header == rhs.header &&
lhs.status == rhs.status &&
lhs.result == rhs.result;
}
template<typename ContainerAllocator1, typename ContainerAllocator2>
bool operator!=(const ::franka_gripper::HomingActionResult_<ContainerAllocator1> & lhs, const ::franka_gripper::HomingActionResult_<ContainerAllocator2> & rhs)
{
return !(lhs == rhs);
}
} // namespace franka_gripper
namespace ros
{
namespace message_traits
{
template <class ContainerAllocator>
struct IsMessage< ::franka_gripper::HomingActionResult_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::franka_gripper::HomingActionResult_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::franka_gripper::HomingActionResult_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::franka_gripper::HomingActionResult_<ContainerAllocator> const>
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::franka_gripper::HomingActionResult_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::franka_gripper::HomingActionResult_<ContainerAllocator> const>
: TrueType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::franka_gripper::HomingActionResult_<ContainerAllocator> >
{
static const char* value()
{
return "89dbc4e75593b525bbbea3a150532ed6";
}
static const char* value(const ::franka_gripper::HomingActionResult_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0x89dbc4e75593b525ULL;
static const uint64_t static_value2 = 0xbbbea3a150532ed6ULL;
};
template<class ContainerAllocator>
struct DataType< ::franka_gripper::HomingActionResult_<ContainerAllocator> >
{
static const char* value()
{
return "franka_gripper/HomingActionResult";
}
static const char* value(const ::franka_gripper::HomingActionResult_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::franka_gripper::HomingActionResult_<ContainerAllocator> >
{
static const char* value()
{
return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n"
"\n"
"Header header\n"
"actionlib_msgs/GoalStatus status\n"
"HomingResult result\n"
"\n"
"================================================================================\n"
"MSG: std_msgs/Header\n"
"# Standard metadata for higher-level stamped data types.\n"
"# This is generally used to communicate timestamped data \n"
"# in a particular coordinate frame.\n"
"# \n"
"# sequence ID: consecutively increasing ID \n"
"uint32 seq\n"
"#Two-integer timestamp that is expressed as:\n"
"# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n"
"# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n"
"# time-handling sugar is provided by the client library\n"
"time stamp\n"
"#Frame this data is associated with\n"
"string frame_id\n"
"\n"
"================================================================================\n"
"MSG: actionlib_msgs/GoalStatus\n"
"GoalID goal_id\n"
"uint8 status\n"
"uint8 PENDING = 0 # The goal has yet to be processed by the action server\n"
"uint8 ACTIVE = 1 # The goal is currently being processed by the action server\n"
"uint8 PREEMPTED = 2 # The goal received a cancel request after it started executing\n"
" # and has since completed its execution (Terminal State)\n"
"uint8 SUCCEEDED = 3 # The goal was achieved successfully by the action server (Terminal State)\n"
"uint8 ABORTED = 4 # The goal was aborted during execution by the action server due\n"
" # to some failure (Terminal State)\n"
"uint8 REJECTED = 5 # The goal was rejected by the action server without being processed,\n"
" # because the goal was unattainable or invalid (Terminal State)\n"
"uint8 PREEMPTING = 6 # The goal received a cancel request after it started executing\n"
" # and has not yet completed execution\n"
"uint8 RECALLING = 7 # The goal received a cancel request before it started executing,\n"
" # but the action server has not yet confirmed that the goal is canceled\n"
"uint8 RECALLED = 8 # The goal received a cancel request before it started executing\n"
" # and was successfully cancelled (Terminal State)\n"
"uint8 LOST = 9 # An action client can determine that a goal is LOST. This should not be\n"
" # sent over the wire by an action server\n"
"\n"
"#Allow for the user to associate a string with GoalStatus for debugging\n"
"string text\n"
"\n"
"\n"
"================================================================================\n"
"MSG: actionlib_msgs/GoalID\n"
"# The stamp should store the time at which this goal was requested.\n"
"# It is used by an action server when it tries to preempt all\n"
"# goals that were requested before a certain time\n"
"time stamp\n"
"\n"
"# The id provides a way to associate feedback and\n"
"# result message with specific goal requests. The id\n"
"# specified must be unique.\n"
"string id\n"
"\n"
"\n"
"================================================================================\n"
"MSG: franka_gripper/HomingResult\n"
"# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n"
"bool success\n"
"string error\n"
;
}
static const char* value(const ::franka_gripper::HomingActionResult_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::franka_gripper::HomingActionResult_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.header);
stream.next(m.status);
stream.next(m.result);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct HomingActionResult_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::franka_gripper::HomingActionResult_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::franka_gripper::HomingActionResult_<ContainerAllocator>& v)
{
s << indent << "header: ";
s << std::endl;
Printer< ::std_msgs::Header_<ContainerAllocator> >::stream(s, indent + " ", v.header);
s << indent << "status: ";
s << std::endl;
Printer< ::actionlib_msgs::GoalStatus_<ContainerAllocator> >::stream(s, indent + " ", v.status);
s << indent << "result: ";
s << std::endl;
Printer< ::franka_gripper::HomingResult_<ContainerAllocator> >::stream(s, indent + " ", v.result);
}
};
} // namespace message_operations
} // namespace ros
#endif // FRANKA_GRIPPER_MESSAGE_HOMINGACTIONRESULT_H
| [
"yscholty@aol.com"
] | yscholty@aol.com |
266ad9776669ff58d7a79d9c07b0a20e3f1c8fc1 | 10e6dcf44471dc0b067d28b26243597d1cce6115 | /AnaModules/LArNeutrinoAna_module.cc | fe3fae59bf1e50c075cb6bce6928afe0bd357c76 | [] | no_license | SFBayLaser/uboonedev | e74d731ae6ba1d2906a2ceb71d5e271246dd53e2 | e8185ec205d98669da3d8c8102aa803ec240fbd8 | refs/heads/master | 2020-04-06T05:10:45.660399 | 2015-10-27T01:23:23 | 2015-10-27T01:23:23 | 36,940,805 | 0 | 3 | null | 2017-03-03T20:50:42 | 2015-06-05T15:40:43 | C++ | UTF-8 | C++ | false | false | 41,702 | cc | // LArNeutrinoAna_module.cc
// A basic "skeleton" to read in art::Event records from a file,
// access their information, and do something with them.
// See
// <https://cdcvs.fnal.gov/redmine/projects/larsoftsvn/wiki/Using_the_Framework>
// for a description of the ART classes used here.
// Almost everything you see in the code below may have to be changed
// by you to suit your task. The example task is to make histograms
// and n-tuples related to dE/dx of particle tracks in the detector.
// As you try to understand why things are done a certain way in this
// example ("What's all this stuff about 'auto const&'?"), it will help
// to read ADDITIONAL_NOTES.txt in the same directory as this file.
#ifndef LArNeutrinoAna_module
#define LArNeutrinoAna_module
// LArSoft includes
#include "Simulation/SimChannel.h"
#include "Simulation/LArG4Parameters.h"
#include "RecoBase/Hit.h"
#include "RecoBase/Cluster.h"
#include "RecoBase/Track.h"
#include "RecoBase/PFParticle.h"
#include "AnalysisBase/CosmicTag.h"
#include "Utilities/DetectorProperties.h"
#include "Utilities/LArProperties.h"
#include "Geometry/Geometry.h"
#include "SimulationBase/MCParticle.h"
#include "SimulationBase/MCTruth.h"
#include "SimulationBase/MCNeutrino.h"
#include "SimpleTypesAndConstants/geo_types.h"
#include "MCBase/MCHitCollection.h"
//#include "cetlib/search_path.h"
#include "cetlib/cpu_timer.h"
#include "Utilities/TimeService.h"
#include "Utilities/AssociationUtil.h"
// Framework includes
#include "art/Framework/Core/EDAnalyzer.h"
#include "art/Framework/Principal/Event.h"
#include "art/Framework/Principal/Handle.h"
#include "art/Framework/Principal/View.h"
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "art/Framework/Services/Optional/TFileService.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "art/Framework/Core/FindManyP.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include "fhiclcpp/ParameterSet.h"
#include "cetlib/exception.h"
// ROOT includes. Note: To look up the properties of the ROOT classes,
// use the ROOT web site; e.g.,
// <http://root.cern.ch/root/html532/ClassIndex.html>
#include "TH1.h"
#include "TH2.h"
#include "TProfile.h"
#include "TTree.h"
#include "TLorentzVector.h"
#include "TVector3.h"
// C++ Includes
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
namespace LArNeutrinoAna
{
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// class definition
class LArNeutrinoAna : public art::EDAnalyzer
{
public:
// Standard constructor and destructor for an ART module.
explicit LArNeutrinoAna(fhicl::ParameterSet const& pset);
virtual ~LArNeutrinoAna();
// This method is called once, at the start of the job. In this
// example, it will define the histograms and n-tuples we'll write.
void beginJob();
// This method is called once, at the start of each run. It's a
// good place to read databases or files that may have
// run-dependent information.
void beginRun(const art::Run& run);
// This method reads in any parameters from the .fcl files. This
// method is called 'reconfigure' because it might be called in the
// middle of a job; e.g., if the user changes parameter values in an
// interactive event display.
void reconfigure(fhicl::ParameterSet const& pset);
// The analysis routine, called once per event.
void analyze (const art::Event& evt);
private:
// Calculate lengths
double length(const recob::Track* track);
double length(const simb::MCParticle& part, double dx,
TVector3& start, TVector3& end, TVector3& startmom, TVector3& endmom,
unsigned int tpc = 0, unsigned int cstat = 0);
// The stuff below is the part you'll most likely have to change to
// go from this custom example to your own task.
typedef std::map< const recob::Hit*, std::set<int> > HitToParticleMap;
typedef std::map< int, std::set<const recob::Hit*> > ParticleToHitMap;
typedef std::vector< art::Ptr<recob::Hit> > HitVector;
// The parameters we'll read from the .fcl file.
std::string fSimulationProducerLabel; // The name of the producer that tracked simulated particles through the detector
std::string fMcHitCollectionModuleLabel; //> The name of the producer of MCHits
std::string fPFParticleProducerLabel; // The name of the produder of the PFParticle hierarchy
std::string fHitProducerLabel; // The name of the producer that created hits
std::string fClusterProducerLabel; // The name of the producer that created clusters
std::string fTrackProducerLabel; // The name of the producer that created the tracks
std::string fCosmicProducerLabel; // The name of the producer that created cosmic tags
std::string fFlashProducerLabel; // The name of the producer that created flash tags
int fSelectedPDG; // PDG code of particle we'll focus on
// Pointers to the histograms we'll create.
// The variables that will go into the n-tuple.
int fEvent;
int fRun;
int fSubRun;
// Other variables that will be shared between different methods.
art::ServiceHandle<geo::Geometry> fGeometry; // pointer to Geometry service
double fElectronsToGeV; // conversion factor
// Define histograms here
TH1D* fMuonRange;
TH1D* fProtonRange;
TH1D* fOtherRange;
TH1D* fMuonRangeMC;
TH1D* fProtonRangeMC;
TH1D* fOtherRangeMC;
TH1D* fMuonDeltaRange;
TH1D* fProtonDeltaRange;
TH1D* fOtherDeltaRange;
TProfile* fMuonEffVsRange;
TProfile* fProtonEffVsRange;
TProfile* fOtherEffVsRange;
TH1D* fMuonNumHits;
TH1D* fProtonNumHits;
TH1D* fOtherNumHits;
TH1D* fMuonNumHitsMC;
TH1D* fProtonNumHitsMC;
TH1D* fOtherNumHitsMC;
TProfile* fMuonEffVsHits;
TProfile* fProtonEffVsHits;
TProfile* fOtherEffVsHits;
TH1D* fMuonHitEfficiency;
TH1D* fMuonHitPurity;
TH1D* fMuonHitEfficPurity;
TH1D* fProtonHitEfficiency;
TH1D* fProtonHitPurity;
TH1D* fProtonHitEfficPurity;
TH1D* fOtherHitEfficiency;
TH1D* fOtherHitPurity;
TH1D* fOtherHitEfficPurity;
TH1D* fNumMcProngs;
TH1D* fNumPrimaryMuons;
TH1D* fNumPrimaryProtons;
TH1D* fNumTracks;
TH1D* fNumMuonTracks;
TH1D* fNumProtonTracks;
TH2D* fMuonTLvsMCL;
TH2D* fProtonTLvsMCL;
TH2D* fOtherTLvsMCL;
TH1D* fPdgCodeOther;
TH1D* fPdgCodeOtherMiss;
TH1D* fNoiseHits;
}; // class LArNeutrinoAna
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// class implementation
//-----------------------------------------------------------------------
// Constructor
LArNeutrinoAna::LArNeutrinoAna(fhicl::ParameterSet const& parameterSet)
: EDAnalyzer(parameterSet)
{
// Read in the parameters from the .fcl file.
this->reconfigure(parameterSet);
}
//-----------------------------------------------------------------------
// Destructor
LArNeutrinoAna::~LArNeutrinoAna()
{}
//-----------------------------------------------------------------------
void LArNeutrinoAna::beginJob()
{
// Get the detector length, to determine the maximum bin edge of one
// of the histograms.
double detectorLength = fGeometry->DetLength();
// Access ART's TFileService, which will handle creating and writing
// histograms and n-tuples for us.
art::ServiceHandle<art::TFileService> tfs;
// The arguments to 'make<whatever>' are the same as those passed
// to the 'whatever' constructor, provided 'whatever' is a ROOT
// class that TFileService recognizes.
// Define the histograms. Putting semi-colons around the title
// causes it to be displayed as the x-axis label if the histogram
// is drawn.
fMuonRangeMC = tfs->make<TH1D>("MuonRangeMC", "; Range", 100, 0., 0.5 * fGeometry->DetLength());
fProtonRangeMC = tfs->make<TH1D>("ProtonRangeMC", "; Range", 100, 0., 0.1 * fGeometry->DetLength());
fOtherRangeMC = tfs->make<TH1D>("OtherRangeMC", "; Range", 100, 0., 0.05 * fGeometry->DetLength());
fMuonRange = tfs->make<TH1D>("MuonRange", "; Range", 100, 0., 0.5 * fGeometry->DetLength());
fProtonRange = tfs->make<TH1D>("ProtonRange", "; Range", 100, 0., 0.1 * fGeometry->DetLength());
fOtherRange = tfs->make<TH1D>("OtherRange", "; Range", 100, 0., 0.05 * fGeometry->DetLength());
fMuonDeltaRange = tfs->make<TH1D>("MuonDeltaRange", "; Delta Range", 200, -100., 100.);
fProtonDeltaRange = tfs->make<TH1D>("ProtonDeltaRange", "; Delta Range", 200, -50., 50.);
fOtherDeltaRange = tfs->make<TH1D>("OtherDeltaRange", "; Delta Range", 200, -50., 50.);
fMuonEffVsRange = tfs->make<TProfile>("MuonEffVsRange", ";Range", 40, 0., 0.5 * fGeometry->DetLength(), 0., 1.1);
fProtonEffVsRange = tfs->make<TProfile>("ProtonEffVsRange", ";Range", 25, 0., 0.1 * fGeometry->DetLength(), 0., 1.1);
fOtherEffVsRange = tfs->make<TProfile>("OtherEffVsRange", ";Range", 20, 0., 0.05 * fGeometry->DetLength(), 0., 1.1);
fMuonNumHits = tfs->make<TH1D>("MuonNumHits", ";log(# hits)", 20, 0.5, 4.5);
fProtonNumHits = tfs->make<TH1D>("ProtonNumHits", ";log(# hits)", 20, 0.5, 4.5);
fOtherNumHits = tfs->make<TH1D>("OtherNumHits", ";log(# hits)", 20, 0.5, 4.5);
fMuonNumHitsMC = tfs->make<TH1D>("MuonNumHitsMC", ";log(# hits)", 20, 0.5, 4.5);
fProtonNumHitsMC = tfs->make<TH1D>("ProtonNumHitsMC", ";log(# hits)", 20, 0.5, 4.5);
fOtherNumHitsMC = tfs->make<TH1D>("OtherNumHitsMC", ";log(# hits)", 20, 0.5, 4.5);
fMuonEffVsHits = tfs->make<TProfile>("MuonEffVsHits", ";log(# hits)", 20, 0.5, 4.5, 0., 1.1);
fProtonEffVsHits = tfs->make<TProfile>("ProtonEffVsHits", ";log(# hits)", 20, 0.5, 4.5, 0., 1.1);
fOtherEffVsHits = tfs->make<TProfile>("OtherEffVsHits", ";log(# hits)", 20, 0.5, 4.5, 0., 1.1);
fMuonHitEfficiency = tfs->make<TH1D>("MuonHitEffic", ";efficiency", 51, 0.0, 1.02);
fMuonHitPurity = tfs->make<TH1D>("MuonHitPurity", ";purity", 51, 0.0, 1.02);
fMuonHitEfficPurity = tfs->make<TH1D>("MuonHitEfficPurity", ";e*p", 51, 0.0, 1.02);
fProtonHitEfficiency = tfs->make<TH1D>("ProtonHitEffic", ";efficiency", 51, 0.0, 1.02);
fProtonHitPurity = tfs->make<TH1D>("ProtonHitPurity", ";purity", 51, 0.0, 1.02);
fProtonHitEfficPurity = tfs->make<TH1D>("ProtonHitEfficPurity", ";e*p", 51, 0.0, 1.02);
fOtherHitEfficiency = tfs->make<TH1D>("OtherHitEffic", ";efficiency", 51, 0.0, 1.02);
fOtherHitPurity = tfs->make<TH1D>("OtherHitPurity", ";purity", 51, 0.0, 1.02);
fOtherHitEfficPurity = tfs->make<TH1D>("OtherHitEfficPurity", ";e*p", 51, 0.0, 1.02);
fMuonTLvsMCL = tfs->make<TH2D>("MuonTLvsMCL", "Reco Length vs. MC Truth Length", 100, 0., 0.5 * detectorLength, 100, 0., 0.5 * detectorLength);
fProtonTLvsMCL = tfs->make<TH2D>("ProtonTLvsMCL", "Reco Length vs. MC Truth Length", 100, 0., 0.2 * detectorLength, 100, 0., 0.2 * detectorLength);
fOtherTLvsMCL = tfs->make<TH2D>("OtherTLvsMCL", "Reco Length vs. MC Truth Length", 100, 0., 0.1 * detectorLength, 100, 0., 0.1 * detectorLength);
fNumMcProngs = tfs->make<TH1D>("NumMcProngs", ";# prongs", 10, 0., 10.);
fNumPrimaryMuons = tfs->make<TH1D>("NumPrimMuons", ";# muons", 10, 0., 10.);
fNumPrimaryProtons = tfs->make<TH1D>("NumPrimProtons", ";# protons", 10, 0., 10.);
fNumTracks = tfs->make<TH1D>("NumTracks", ";# tracks", 10, 0., 10.);
fNumMuonTracks = tfs->make<TH1D>("NumMuonTracks", ";# tracks", 10, 0., 10.);
fNumProtonTracks = tfs->make<TH1D>("NumProtonTracks", ";# tracks", 10, 0., 10.);
fPdgCodeOther = tfs->make<TH1D>("PdgCodeOther", ";pdg code", 400, -200., 200.);
fPdgCodeOtherMiss = tfs->make<TH1D>("PdgCodeOtherM", ";pdg code", 400, -200., 200.);
fNoiseHits = tfs->make<TH1D>("NoiseHits", ";# hits", 100, 0., 100.);
}
//-----------------------------------------------------------------------
void LArNeutrinoAna::beginRun(const art::Run& /*run*/)
{
// How to convert from number of electrons to GeV. The ultimate
// source of this conversion factor is
// ${LARSIM_DIR}/include/SimpleTypesAndConstants/PhysicalConstants.h.
// art::ServiceHandle<sim::LArG4Parameters> larParameters;
// fElectronsToGeV = 1./larParameters->GeVToElectrons();
}
//-----------------------------------------------------------------------
void LArNeutrinoAna::reconfigure(fhicl::ParameterSet const& p)
{
// Read parameters from the .fcl file. The names in the arguments
// to p.get<TYPE> must match names in the .fcl file.
fSimulationProducerLabel = p.get< std::string >("SimulationLabel");
fMcHitCollectionModuleLabel = p.get< std::string >("MCHitLabel");
fPFParticleProducerLabel = p.get< std::string >("PFParticleLabel");
fHitProducerLabel = p.get< std::string >("HitLabel");
fClusterProducerLabel = p.get< std::string >("ClusterProducerLabel");
fTrackProducerLabel = p.get< std::string >("TrackProducerLabel");
fCosmicProducerLabel = p.get< std::string >("CosmicProducerLabel");
fFlashProducerLabel = p.get< std::string >("FlashProducerLabel");
fSelectedPDG = p.get< int >("PDGcode");
return;
}
//-----------------------------------------------------------------------
void LArNeutrinoAna::analyze(const art::Event& event)
{
// Start by fetching some basic event information for our n-tuple.
fEvent = event.id().event();
fRun = event.run();
fSubRun = event.subRun();
// The first step is to attempt to recover the collection of MCHits that
// we will need for doing our PFParticle to MC matching
art::Handle< std::vector<sim::MCHitCollection> > mcHitCollectionHandle;
event.getByLabel(fMcHitCollectionModuleLabel, mcHitCollectionHandle);
if (!mcHitCollectionHandle.isValid()) return;
// Recover this into a local stl version
const std::vector<sim::MCHitCollection> &mcHitCollectionVec = *mcHitCollectionHandle;
// This is the standard method of reading multiple objects
// associated with the same event; see
// <https://cdcvs.fnal.gov/redmine/projects/larsoftsvn/wiki/Using_the_Framework>
// for more information. Define a "handle" to point to a vector of
// the objects.
art::Handle< std::vector<simb::MCParticle> > particleHandle;
// Then tell the event to fill the vector with all the objects of
// that type produced by a particular producer.
event.getByLabel(fSimulationProducerLabel, particleHandle);
// Let's recover the MCTruth objects
art::FindOneP<simb::MCTruth> mcTruthAssns(particleHandle, event, fSimulationProducerLabel);
// The MCParticle objects are not necessarily in any particular
// order. Since we may have to search the list of particles, let's
// put them into a sorted map that will make searching fast and
// easy. To save both space and time, the map will not contain a
// copy of the MCParticle, but a pointer to it.
std::map< int, const simb::MCParticle* > particleMap;
// Before starting to loop through the particles, we are going to want to
// build a mapping between hits and track id's
// Start by recovering info from the event store
art::Handle< std::vector<recob::Hit> > hitHandle;
event.getByLabel(fHitProducerLabel, hitHandle);
//we're gonna probably need the time service to convert hit times to TDCs
art::ServiceHandle<util::TimeService> timeService;
// our ultimate goal here
HitToParticleMap hitToParticleMap;
ParticleToHitMap particleToHitMap;
// Keep track of the number of noise hits
int nNoiseHits(0);
// Ok, so this loop obviously takes the MC information and builds two maps
// 1) a map from a Hit2D object to the track ID's that made it
// 2) the reverse map, going from track ID to Hit2D object
for (unsigned int iHit = 0, iHitEnd = hitHandle->size(); iHit < iHitEnd; ++iHit)
{
art::Ptr<recob::Hit> hit(hitHandle, iHit);
const geo::WireID& wireId = hit->WireID();
unsigned int channel = fGeometry->PlaneWireToChannel(wireId.Plane, wireId.Wire, wireId.TPC, wireId.Cryostat);
const std::vector<sim::MCHit>& mcHitVec = mcHitCollectionVec.at(channel);
int start_tdc = timeService->TPCTick2TDC( hit->StartTick() );
int end_tdc = timeService->TPCTick2TDC( hit->EndTick() );
sim::MCHit startTime;
sim::MCHit endTime;
startTime.SetTime(start_tdc, 0);
endTime.SetTime(end_tdc, 0);
std::vector<sim::MCHit>::const_iterator startItr = std::lower_bound(mcHitVec.begin(), mcHitVec.end(), startTime);
std::vector<sim::MCHit>::const_iterator endItr = std::upper_bound(startItr, mcHitVec.end(), endTime);
while(startItr != endItr)
{
int trackID = (*startItr++).PartTrackId();
hitToParticleMap[hit.get()].insert(trackID);
particleToHitMap[trackID].insert(hit.get());
}
// else nNoiseHits++;
}
// Record for posteriety
fNoiseHits->Fill(nNoiseHits);
// This loop will build the map between track ID and the MCParticle related to it
for ( auto const& particle : (*particleHandle) )
{
// For the methods you can call to get particle information,
// see ${NUTOOLS_DIR}/include/SimulationBase/MCParticle.h.
int trackID = particle.TrackId();
// Add the address of the MCParticle to the map, with the track ID as the key.
particleMap[trackID] = &particle;
} // loop over all particles in the event.
// Ok, at this point we're ready to recover Tracks and the assorted necessities for the next step
// For sure we need a boatload of stuff here...
// Start with some useful typdefs
typedef std::set<art::Ptr<recob::Hit> > Hit2DSet; // Need to count only unique hits
typedef std::map< int, Hit2DSet > TrackIDToHit2DMap;
typedef std::vector<const recob::Track*> TrackVec;
typedef std::map< int, TrackVec > TrackIDToTrackVecMap;
typedef std::map<const recob::Track*, TrackIDToHit2DMap > TrackToTrackHit2DMap;
// Now define the maps relating pfparticles to tracks
TrackIDToTrackVecMap trackIDToTrackMap;
TrackToTrackHit2DMap trackToTrackHitMap;
// Something to keep track of number of hits associated to a cluster
std::map<const recob::Track*, int> trackHitCntMap;
// Recover the PFParticles, the main products for our next major loop
art::Handle<std::vector<recob::PFParticle> > pfParticleHandle;
event.getByLabel(fPFParticleProducerLabel, pfParticleHandle);
// We need a handle to the collection of clusters in the data store so we can
// handle associations to hits.
art::Handle<std::vector<recob::Cluster> > clusterHandle;
event.getByLabel(fPFParticleProducerLabel, clusterHandle);
// Now retrieve a handle to the fit tracks
art::Handle<std::vector<recob::Track> > trackHandle;
event.getByLabel(fTrackProducerLabel, trackHandle);
// If we have reconstructed tracks then we fill out the tables relating to hits
// The valididy ot a trackHandle implies the validity of the PFParticle and Cluster handles
if (trackHandle.isValid())
{
// Recover track hit associations
art::FindManyP<recob::Hit> trackHitAssns(trackHandle, event, fTrackProducerLabel);
// The goal of this loop is to recover the list of 2D hits associated with a given Track
// (through associations with 2D clusters) and develop some maps which allow us to associate
// the Track to a MC particle.
for (const auto& track : (*trackHandle))
{
// Recover the hits associated to this track
std::vector<art::Ptr<recob::Hit> > hits = trackHitAssns.at(track.ID());
// Keep track of this to hopefully save some time later
trackHitCntMap[&track] = hits.size();
// To categorize the PFParticle (associate to MCParticle), we will
// create and fill an instance of a TrackIDToHitMap.
// So, for a given PFParticle we will have a map of the track ID's (MCParticles)
// and the hits that they contributed energy too
trackToTrackHitMap[&track] = TrackIDToHit2DMap();
TrackIDToHit2DMap& trackIdToHit2DMap = trackToTrackHitMap[&track];
// Something to count MCParticles contributing here
std::set<int> trackIdCntSet;
int nMultiParticleHits(0);
int nNoParticleHits(0);
// To fill out this map we now loop over the recovered Hit2D's and stuff into the map
for (const auto& hit : hits)
{
// Given the Hit2D, recover the list of asscociated track ID's (MCParticles)
HitToParticleMap::iterator hitToParticleMapItr = hitToParticleMap.find(hit.get());
if (hitToParticleMapItr != hitToParticleMap.end())
{
// More than one MCParticle can contribute energy to make a given hit
// So loop over the track ID's for this hit
for(const auto& trackId : hitToParticleMapItr->second)
{
trackIdToHit2DMap[trackId].insert(hit);
trackIdCntSet.insert(trackId);
}
if (hitToParticleMapItr->second.size() > 1) nMultiParticleHits++;
}
else
{
nNoParticleHits++;
}
}
// Make sure something happened here...
if (!trackIdToHit2DMap.empty())
{
int bestTrackId(-99999);
size_t bestTrackCnt(0);
// Make a quick loop through the map to do some majority logic matching
// We only care about find the best match so no worries about sorting
// Take advantage of this loop to count the number of unique 2D hits
for(const auto& trackItr : trackIdToHit2DMap)
{
// Majority logic matching
if (trackItr.second.size() > bestTrackCnt)
{
bestTrackId = trackItr.first;
bestTrackCnt = trackItr.second.size();
}
}
if (bestTrackId != -99999)
{
trackIDToTrackMap[bestTrackId].push_back(&track);
}
}
} // end of loop over the PFParticle collection
}
// Always a handy thing to have hidden in your code:
// const double radToDegrees = 180. / 3.14159265;
art::ServiceHandle<util::LArProperties> larProperties;
// One last task worth pursuing is to see if we can pick out the neutrino interaction and do some categorization of it.
// const simb::MCTruth* theAnswerIsOutThere(0);
std::vector<const simb::MCParticle*> mcPartVec;
std::vector<const simb::MCParticle*> primaryMuonVec;
std::vector<const simb::MCParticle*> primaryProtonVec;
std::vector<const recob::Track*> trackVec;
std::vector<const recob::Track*> muonTrackVec;
std::vector<const recob::Track*> protonTrackVec;
for (size_t particleIdx = 0; particleIdx < particleHandle->size(); particleIdx++)
{
art::Ptr<simb::MCParticle> particle(particleHandle, particleIdx);
// See if we can quickly eliminate junk
if (particle->NumberTrajectoryPoints() < 2) continue;
bool isNeutrino(false);
try
{
art::Ptr<simb::MCTruth> mcTruth = mcTruthAssns.at(particleIdx);
if (mcTruth->Origin() != simb::kBeamNeutrino) continue;
isNeutrino = true;
// theAnswerIsOutThere = mcTruth.get();
}
catch(...)
{
isNeutrino = false;
}
if (isNeutrino)
{
// For the methods you can call to get particle information,
// see ${NUTOOLS_DIR}/include/SimulationBase/MCParticle.h.
int bestTrackID = particle->TrackId();
// Recover the particle's identity
int trackPDGCode = particle->PdgCode();
// Did this mc particle leave hits in the TPC?
ParticleToHitMap::iterator particleToHitItr = particleToHitMap.find(bestTrackID);
// No hits no work
if (particleToHitItr == particleToHitMap.end()) continue;
// Can we check the range of this particle?
if(particle->E() < 0.001*particle->Mass() + 0.05) continue;
// Let's get the total number of "true" hits that are created by this MCParticle
int nTrueMcHits = particleToHitItr->second.size();
// Count number of hits in each view
int nHitsPerView[3] = {0,0,0};
std::set<int> uniqueWiresPerView[3] = {std::set<int>(),std::set<int>(),std::set<int>()};
float maxTimePerView[3] = {0., 0., 0.};
float minTimePerView[3] = {10000., 10000., 10000.};
for (const auto& hit : particleToHitItr->second)
{
int view = hit->View();
nHitsPerView[view]++;
uniqueWiresPerView[view].insert(hit->WireID().Wire);
maxTimePerView[view] = std::max(maxTimePerView[view], hit->PeakTime());
minTimePerView[view] = std::min(minTimePerView[view], hit->PeakTime());
}
// We need to make sure there was some activity in the TPC
if (uniqueWiresPerView[0].size() < 4 || uniqueWiresPerView[1].size() < 4 || uniqueWiresPerView[2].size() < 4) continue;
// std::cout << "--- PDG code: " << trackPDGCode << std::endl;
// for(int idx = 0; idx < 3; idx++)
// {
// std::cout << "Hits: " << nHitsPerView[idx] << ", wires: " << uniqueWiresPerView[idx].size() << ", max Time: " << maxTimePerView[idx]
// << ", min Time: " << minTimePerView[idx] << std::endl;
// }
// Calculate the x offset due to nonzero mc particle time.
double mctime = particle->T(); // nsec
double mcdx = mctime * 1.e-3 * larProperties->DriftVelocity(); // cm
// Calculate the length of this mc particle inside the fiducial volume.
TVector3 mcstart;
TVector3 mcend;
TVector3 mcstartmom;
TVector3 mcendmom;
double mcTrackLen = length(*particle, mcdx, mcstart, mcend, mcstartmom, mcendmom);
// Require particle travel at least three wires in Y-Z plane
if (mcTrackLen < 0.91) continue;
mcPartVec.push_back(particle.get());
double logNumMcHits(std::log10(nTrueMcHits));
bool isPrimaryMuon = fabs(trackPDGCode) == 13 && particle->Process() == "primary";
bool isPrimaryProton = fabs(trackPDGCode) == 2212 && particle->Process() == "primary";
if (isPrimaryMuon) primaryMuonVec.push_back(particle.get());
else if (isPrimaryProton) primaryProtonVec.push_back(particle.get());
mf::LogDebug("LArNeutrinoAna") << "***>> Found Neutrino product: " << *particle << std::endl;
// Now check to see that a track is associated with this MCParticle (trackID)
TrackIDToTrackVecMap::iterator trackIDToTrackItr = trackIDToTrackMap.find(bestTrackID);
// If no track then skip the rest
if (trackIDToTrackItr == trackIDToTrackMap.end())
{
// Of course, we must record the results first, and what we do depends on the particle...
if (isPrimaryMuon)
{
mcTrackLen = std::min(mcTrackLen, 0.5*fGeometry->DetLength()-1.);
fMuonRangeMC->Fill(mcTrackLen, 1.);
fMuonRange->Fill(0., 1.);
fMuonEffVsRange->Fill(mcTrackLen, 0.);
fMuonNumHits->Fill(0.1, 1.);
fMuonNumHitsMC->Fill(logNumMcHits, 1.);
fMuonEffVsHits->Fill(logNumMcHits, 0.);
// fMuonHitEfficiency->Fill(0., 1.);
// fMuonHitPurity->Fill(0., 1.);
// fMuonHitEfficPurity->Fill(0., 1.);
fMuonTLvsMCL->Fill(mcTrackLen, 0., 1.);
mf::LogInfo("LArNeutrinoAna") << "***>> Primary muon missing, event # " << fEvent << ", mcTrackLen: " << mcTrackLen << std::endl;
}
else if (isPrimaryProton)
{
mcTrackLen = std::min(mcTrackLen, 0.1*fGeometry->DetLength()-1.);
fProtonRangeMC->Fill(mcTrackLen, 1.);
fProtonRange->Fill(0., 1.);
fProtonEffVsRange->Fill(mcTrackLen, 0.);
fProtonNumHits->Fill(0.1, 1.);
fProtonNumHitsMC->Fill(logNumMcHits, 1.);
fProtonEffVsHits->Fill(logNumMcHits, 0.);
// fProtonHitEfficiency->Fill(0., 1.);
// fProtonHitPurity->Fill(0., 1.);
// fProtonHitEfficPurity->Fill(0., 1.);
fProtonTLvsMCL->Fill(mcTrackLen, 0., 1.);
mf::LogInfo("LArNeutrinoAna") << "***>> Primary proton missing, event # " << fEvent << ", mcTrackLen: " << mcTrackLen << std::endl;
}
else
{
mcTrackLen = std::min(mcTrackLen, 0.05*fGeometry->DetLength()-1.);
// Should add pdgcode plot to see what things are...
fOtherRangeMC->Fill(mcTrackLen, 1.);
fOtherRange->Fill(0., 1.);
fOtherEffVsRange->Fill(mcTrackLen, 0.);
fOtherNumHits->Fill(0.1, 1.);
fOtherNumHitsMC->Fill(logNumMcHits, 1.);
fOtherEffVsHits->Fill(logNumMcHits, 0.);
// fOtherHitEfficiency->Fill(0., 1.);
// fOtherHitPurity->Fill(0., 1.);
// fOtherHitEfficPurity->Fill(0., 1.);
fOtherTLvsMCL->Fill(mcTrackLen, 0., 1.);
fPdgCodeOtherMiss->Fill(std::max(-199.5,std::min(199.5,double(trackPDGCode))), 1.);
}
continue;
}
// Here our goal is to count the number of hits associated to a Track by the "best" MCParticle
// (which is the one which produced the most number of hits the Track has grouped together)
const recob::Track* track(0);
int bestCnt(0);
int nTracks(0);
// Loop over the Tracks associated to this track ID (MCParticle)
for(const auto& tmpPart : trackIDToTrackItr->second)
{
// This is to get the list of hits this PFParticle has broken out by track id
TrackIDToHit2DMap::iterator tmpPartTrackItr = trackToTrackHitMap[tmpPart].find(bestTrackID);
if (tmpPartTrackItr != trackToTrackHitMap[tmpPart].end())
{
int trackHitCnt = tmpPartTrackItr->second.size();
if (trackHitCnt > bestCnt)
{
bestCnt = trackHitCnt;
track = tmpPart;
}
if (trackHitCnt > int(nTrueMcHits / 10)) nTracks++;
}
}
// I don't think this can happen...
if (!track) continue;
trackVec.push_back(track);
// Now we can determine:
// 1) The total number of hits in this cluster
// 2) The number of hits belonging to the matched mc track
// 3) The number of hits on that track
// 4) The number of hits not belonging to this track which are on the cluster (the impurities)
size_t nTotalClusterHits = trackHitCntMap[track];
size_t nMatchedHits = bestCnt;
// size_t nWrongClusterHits = nTotalClusterHits - nMatchedHits;
// MicroBooNE definitions of efficiency and purity:
// efficiency E = number of true hits in the cluster / number of true hits from MC particle
// purity P = number of true hits in the cluster / all hits in the cluster
double hitEfficiency = double(nMatchedHits) / double(nTrueMcHits);
// double wrongEff = double(nWrongClusterHits) / double(nTrueMcHits);
double hitPurity = double(nMatchedHits) / double(nTotalClusterHits);
double trackLen = length(track);
double logNumHits = std::log10(nTotalClusterHits);
if (isPrimaryMuon)
{
double deltaRange = std::min(99.9, std::max(mcTrackLen - trackLen, -99.9));
mcTrackLen = std::min(mcTrackLen, 0.5*fGeometry->DetLength()-1.);
trackLen = std::min(trackLen, 0.5*fGeometry->DetLength()-1.);
fMuonRangeMC->Fill(mcTrackLen, 1.);
fMuonRange->Fill(trackLen, 1.);
fMuonDeltaRange->Fill(deltaRange, 1.);
fMuonEffVsRange->Fill(mcTrackLen, 1.);
fMuonNumHits->Fill(logNumHits, 1.);
fMuonNumHitsMC->Fill(logNumMcHits, 1.);
fMuonEffVsHits->Fill(logNumMcHits, 1.);
fMuonHitEfficiency->Fill(hitEfficiency, 1.);
fMuonHitPurity->Fill(hitPurity, 1.);
fMuonHitEfficPurity->Fill(hitEfficiency*hitPurity, 1.);
fMuonTLvsMCL->Fill(mcTrackLen, trackLen, 1.);
muonTrackVec.push_back(track);
}
else if (isPrimaryProton)
{
double deltaRange = std::min(49.9, std::max(mcTrackLen - trackLen, -49.9));
mcTrackLen = std::min(mcTrackLen, 0.1*fGeometry->DetLength()-1.);
trackLen = std::min(trackLen, 0.1*fGeometry->DetLength()-1.);
fProtonRangeMC->Fill(mcTrackLen, 1.);
fProtonRange->Fill(trackLen, 1.);
fProtonDeltaRange->Fill(deltaRange, 1.);
fProtonEffVsRange->Fill(mcTrackLen, 1.);
fProtonNumHits->Fill(logNumHits, 1.);
fProtonNumHitsMC->Fill(logNumMcHits, 1.);
fProtonEffVsHits->Fill(logNumMcHits, 1.);
fProtonHitEfficiency->Fill(hitEfficiency, 1.);
fProtonHitPurity->Fill(hitPurity, 1.);
fProtonHitEfficPurity->Fill(hitEfficiency*hitPurity, 1.);
fProtonTLvsMCL->Fill(mcTrackLen, trackLen, 1.);
protonTrackVec.push_back(track);
}
else
{
double deltaRange = std::min(49.9, std::max(mcTrackLen - trackLen, -49.9));
mcTrackLen = std::min(mcTrackLen, 0.05*fGeometry->DetLength()-1.);
trackLen = std::min(trackLen, 0.05*fGeometry->DetLength()-1.);
fOtherRangeMC->Fill(mcTrackLen, 1.);
fOtherRange->Fill(trackLen, 1.);
fOtherDeltaRange->Fill(deltaRange, 1.);
fOtherEffVsRange->Fill(mcTrackLen, 1.);
fOtherNumHits->Fill(logNumHits, 1.);
fOtherNumHitsMC->Fill(logNumMcHits, 1.);
fOtherEffVsHits->Fill(logNumMcHits, 1.);
fOtherHitEfficiency->Fill(hitEfficiency, 1.);
fOtherHitPurity->Fill(hitPurity, 1.);
fOtherHitEfficPurity->Fill(hitEfficiency*hitPurity, 1.);
fOtherTLvsMCL->Fill(mcTrackLen, trackLen, 1.);
fPdgCodeOther->Fill(std::max(-199.5,std::min(199.5,double(trackPDGCode))), 1.);
}
}
}
int nMcProngs = mcPartVec.size();
int nPrimaryMuons = primaryMuonVec.size();
int nPrimaryProtons = primaryProtonVec.size();
int nTracks = trackVec.size();
int nMuonTracks = muonTrackVec.size();
int nProtonTracks = protonTrackVec.size();
fNumMcProngs->Fill(nMcProngs);
fNumPrimaryMuons->Fill(nPrimaryMuons);
fNumPrimaryProtons->Fill(nPrimaryProtons);
fNumTracks->Fill(nTracks);
fNumMuonTracks->Fill(nMuonTracks);
fNumProtonTracks->Fill(nProtonTracks);
return;
}
// Length of reconstructed track.
//----------------------------------------------------------------------------
double LArNeutrinoAna::length(const recob::Track* track)
{
double result(0.);
TVector3 disp(track->LocationAtPoint(0));
int n(track->NumberTrajectoryPoints());
for(int i = 1; i < n; ++i)
{
const TVector3& pos = track->LocationAtPoint(i);
disp -= pos;
result += disp.Mag();
disp = pos;
}
return result;
}
// Length of MC particle.
//----------------------------------------------------------------------------
double LArNeutrinoAna::length(const simb::MCParticle& part, double dx,
TVector3& start, TVector3& end, TVector3& startmom, TVector3& endmom,
unsigned int tpc, unsigned int cstat)
{
// Get services.
art::ServiceHandle<geo::Geometry> geom;
art::ServiceHandle<util::DetectorProperties> detprop;
// Get fiducial volume boundary.
double xmin = 0.;
double xmax = 2.*geom->DetHalfWidth();
double ymin = -geom->DetHalfHeight();
double ymax = geom->DetHalfHeight();
double zmin = 0.;
double zmax = geom->DetLength();
double result = 0.;
TVector3 disp;
int n = part.NumberTrajectoryPoints();
bool first = true;
for(int i = 0; i < n; ++i)
{
TVector3 pos = part.Position(i).Vect();
// Make fiducial cuts. Require the particle to be within the physical volume of
// the tpc, and also require the apparent x position to be within the expanded
// readout frame.
if(pos.X() >= xmin &&
pos.X() <= xmax &&
pos.Y() >= ymin &&
pos.Y() <= ymax &&
pos.Z() >= zmin &&
pos.Z() <= zmax)
{
pos[0] += dx;
double ticks = detprop->ConvertXToTicks(pos[0], 0, 0, 0);
if(ticks >= 0. && ticks < detprop->ReadOutWindowSize())
{
if(first)
{
start = pos;
startmom = part.Momentum(i).Vect();
}
else
{
disp -= pos;
result += disp.Mag();
}
first = false;
disp = pos;
end = pos;
endmom = part.Momentum(i).Vect();
}
}
}
return result;
}
// This macro has to be defined for this module to be invoked from a
// .fcl file; see LArNeutrinoAna.fcl for more information.
DEFINE_ART_MODULE(LArNeutrinoAna)
} // namespace LArNeutrinoAna
#endif // LArNeutrinoAna_module
| [
"usher@slac.stanford.edu"
] | usher@slac.stanford.edu |
d328038b2168cfe7d9a844457c16977ac3950f1c | 55987c29910ddd89800b3b46c83d9a01b8b62852 | /src/alco_edit_base.cpp | 4aeb96e305a88b01cd509bdb28f51d57968e6196 | [] | no_license | timurchak/AlcoMetr | ccf4a5bd1aaf78656a83177965da64c6aa342f15 | 8217bc0d9d8697014859dc8e5d17708429186aa5 | refs/heads/master | 2023-01-10T03:21:46.290604 | 2020-11-14T20:22:17 | 2020-11-14T20:22:17 | 300,037,417 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,325 | cpp | #include "alco_edit_base.h"
#include "ui_alco_edit_base.h"
AlcoEditBase::AlcoEditBase(AlcoBaseWorker* _baseWorker, QWidget* parent)
: QWidget(parent)
, ui(new Ui::AlcoEditBase)
, lay(new QDynamicGridLayout(4))
, baseWorker(_baseWorker)
, base(baseWorker->getMapAlco())
{
ui->setupUi(this);
auto it = base->begin();
while (it != base->end()) {
auto layn = addCategory(it.key(), it.value());
lay->add(layn);
++it;
}
ui->lay_scroll->addLayout(lay);
}
AlcoEditBase::~AlcoEditBase() { delete ui; }
QVBoxLayout* AlcoEditBase::addCategory(const QString& name, const AlcoList& list)
{
AlcoEditBaseItem* item = new AlcoEditBaseItem(name, list);
connect(
item->w, &QListWidget::customContextMenuRequested, this, &AlcoEditBase::showContextMenu);
listCategory << item;
return item->lay;
}
void AlcoEditBase::showContextMenu(const QPoint& pos)
{
QListWidget* list = qobject_cast<QListWidget*>(sender());
if (list == nullptr) {
return;
}
QPoint gpos = list->mapToGlobal(pos);
QMenu menu;
menu.addAction("Удалить элемент", this, &AlcoEditBase::removeItem);
menu.addAction("Добавить элемент", this, &AlcoEditBase::addItem);
menu.addAction("Удалить категорию", this, &AlcoEditBase::removeCategory);
menu.exec(gpos);
}
void AlcoEditBase::addItem()
{
QListWidget* list = qobject_cast<QListWidget*>(focusWidget());
if (list == nullptr) {
return;
}
QListWidgetItem* witem = new QListWidgetItem("NoName");
witem->setFlags(witem->flags() | Qt::ItemIsEditable);
list->addItem(witem);
}
void AlcoEditBase::removeItem()
{
QListWidget* list = qobject_cast<QListWidget*>(focusWidget());
if (list == nullptr) {
return;
}
for (int i = 0; i < list->selectedItems().size(); ++i) {
// Get curent item on selected row
QListWidgetItem* item = list->selectedItems()[i];
// And remove it
delete item;
}
}
void AlcoEditBase::removeCategory()
{
QListWidget* list = qobject_cast<QListWidget*>(focusWidget());
if (list == nullptr) {
return;
}
AlcoEditBaseItem* searched;
for (auto& item : listCategory) {
if (item->w == list) {
searched = item;
}
}
int ret = QMessageBox::warning(this, "Предупрждение о удаление категории",
"Вы действительно хотите удалить всю категорию " + searched->catName->text(),
QMessageBox::Yes | QMessageBox::No);
if(ret == QMessageBox::No) {
return;
}
listCategory.removeOne(searched);
searched->w->deleteLater();
searched->catName->deleteLater();
searched->lay->deleteLater();
delete searched;
}
void AlcoEditBase::on_Btn_AddCategory_clicked() { lay->add(addCategory("", {})); }
void AlcoEditBase::on_Btn_Save_clicked()
{
base->clear();
for (auto& item : listCategory) {
QString type = item->catName->text();
base->operator[](type) = AlcoList();
for (int i = 0; i < item->w->count(); i++) {
base->operator[](type) << new AlcoItem({ item->w->item(i)->text(), "", 0, 0 }, type);
}
}
baseWorker->saveBase();
}
| [
"timurchak@gmail.com"
] | timurchak@gmail.com |
23eca5c81e46d2bc4082e9fae72739259378d4de | fd2c3a26e156296fb0936b7d9af7f81ab4cb53e1 | /phorm/except.h | be4109467fe48d3219391ead2e186aced7a72b7b | [] | no_license | spetz911/http-server | 950a2923e159313d56a30c409ccdf38726d61e67 | 00ae5e3f19795d78c4ea22e65a4fee8df24bf769 | refs/heads/master | 2020-06-05T00:19:11.346005 | 2012-10-30T13:20:36 | 2012-10-30T13:20:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,271 | h | /**
* Common definitions and routines for the TDMN project.
*
* 2011. Written by NatSys Lab. (info@natsys-lab.com).
*/
#ifndef __TDMN_H__
#define __TDMN_H__
#include <assert.h>
#include <errno.h>
#include <execinfo.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <string>
// Environment checks and sesstings.
#ifndef __x86_64__
#warning "Your architecture is not supported. Please use x86-64 only."
#endif
#if !defined(LEVEL1_DCACHE_LINESIZE) || !LEVEL1_DCACHE_LINESIZE
#ifdef LEVEL1_DCACHE_LINESIZE
#undef LEVEL1_DCACHE_LINESIZE
#endif
#define LEVEL1_DCACHE_LINESIZE 64
#endif
#ifndef NDEBUG // Debugging
#define DBG_STMT(x) x;
#define error_exit(n) ::abort()
#define SCHED_YIELD_SLEEP 100000
#else // No Debugging
#define DBG_STMT(x)
#define error_exit(n) ::exit(n)
// 0.001 sec, equal to Linux 2.6 scheduler tick
#define SCHED_YIELD_SLEEP 1000
#endif
#define INVARIANT(cond) assert(cond)
class Except : public std::exception {
private:
static const size_t maxmsg = 256;
std::string str_;
public:
Except(const char* fmt, ...) throw()
{
va_list ap;
char msg[maxmsg];
va_start(ap, fmt);
vsnprintf(msg, maxmsg, fmt, ap);
va_end(ap);
str_ = msg;
// Add system error code (errno).
if (errno) {
std::stringstream ss;
ss << " (" << strerror(errno)
<< ", errno=" << errno << ")";
str_ += ss.str();
}
// Add OpenSSL error code if exists.
// unsigned long ossl_err = ERR_get_error();
// if (ossl_err) {
// char buf[256];
// str_ += std::string(": ")
// + ERR_error_string(ossl_err, buf);
// }
// Add call trace symbols.
call_trace();
}
~Except() throw()
{}
const char *
what() const throw()
{
return str_.c_str();
}
private:
void
call_trace() throw()
{
// Do not print more that BTRACE_CALLS_NUM calls in the trace.
static const size_t BTRACE_CALLS_NUM = 32;
void *trace_addrs[BTRACE_CALLS_NUM];
int n_addr = backtrace(trace_addrs,
sizeof(trace_addrs) / sizeof(trace_addrs[0]));
if (!n_addr)
return;
char **btrace = backtrace_symbols(trace_addrs, n_addr);
if (!btrace)
return;
for (int i = 0; i < n_addr; ++i)
str_ += std::string("\n\t") + btrace[i];
free(btrace);
}
};
#endif // __TDMN_H__
| [
"spetz911@gmail.com"
] | spetz911@gmail.com |
eb75056ed82fa1ecd50dedd5fc8d1d6f02a2bfd1 | a1a56ba3059d64b36d1609e8999df2273140e84e | /of_v0.8.0_osx_Chinese/examples/math 数学/noiseField2dExample二维随机噪点/src/testApp.cpp | d0f6c9542af0af4bdafbd8264f1b7d37b581c8a5 | [
"MIT"
] | permissive | XuXo/openFrameworks_Chinese | ae4a5aeee7d16ee4570f4d852f8f5bb31a85be62 | 2118e8d796bf638dfbed38971d502891e066acc8 | refs/heads/master | 2020-12-11T05:53:45.697198 | 2014-06-09T22:52:36 | 2014-06-09T22:52:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,824 | cpp | /*
This example demonstrates how to use a two dimensional slice of a three
dimensional noise field to guide particles that are flying around. It was
originally based on the idea of simulating "pollen" being blown around by
the wind, and implemented in the Processing:
http://www.openprocessing.org/visuals/?visualID=2785
这个例子说明了如何用三维领域中的二维切片去指导一群飞舞的粒子。这个例子是原创性地基于模拟被风吹散的“花粉”,
你还可以看到一个Processing的例子: http://www.openprocessing.org/visuals/?visualID=2785。
*/
#include "testApp.h"
/*
All these settings control the behavior of the app. In general it's a better
idea to keep variables in the .h file, but this makes it easy to set them at
the same time you declare them.
这些设置控制整个应用的表现方式。总的来说,如果在.h文件里面保存这些变量会比较好,但是把变量写在这里会更容易去设置他们。
*/
int nPoints = 4096; // points to draw 要画的点
float complexity = 6; // wind complexity 风的复杂度
float pollenMass = .8; // pollen mass 花粉的质量
float timeSpeed = .02; // wind variation speed 风的变化速度
float phase = TWO_PI; // separate u-noise from v-noise 从 v-随机噪点中分离 u-随机噪点
float windSpeed = 40; // wind vector magnitude for debug 调试用风的向量大小
int step = 10; // spatial sampling rate for debug 调试用空间率
bool debugMode = false;
/*
This is the magic method that samples a 2d slice of the 3d noise field. When
you call this method with a position, it returns a direction (a 2d vector). The
trick behind this method is that the u,v values for the field are taken from
out-of-phase slices in the first dimension: t + phase for the u, and t - phase
for the v.
这是一个魔术般的的方法,它从3d的噪点场中采集2d的切片。当你用一个位置坐标去激活这个方法时,它会返回一个方向(一个2d的矢量)。
这个方式背后的窍门是这个场中的u,v数值取自一纬空间里的外层切片;t+层用于u, 和 t-层用于v。
*/
//--------------------------------------------------------------
ofVec2f testApp::getField(ofVec2f position) {
float normx = ofNormalize(position.x, 0, ofGetWidth());
float normy = ofNormalize(position.y, 0, ofGetHeight());
float u = ofNoise(t + phase, normx * complexity + phase, normy * complexity + phase);
float v = ofNoise(t - phase, normx * complexity - phase, normy * complexity + phase);
return ofVec2f(u, v);
}
//--------------------------------------------------------------
void testApp::setup() {
ofSetVerticalSync(true); // don't go too fast 不会跑的太快
ofEnableAlphaBlending();
// randomly allocate the points across the screen 在屏幕上随机放置点点
points.resize(nPoints);
for(int i = 0; i < nPoints; i++) {
points[i] = ofVec2f(ofRandom(0, ofGetWidth()), ofRandom(0, ofGetHeight()));
}
// we'll be drawing the points into an ofMesh that is drawn as bunch of points 我们会画一些点点到ofMesh里面,然后这个ofMesh会画一堆点点
cloud.clear();
cloud.setMode(OF_PRIMITIVE_POINTS);
}
//--------------------------------------------------------------
void testApp::update() {
width = ofGetWidth(), height = ofGetHeight();
t = ofGetFrameNum() * timeSpeed;
for(int i = 0; i < nPoints; i++) {
float x = points[i].x, y = points[i].y;
ofVec2f field = getField(points[i]); // get the field at this position 得到所在位置的场
// use the strength of the field to determine a speed to move 使用场的强度来确定移动速度
// the speed is changing over time and velocity-space as well 速度和加速空间都会不断变化
float speed = (1 + ofNoise(t, field.x, field.y)) / pollenMass;
// add the velocity of the particle to its position 把粒子的坐标和加速度相加
x += ofLerp(-speed, speed, field.x);
y += ofLerp(-speed, speed, field.y);
// if we've moved outside of the screen, reinitialize randomly 如果点点已经移动到屏幕之外了,就随机初始化
if(x < 0 || x > width || y < 0 || y > height) {
x = ofRandom(0, width);
y = ofRandom(0, height);
}
// save the changes we made to the position 保存我们对点点位置的改变
points[i].x = x;
points[i].y = y;
// add the current point to our collection of drawn points 把新的点点加到我们需要画的点点矢量里
cloud.addVertex(ofVec2f(x, y));
}
}
//--------------------------------------------------------------
void testApp::draw() {
ofBackground(255);
if(debugMode) {
ofSetColor(0);
// draw a vector field for the debug screen 绘制出矢量场用于调试屏幕
for(int i = 0; i < width; i += step) {
for(int j = 0; j < height; j += step) {
ofVec2f field = getField(ofVec2f(i, j));
ofPushMatrix();
ofTranslate(i, j);
ofSetColor(0);
ofLine(0, 0, ofLerp(-windSpeed, windSpeed, field.x), ofLerp(-windSpeed, windSpeed, field.y));
ofPopMatrix();
}
}
// draw the points as circles 用圆形作为绘制的点
ofSetColor(ofColor::red);
for(int i = 0; i < nPoints; i++) {
ofCircle(points[i], 2);
}
} else {
// when not in debug mode, draw all the points to the screen 如果不是在调试模式,绘制所有的点点到屏幕上
ofSetColor(0, 10);
cloud.draw();
}
ofDrawBitmapStringHighlight("click to reset\nhit any key for debug", 10, 10, ofColor::white, ofColor::black);
}
//--------------------------------------------------------------
void testApp::keyPressed(int key) {
// when you hit a key, draw the debug screen 如果你点击一个按键,切换到调试模式
debugMode = !debugMode;
}
//--------------------------------------------------------------
void testApp::keyReleased(int key) {
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y) {
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button) {
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button) {
// when you click the mouse, reset all the points 如果点击鼠标,重置所有的点点
setup();
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button) {
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h) {
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}
| [
"bestpaul1985@gmail.com"
] | bestpaul1985@gmail.com |
e6f99edbcee1a6af48ce4611e46766bfc1d41a28 | 07e7ba58630ccbedc1117a7f3200bebec31e0262 | /src/sph-openmp-v1/Grid.h | 0f702738cd71577db1c1df2f6293cac3c1e1d35c | [] | no_license | skxu/FluidDynamics | 641931c4cd81f3ef937c4c49ebdb393d59b322d5 | c4815c2e8b4f966f0aa18b6398be864c78d448fd | refs/heads/master | 2020-06-05T22:31:27.682677 | 2014-12-09T15:04:45 | 2014-12-09T15:04:45 | 26,093,164 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,253 | h | #ifndef __GRID_H__
#define __GRID_H__
#include <vector>
#include <math.h>
#include <assert.h>
#include <stdio.h>
#include <pmmintrin.h>
#include "omp.h"
#include "Variables.h"
using namespace std;
class Grid{
public:
Grid(float xBound, float yBound, float zBound, float h, sim_state_t* s);
~Grid();
/* Call this to refresh the particles to the correct cells */
void setParticles();
/* Get the neighbors of particle i */
vector<int>* getNeighbors(int i);
private:
vector<vector<int> > grid;
vector<vector<int> > speedOctopus;
vector<vector<int>*> neighbors;
/* h */
float cutoff;
float cutoffSq;
/* Vector of particle positions from sim_state_t*/
float* posVec;
/* Number of particles */
int n;
int xDim;
int yDim;
int zDim;
int totalCells;
void setNeighbors();
/* Precalculate all the neighbors to a grid cell */
void fitOctopus(int i);
/* Remove everything from cells */
void cleanGrid();
/* Check if this is within the grid */
bool isValidPos(float gridPos_x, float gridPos_y, float gridPos_z);
/* Locate index of cell for this position */
int calcIndex(float x, float y, float z);
/* Go from 3d grid indices to vector index */
int flatten(float gridPos_x, float gridPos_y, float gridPos_z);
};
#endif | [
"alwong8@berkeley.edu"
] | alwong8@berkeley.edu |
855dbe41ca55370ff3e36444b653c640acd6b3bd | a0ab2bcf79c7e7f07f8917cbff4b04712e78d11a | /ch13/dense_RGBD/pointcloud_mapping.cpp | c2b2ce78a08d711af0a758e3a157dd85edfe388b | [] | no_license | mydream1994/slam_practice | fb41e1714ea75a772643aca0bb6437d85a1bd94b | f99a91f892b0825cea1b2e7a1838b6ff1721ff40 | refs/heads/master | 2020-03-25T19:27:48.300864 | 2018-08-09T01:22:55 | 2018-08-09T01:33:51 | 144,084,268 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,705 | cpp | #include <iostream>
#include <fstream>
#include <vector>
using namespace std;
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <Eigen/Geometry>
//格式化字符串 处理图像文件格式
#include <boost/format.hpp>
//点云数据处理
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/filters/statistical_outlier_removal.h>
using namespace cv;
int main(int argc,char** argv)
{
vector<Mat> colorImgs,depthImgs; //彩色图和深度图
//欧式变换矩阵使用Eigen::Isometry3d,实际是4x4矩阵
//在标准容器vector<>中使用Eigen库成员,不加Eigen::aligned_allocator,会报错
vector<Eigen::Isometry3d,Eigen::aligned_allocator<Eigen::Isometry3d> > poses; //相机位姿
ifstream fin("../data/pose.txt");
if(!fin)
{
cerr<<"请在有post.txt的目录下运行此程序"<<endl;
return 1;
}
for(int i=0;i<5;i++)
{
boost::format fmt("../data/%s/%d.%s"); //图像文件格式
colorImgs.push_back(imread((fmt%"color"%(i+1)%"png").str()));
//深度图是16UC1的单通道图像
depthImgs.push_back(imread((fmt%"depth"%(i+1)%"pgm").str(),-1)); //使用-1读取原始深度图像
double data[7] = {0};
for(auto& d:data)
fin>>d;
Eigen::Quaterniond q(data[6],data[3],data[4],data[5]);
Eigen::Isometry3d T(q);
T.pretranslate(Eigen::Vector3d(data[0],data[1],data[2]));
poses.push_back(T);
}
//计算点云并拼接
//相机内参
double cx = 325.5; //图像像素,原点平移
double cy = 253.5;
double fx = 518.0; //焦距和缩放
double fy = 519.0;
double depthScale = 1000;
//定义点云使用的格式 这里用的是XYZRGB
typedef pcl::PointXYZRGB PointT; //点云中的点对象 位置和像素值
typedef pcl::PointCloud<PointT> PointCloud; //整个点云对象
//新建一个点云
//使用智能指针,创建一个空点云,这种指针用完会自动释放
PointCloud::Ptr pointCloud(new PointCloud);
for(int i=0;i<5;i++)
{
PointCloud::Ptr current(new PointCloud);
cout<<"转换图像中:"<<i+1<<endl;
Mat color = colorImgs[i];
Mat depth = depthImgs[i]; //深度图像
Eigen::Isometry3d T=poses[i]; //每个图像对应的摄像头位姿
//对每个像素值对应的点 转换到现实世界
for(int v=0;v<color.rows;v++)
for(int u=0;u<color.cols;u++)
{
//v表示指向第v行 u表示指向第u个元素
unsigned int d = depth.ptr<unsigned short> (v)[u];
if(d == 0)
continue; //为0表示没有测量到
if(d >= 7000)
continue; //深度太大时不稳定
Eigen::Vector3d point;
point[2] = double(d)/depthScale;
point[0] = (u-cx)*point[2]/fx;
point[1] = (v-cy)*point[2]/fy;
Eigen::Vector3d pointWorld = T*point;
PointT p;
p.x = pointWorld[0];
p.y = pointWorld[1];
p.z = pointWorld[2];
//step每一航的字节数
p.b = color.data[v*color.step+u*color.channels()];
p.g = color.data[v*color.step+u*color.channels()+1];
p.r = color.data[v*color.step+u*color.channels()+2];
current->points.push_back(p);
}
//depth filter and statistical removal
//利用统计滤波器方法去除孤立点,该滤波器统计每个点
//与它最近N个点的距离值的分布,去除距离均值过大的点
//这样就保留了那些"粘在一起"的点,去掉了孤立的噪声点
PointCloud::Ptr tmp(new PointCloud);
pcl::StatisticalOutlierRemoval<PointT> statistical_filter;
statistical_filter.setMeanK(50);
statistical_filter.setStddevMulThresh(1.0);
statistical_filter.setInputCloud(current);
statistical_filter.filter(*tmp);
(*pointCloud) += *tmp;
}
pointCloud->is_dense = false;
cout<<"点云共有"<<pointCloud->size()<<"个点"<<endl;
//voxel filter
//利用体素滤波器进行降采样,由于多个视角存在视野重叠,在重叠区域会存在大量的位置十分相近的点
//这会占用许多内存空间,体素滤波保证在某个一定大小的立方体(体素)内仅有一个点
//相当与对三维空间进行了降采样,从而节省了很多存储空间
pcl::VoxelGrid<PointT> voxel_filter;
//把分辨率调至0.01,表示每立方厘米有一个点
voxel_filter.setLeafSize(0.01,0.01,0.01); //resolution
PointCloud::Ptr tmp(new PointCloud);
voxel_filter.setInputCloud(pointCloud);
voxel_filter.filter(*tmp);
tmp->swap(*pointCloud);
cout<<"滤波之后,点云共有"<<pointCloud->size()<<"个点"<<endl;
pcl::io::savePCDFileBinary("map.pcd",*pointCloud);
cout<<"ok"<<endl;
return 0;
} | [
"568636643@qq.com"
] | 568636643@qq.com |
51092588415df4d7807fa7500d81a27b5c2fdafc | 27bb5ed9eb1011c581cdb76d96979a7a9acd63ba | /aws-cpp-sdk-cognito-sync/source/model/GetIdentityPoolConfigurationRequest.cpp | f6df74ef589c88d392bcd5032ce77446e966bef5 | [
"Apache-2.0",
"JSON",
"MIT"
] | permissive | exoscale/aws-sdk-cpp | 5394055f0876a0dafe3c49bf8e804d3ddf3ccc54 | 0876431920136cf638e1748d504d604c909bb596 | refs/heads/master | 2023-08-25T11:55:20.271984 | 2017-05-05T17:32:25 | 2017-05-05T17:32:25 | 90,744,509 | 0 | 0 | null | 2017-05-09T12:43:30 | 2017-05-09T12:43:30 | null | UTF-8 | C++ | false | false | 1,036 | cpp | /*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include <aws/cognito-sync/model/GetIdentityPoolConfigurationRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::CognitoSync::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
GetIdentityPoolConfigurationRequest::GetIdentityPoolConfigurationRequest() :
m_identityPoolIdHasBeenSet(false)
{
}
Aws::String GetIdentityPoolConfigurationRequest::SerializePayload() const
{
return "";
}
| [
"henso@amazon.com"
] | henso@amazon.com |
dd8eeb2dc05e545a30e75923bb80076662772d92 | 3fee62a27cffa0853e019a3352ac4fc0e0496a3d | /zCleanupCamSpace/ZenGin/Gothic_II_Classic/API/zParticle.h | fcd29ff26588f5673f847e6aaf92b23de16b3041 | [] | no_license | Gratt-5r2/zCleanupCamSpace | f4efcafe95e8a19744347ac40b5b721ddbd73227 | 77daffabac84c8e8bc45e0d7bcd7289520766068 | refs/heads/master | 2023-08-20T15:22:49.382145 | 2021-10-30T12:27:17 | 2021-10-30T12:27:17 | 422,874,598 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,486 | h | // Supported with union (c) 2018-2021 Union team
#ifndef __ZPARTICLE_H__VER2__
#define __ZPARTICLE_H__VER2__
namespace Gothic_II_Classic {
const int zPARTICLE_MAX_GLOBAL = 4096;
enum zTPFX_EmitterShape {
zPFX_EMITTER_SHAPE_POINT,
zPFX_EMITTER_SHAPE_LINE,
zPFX_EMITTER_SHAPE_BOX,
zPFX_EMITTER_SHAPE_CIRCLE,
zPFX_EMITTER_SHAPE_SPHERE,
zPFX_EMITTER_SHAPE_MESH
};
enum zTPFX_EmitterFOR {
zPFX_FOR_WORLD,
zPFX_FOR_OBJECT,
zPFX_FOR_OBJECT_EACH_FRAME
};
enum zTPFX_EmitterDirMode {
zPFX_EMITTER_DIRMODE_NONE,
zPFX_EMITTER_DIRMODE_DIR,
zPFX_EMITTER_DIRMODE_TARGET,
zPFX_EMITTER_DIRMODE_MESH
};
enum zTPFX_EmitterVisOrient {
zPFX_EMITTER_VISORIENT_NONE,
zPFX_EMITTER_VISORIENT_VELO_ALIGNED,
zPFX_EMITTER_VISORIENT_VOB_XZPLANE,
zPFX_EMITTER_VISORIENT_VELO_ALIGNED3D
};
enum zTPFX_DistribType {
zPFX_EMITTER_DISTRIBTYPE_RAND,
zPFX_EMITTER_DISTRIBTYPE_UNIFORM,
zPFX_EMITTER_DISTRIBTYPE_WALK
};
enum zTPFX_FlockMode {
zPFX_FLOCK_NONE,
zPFX_FLOCK_WIND,
zPFX_FLOCK_WIND_PLANTS,
zPFX_FLOCK_WIND_RAND
};
// sizeof 64h
typedef struct zSParticle {
public:
zSParticle* next; // sizeof 04h offset 00h
zVEC3 position; // sizeof 0Ch offset 04h
zVEC3 positionWS; // sizeof 0Ch offset 10h
zVEC3 vel; // sizeof 0Ch offset 1Ch
float lifeSpan; // sizeof 04h offset 28h
float alpha; // sizeof 04h offset 2Ch
float alphaVel; // sizeof 04h offset 30h
zVEC2 size; // sizeof 08h offset 34h
zVEC2 sizeVel; // sizeof 08h offset 3Ch
zVEC3 color; // sizeof 0Ch offset 44h
zVEC3 colorVel; // sizeof 0Ch offset 50h
float flockFreeWillTime; // sizeof 04h offset 5Ch
zCPolyStrip* polyStrip; // sizeof 04h offset 60h
void zSParticle_OnInit() zCall( 0x005A7820 );
zSParticle() zInit( zSParticle_OnInit() );
} zTParticle;
// sizeof 364h
class zCParticleEmitter {
public:
float ppsValue; // sizeof 04h offset 00h
zSTRING ppsScaleKeys_S; // sizeof 14h offset 04h
int ppsIsLooping; // sizeof 04h offset 18h
int ppsIsSmooth; // sizeof 04h offset 1Ch
float ppsFPS; // sizeof 04h offset 20h
zSTRING ppsCreateEm_S; // sizeof 14h offset 24h
float ppsCreateEmDelay; // sizeof 04h offset 38h
zSTRING shpType_S; // sizeof 14h offset 3Ch
zSTRING shpFOR_S; // sizeof 14h offset 50h
zSTRING shpOffsetVec_S; // sizeof 14h offset 64h
zSTRING shpDistribType_S; // sizeof 14h offset 78h
float shpDistribWalkSpeed; // sizeof 04h offset 8Ch
int shpIsVolume; // sizeof 04h offset 90h
zSTRING shpDim_S; // sizeof 14h offset 94h
zSTRING shpMesh_S; // sizeof 14h offset A8h
int shpMeshRender_B; // sizeof 04h offset BCh
zSTRING shpScaleKeys_S; // sizeof 14h offset C0h
int shpScaleIsLooping; // sizeof 04h offset D4h
int shpScaleIsSmooth; // sizeof 04h offset D8h
float shpScaleFPS; // sizeof 04h offset DCh
zSTRING dirMode_S; // sizeof 14h offset E0h
zSTRING dirFOR_S; // sizeof 14h offset F4h
zSTRING dirModeTargetFOR_S; // sizeof 14h offset 108h
zSTRING dirModeTargetPos_S; // sizeof 14h offset 11Ch
float dirAngleHead; // sizeof 04h offset 130h
float dirAngleHeadVar; // sizeof 04h offset 134h
float dirAngleElev; // sizeof 04h offset 138h
float dirAngleElevVar; // sizeof 04h offset 13Ch
float velAvg; // sizeof 04h offset 140h
float velVar; // sizeof 04h offset 144h
float lspPartAvg; // sizeof 04h offset 148h
float lspPartVar; // sizeof 04h offset 14Ch
zSTRING flyGravity_S; // sizeof 14h offset 150h
int flyCollDet_B; // sizeof 04h offset 164h
zSTRING visName_S; // sizeof 14h offset 168h
zSTRING visOrientation_S; // sizeof 14h offset 17Ch
int visTexIsQuadPoly; // sizeof 04h offset 190h
float visTexAniFPS; // sizeof 04h offset 194h
int visTexAniIsLooping; // sizeof 04h offset 198h
zSTRING visTexColorStart_S; // sizeof 14h offset 19Ch
zSTRING visTexColorEnd_S; // sizeof 14h offset 1B0h
zSTRING visSizeStart_S; // sizeof 14h offset 1C4h
float visSizeEndScale; // sizeof 04h offset 1D8h
zSTRING visAlphaFunc_S; // sizeof 14h offset 1DCh
float visAlphaStart; // sizeof 04h offset 1F0h
float visAlphaEnd; // sizeof 04h offset 1F4h
float trlFadeSpeed; // sizeof 04h offset 1F8h
zSTRING trlTexture_S; // sizeof 14h offset 1FCh
float trlWidth; // sizeof 04h offset 210h
float mrkFadeSpeed; // sizeof 04h offset 214h
zSTRING mrkTexture_S; // sizeof 14h offset 218h
float mrkSize; // sizeof 04h offset 22Ch
zSTRING m_flockMode_S; // sizeof 14h offset 230h
float m_fFlockWeight; // sizeof 04h offset 244h
int m_bSlowLocalFOR; // sizeof 04h offset 248h
zSTRING m_timeStartEnd_S; // sizeof 14h offset 24Ch
int m_bIsAmbientPFX; // sizeof 04h offset 260h
int endOfDScriptPart; // sizeof 04h offset 264h
zSTRING particleFXName; // sizeof 14h offset 268h
zCArray<float> ppsScaleKeys; // sizeof 0Ch offset 27Ch
zCParticleEmitter* ppsCreateEmitter; // sizeof 04h offset 288h
zTPFX_EmitterShape shpType; // sizeof 04h offset 28Ch
float shpCircleSphereRadius; // sizeof 04h offset 290h
zVEC3 shpLineBoxDim; // sizeof 0Ch offset 294h
zCMesh* shpMesh; // sizeof 04h offset 2A0h
zCPolygon* shpMeshLastPoly; // sizeof 04h offset 2A4h
zTPFX_EmitterFOR shpFOR; // sizeof 04h offset 2A8h
zTPFX_DistribType shpDistribType; // sizeof 04h offset 2ACh
zVEC3 shpOffsetVec; // sizeof 0Ch offset 2B0h
zCArray<float> shpScaleKeys; // sizeof 0Ch offset 2BCh
zTPFX_EmitterDirMode dirMode; // sizeof 04h offset 2C8h
zTPFX_EmitterFOR dirFOR; // sizeof 04h offset 2CCh
zTPFX_EmitterFOR dirModeTargetFOR; // sizeof 04h offset 2D0h
zVEC3 dirModeTargetPos; // sizeof 0Ch offset 2D4h
zTBBox3D dirAngleBox; // sizeof 18h offset 2E0h
zVEC3 dirAngleBoxDim; // sizeof 0Ch offset 2F8h
zVEC3 flyGravity; // sizeof 0Ch offset 304h
zCTexture* visTexture; // sizeof 04h offset 310h
zCMesh* visMesh; // sizeof 04h offset 314h
zTPFX_EmitterVisOrient visOrientation; // sizeof 04h offset 318h
zVEC2 visSizeStart; // sizeof 08h offset 31Ch
zVEC3 visTexColorRGBAStart; // sizeof 0Ch offset 324h
zVEC3 visTexColorRGBAEnd; // sizeof 0Ch offset 330h
zTRnd_AlphaBlendFunc visAlphaFunc; // sizeof 04h offset 33Ch
zCTexture* trlTexture; // sizeof 04h offset 340h
zCTexture* mrkTexture; // sizeof 04h offset 344h
int isOneShotFX; // sizeof 04h offset 348h
float dirAngleHeadVarRad; // sizeof 04h offset 34Ch
float dirAngleElevVarRad; // sizeof 04h offset 350h
zTPFX_FlockMode m_flockMode; // sizeof 04h offset 354h
float m_ooAlphaDist; // sizeof 04h offset 358h
float m_startTime; // sizeof 04h offset 35Ch
float m_endTime; // sizeof 04h offset 360h
void zCParticleEmitter_OnInit( zCParticleEmitter const& ) zCall( 0x005A8A70 );
void zCParticleEmitter_OnInit() zCall( 0x005AD200 );
zCParticleEmitter( zCParticleEmitter const& a0 ) zInit( zCParticleEmitter_OnInit( a0 ));
zCParticleEmitter() zInit( zCParticleEmitter_OnInit() );
~zCParticleEmitter() zCall( 0x005AD520 );
void UpdateVelocity() zCall( 0x005AD860 );
void AddCompoundReferences() zCall( 0x005AD870 );
void ResetStrings() zCall( 0x005AD8C0 );
void Reset() zCall( 0x005ADB60 );
void UpdateInternals() zCall( 0x005AE020 );
void SetOutputDir( zVEC3 const& ) zCall( 0x005AEE70 );
void ConvertAnglesIntoBox() zCall( 0x005AF0B0 );
zVEC3 GetPosition() zCall( 0x005AF100 );
zVEC3 __fastcall GetVelocity( zSParticle*, zCParticleFX* ) zCall( 0x005AF500 );
zCParticleEmitter& operator =( zCParticleEmitter const& ) zCall( 0x007111E0 );
static zVEC3 String2Vec3( zSTRING const& ) zCall( 0x005ADB80 );
static zVEC2 String2Vec2( zSTRING const& ) zCall( 0x005ADE00 );
// user API
#include "zCParticleEmitter.inl"
};
// sizeof 1Ch
class zCParticleEmitterVars {
public:
float ppsScaleKeysActFrame; // sizeof 04h offset 00h
float ppsNumParticlesFraction; // sizeof 04h offset 04h
float ppsTotalLifeTime; // sizeof 04h offset 08h
int ppsDependentEmitterCreated; // sizeof 04h offset 0Ch
float shpScaleKeysActFrame; // sizeof 04h offset 10h
float uniformValue; // sizeof 04h offset 14h
float uniformDelta; // sizeof 04h offset 18h
zCParticleEmitterVars() {}
// user API
#include "zCParticleEmitterVars.inl"
};
// sizeof B8h
class zCParticleFX : public zCVisual {
public:
zCLASS_DECLARATION( zCParticleFX )
// sizeof 0Ch
class zCStaticPfxList {
public:
zCParticleFX* pfxListHead; // sizeof 04h offset 00h
zCParticleFX* pfxListTail; // sizeof 04h offset 04h
int numInList; // sizeof 04h offset 08h
zCStaticPfxList() {}
void InsertPfxHead( zCParticleFX* ) zCall( 0x005A7C00 );
void RemovePfx( zCParticleFX* ) zCall( 0x005A7C40 );
void TouchPfx( zCParticleFX* ) zCall( 0x005A7CB0 );
void ProcessList() zCall( 0x005A7D70 );
int IsInList( zCParticleFX* ) zCall( 0x005A84B0 );
// user API
#include "zCParticleFX_zCStaticPfxList.inl"
};
zTParticle* firstPart; // sizeof 04h offset 34h
zCParticleEmitterVars emitterVars; // sizeof 1Ch offset 38h
zCParticleEmitter* emitter; // sizeof 04h offset 54h
zTBBox3D bbox3DWorld; // sizeof 18h offset 58h
zCVob* connectedVob; // sizeof 04h offset 70h
int bboxUpdateCtr; // sizeof 04h offset 74h
group {
unsigned char emitterIsOwned : 1; // sizeof 01h offset bit
unsigned char dontKillPFXWhenDone : 1; // sizeof 01h offset bit
unsigned char dead : 1; // sizeof 01h offset bit
unsigned char isOneShotFX : 1; // sizeof 01h offset bit
unsigned char forceEveryFrameUpdate : 1; // sizeof 01h offset bit
unsigned char renderUnderWaterOnly : 1; // sizeof 01h offset bit
};
zCParticleFX* nextPfx; // sizeof 04h offset 7Ch
zCParticleFX* prevPfx; // sizeof 04h offset 80h
float privateTotalTime; // sizeof 04h offset 84h
float lastTimeRendered; // sizeof 04h offset 88h
float timeScale; // sizeof 04h offset 8Ch
float localFrameTimeF; // sizeof 04h offset 90h
zCQuadMark* quadMark; // sizeof 04h offset 94h
zTBBox3D quadMarkBBox3DWorld; // sizeof 18h offset 98h
float m_BboxYRangeInv; // sizeof 04h offset B0h
int m_bVisualNeverDies; // sizeof 04h offset B4h
void zCParticleFX_OnInit() zCall( 0x005A78F0 );
zCParticleFX() zInit( zCParticleFX_OnInit() );
void InitEmitterVars() zCall( 0x005A8550 );
void FreeParticles() zCall( 0x005A8570 );
void RemoveEmitter() zCall( 0x005A88E0 );
int SetEmitter( zCParticleEmitter*, int ) zCall( 0x005A8920 );
int SetEmitter( zSTRING const&, int ) zCall( 0x005A9460 );
int SetAndStartEmitter( zSTRING const&, int ) zCall( 0x005A9660 );
int SetAndStartEmitter( zCParticleEmitter*, int ) zCall( 0x005A9690 );
void StopEmitterOutput() zCall( 0x005A96C0 );
void RestoreEmitterOutput() zCall( 0x005A96D0 );
int CalcIsDead() zCall( 0x005A99F0 );
void UpdateParticleFX() zCall( 0x005A9A80 );
void CreateParticlesUpdateDependencies() zCall( 0x005A9B60 );
void UpdateParticle( zSParticle* ) zCall( 0x005A9E10 );
float GetShapeScaleThisFrame() zCall( 0x005AC2C0 );
int GetNumParticlesThisFrame() zCall( 0x005AC430 );
void CheckDependentEmitter() zCall( 0x005AC5D0 );
void CreateParticles() zCall( 0x005AC770 );
static zCObject* _CreateNewInstance() zCall( 0x005A6ED0 );
static void ParseParticleFXScript() zCall( 0x005A7000 );
static void InitParticleFX() zCall( 0x005A74D0 );
static void CleanupParticleFX() zCall( 0x005A7830 );
static zCParticleEmitter* SearchParticleEmitter( zSTRING const& ) zCall( 0x005A8720 );
static zCParticleFX* Load( zSTRING const& ) zCall( 0x005A9710 );
static float PartRand() zCall( 0x005A9A60 );
virtual zCClassDef* _GetClassDef() const zCall( 0x005A79F0 );
virtual ~zCParticleFX() zCall( 0x005A7A60 );
virtual int Render( zTRenderContext& ) zCall( 0x005AADB0 );
virtual int IsBBox3DLocal() zCall( 0x005A7A00 );
virtual zTBBox3D GetBBox3D() zCall( 0x005A98C0 );
virtual zSTRING GetVisualName() zCall( 0x005A8670 );
virtual int GetVisualDied() zCall( 0x005A7A10 );
virtual void SetVisualUsedBy( zCVob* ) zCall( 0x005A85C0 );
virtual unsigned long GetRenderSortKey() const zCall( 0x005A7A20 );
virtual void HostVobRemovedFromWorld( zCVob*, zCWorld* ) zCall( 0x005A7BF0 );
virtual void HostVobAddedToWorld( zCVob*, zCWorld* ) zCall( 0x005A7BD0 );
virtual zSTRING const* GetFileExtension( int ) zCall( 0x005A84E0 );
virtual zCVisual* LoadVisualVirtual( zSTRING const& ) const zCall( 0x005A8540 );
// static properties
static zCParser*& s_pfxParser;
static zCArraySort<zCParticleEmitter*>& s_emitterPresetList;
static zCParticleEmitter& s_emitterDummyDefault;
static int& s_bAmbientPFXEnabled;
static int& s_globNumPart;
static zTParticle*& s_globPartList;
static zTParticle*& s_globFreePart;
static zCMesh*& s_partMeshTri;
static zCMesh*& s_partMeshQuad;
static int& s_showDebugInfo;
static zCStaticPfxList& s_pfxList;
// user API
#include "zCParticleFX.inl"
};
} // namespace Gothic_II_Classic
#endif // __ZPARTICLE_H__VER2__ | [
"amax96@yandex.ru"
] | amax96@yandex.ru |
d9325460d7f6c76008bcfd78ed640eeef1b9e974 | f4367e9ab6cec456cc716a411ff89ffea1318849 | /SDL Game/SDL Game/Engine/Components/Transforms/Transform.cpp | 60fc6127d57ec8c8b86261ac5de75d78b545bef6 | [
"MIT"
] | permissive | BrunoAOR/SDL-Game | 5a3d3d47cab279c5d4ad2e279b8f5ba33a111cba | 090a09e2c19d18b000769f353c5e7727d60fe5f6 | refs/heads/master | 2021-01-22T14:49:36.914345 | 2017-11-18T13:29:07 | 2017-11-18T13:29:07 | 100,718,943 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,905 | cpp | #include "Transform.h"
#define _USE_MATH_DEFINES
#include <math.h>
#include "Engine/EngineUtils.h"
#include "Engine/Components/ComponentType.h"
Transform::Transform()
: m_localPosition(Vector2(0,0))
, m_localRotation(0)
, m_localScale(Vector2(1,1))
, m_worldPosition(Vector2(0, 0))
, m_worldRotation(0)
, m_worldScale(Vector2(1, 1))
, m_parentTransform(nullptr)
{
type = ComponentType::Transform;
}
Vector2 Transform::getLocalPosition() const
{
return m_localPosition;
}
Vector2 Transform::getWorldPosition() const
{
return m_worldPosition;
}
void Transform::setLocalPosition(const Vector2& position)
{
m_localPosition = position;
m_worldPosition = localToWorldPosition(position);
updateChildrenWorldFields();
}
void Transform::setWorldPosition(const Vector2& position)
{
m_worldPosition = position;
if (m_parentTransform == nullptr)
{
m_localPosition = position;
}
else
{
Vector2 parentWorldScale = m_parentTransform->getWorldScale();
if (parentWorldScale.x == 0 || parentWorldScale.y == 0)
{
return;
}
m_localPosition = worldToLocalPosition(position);
}
updateChildrenWorldFields();
}
double Transform::getLocalRotation() const
{
return m_localRotation;
}
double Transform::getWorldRotation() const
{
return m_worldRotation;
}
void Transform::setLocalRotation(double rotation)
{
// Set Local Rotation
// Clamp between 0 and 360
m_localRotation = rotation - 360 * (int)(rotation / 360);
// Set World Rotation
m_worldRotation = localToWorldRotation(rotation);
updateChildrenWorldFields();
}
void Transform::setWorldRotation(double rotation)
{
// Set World Rotation
// Clamp between 0 and 360
m_worldRotation = rotation - 360 * (int)(rotation / 360);
// Set Local Rotation
m_localRotation = worldToLocalRotation(rotation);
updateChildrenWorldFields();
}
Vector2 Transform::getLocalScale() const
{
return m_localScale;
}
Vector2 Transform::getWorldScale() const
{
return m_worldScale;
}
void Transform::setLocalScale(const Vector2& scale)
{
m_localScale = scale;
m_worldScale = localToWorldScale(scale);
updateChildrenWorldFields();
}
void Transform::setWorldScale(const Vector2& scale)
{
m_worldScale = scale;
m_localScale = worldToLocalScale(scale);
updateChildrenWorldFields();
}
Vector2 Transform::localToWorldPosition(const Vector2 & localPosition) const
{
if (m_parentTransform == nullptr)
{
return localPosition;
}
else
{
Vector2 worldPosition;
// 1. Solve the rotation
// 1.1 Get polar coordinates for localPosition (r and theta)
double r = sqrt(localPosition.x * localPosition.x + localPosition.y * localPosition.y);
double theta = atan2(localPosition.y, localPosition.x);
// 1.2 use the polar coordinate to recalculate the x and y coordinates
double parentWorldRotation = m_parentTransform->getWorldRotation();
worldPosition.x = r * cos(theta + M_PI / 180 * parentWorldRotation);
worldPosition.y = r * sin(theta + M_PI / 180 * parentWorldRotation);
// 2. Solve the scale
Vector2 parentWorldScale = m_parentTransform->getWorldScale();
worldPosition.x *= parentWorldScale.x;
worldPosition.y *= parentWorldScale.y;
// 3. Solve the position
Vector2 parentWorldPosition = m_parentTransform->getWorldPosition();
worldPosition.x += parentWorldPosition.x;
worldPosition.y += parentWorldPosition.y;
return (worldPosition);
}
}
Vector2 Transform::worldToLocalPosition(const Vector2 & worldPosition) const
{
if (m_parentTransform == nullptr)
{
return worldPosition;
}
else
{
Vector2 parentWorldScale = m_parentTransform->getWorldScale();
if (parentWorldScale.x == 0 || parentWorldScale.y == 0)
{
return worldPosition;
}
Vector2 localPosition = Vector2();
// 1. Solve position
Vector2 parentWorldPosition = m_parentTransform->getWorldPosition();
localPosition.x = worldPosition.x - parentWorldPosition.x;
localPosition.y = worldPosition.y - parentWorldPosition.y;
// 2. Solve scale
localPosition.x /= parentWorldScale.x;
localPosition.y /= parentWorldScale.y;
// 3. Solve rotation
// 3.1 Get polar coordinates for the current localPosition (r and theta)
double r = sqrt(localPosition.x * localPosition.x + localPosition.y * localPosition.y);
double theta = atan2(localPosition.y, localPosition.x);
// 3.2 use the polar coordinate to recalculate the x and y coordinates
double parentWorldRotation = m_parentTransform->getWorldRotation();
localPosition.x = r * cos(theta - M_PI / 180 * parentWorldRotation);
localPosition.y = r * sin(theta - M_PI / 180 * parentWorldRotation);
return localPosition;
}
}
double Transform::localToWorldRotation(double localRotation) const
{
double worldRotation = localRotation;
if (m_parentTransform != nullptr)
{
// For rotation, one only needs to add the parent rotation
worldRotation += m_parentTransform->getWorldRotation();
}
// Clamp between 0 and 360
worldRotation -= 360 * (int)(worldRotation / 360);
return (worldRotation);
}
double Transform::worldToLocalRotation(double worldRotation) const
{
if (m_parentTransform == nullptr)
{
return worldRotation;
}
else
{
double localRotation = worldRotation - m_parentTransform->getWorldRotation();
localRotation -= 360 * (int)(localRotation / 360);
return localRotation;
}
}
Vector2 Transform::localToWorldScale(const Vector2 & localScale) const
{
if (m_parentTransform == nullptr)
{
return localScale;
}
else
{
Vector2 worldScale;
Vector2 parentWorldScale = m_parentTransform->getWorldScale();
worldScale.x = localScale.x * parentWorldScale.x;
worldScale.y = localScale.y * parentWorldScale.y;
// For scale, one only needs to multiply the parent scale
return (worldScale);
}
}
Vector2 Transform::worldToLocalScale(const Vector2 & worldScale) const
{
if (m_parentTransform == nullptr)
{
return worldScale;
}
else
{
Vector2 localScale;
Vector2 parentWorldScale = m_parentTransform->getWorldScale();
if (parentWorldScale.x != 0)
{
localScale.x = worldScale.x / parentWorldScale.x;
}
if (parentWorldScale.y != 0)
{
localScale.y = worldScale.y / parentWorldScale.y;
}
return localScale;
}
}
std::weak_ptr<Transform> Transform::getParent()
{
return m_parentWeakPtr;
}
bool Transform::setParent(std::weak_ptr<Transform> parent)
{
if (parent.expired())
{
removeParent();
}
Transform* parentTransform = parent.lock().get();
// So, if we try to set the current parent as new parent, nothing needs to be done.
if (m_parentTransform == parentTransform)
{
return true;
}
// If the parent is a child of this transform, we return false
if (isTransformInChildrenHierarchy(parentTransform))
{
return false;
}
// Now, we remove the parent (which in turn removes this transform from the m_parent's children list)
if (m_parentTransform != nullptr)
{
m_parentTransform->removeChild(this);
m_parentTransform = nullptr;
}
// Add this transform to the parentTransform's children
if (parentTransform->addChild(this))
{
// And then set the m_parent variable
m_parentTransform = parentTransform;
m_parentWeakPtr = parent;
updateLocalFields();
return true;
}
else
{
updateLocalFields();
return false;
}
}
void Transform::removeParent()
{
if (m_parentTransform != nullptr)
{
m_parentTransform->removeChild(this);
m_parentTransform = nullptr;
m_parentWeakPtr.reset();
}
updateLocalFields();
}
bool Transform::addChild(Transform * childTransform)
{
int index = EngineUtils::indexOf(m_children, childTransform);
if (index == -1)
{
m_children.push_back(childTransform);
return true;
}
return false;
}
bool Transform::removeChild(Transform * childTransform)
{
int index = EngineUtils::indexOf(m_children, childTransform);
if (index != -1)
{
m_children.erase(m_children.begin() + index);
return true;
}
return false;
}
bool Transform::isTransformInChildrenHierarchy(Transform* transform)
{
for (auto childTransform : m_children)
{
if (childTransform == transform)
{
return true;
}
return(childTransform->isTransformInChildrenHierarchy(transform));
}
return false;
}
void Transform::updateLocalFields()
{
m_localPosition = worldToLocalPosition(m_worldPosition);
m_localRotation = worldToLocalRotation(m_worldRotation);
m_localScale = worldToLocalScale(m_worldScale);
}
void Transform::updateWorldFields()
{
m_worldPosition = localToWorldPosition(m_localPosition);
m_worldRotation = localToWorldRotation(m_localRotation);
m_worldScale = localToWorldScale(m_localScale);
}
void Transform::updateChildrenLocalFields()
{
for (Transform* childTransform : m_children)
{
childTransform->updateLocalFields();
childTransform->updateChildrenLocalFields();
}
}
void Transform::updateChildrenWorldFields()
{
for (Transform* childTransform : m_children)
{
childTransform->updateWorldFields();
childTransform->updateChildrenWorldFields();
}
}
| [
"brunoorla@gmail.com"
] | brunoorla@gmail.com |
5336de50a5200a65be8ca02925c9ef285eaa2541 | 95a21e51d1ee52c05c8f491ae174ac8af90da028 | /java/cpp/dataStructures/searchTrees/TreeMap.cpp | 48d158ac571c00fe6a5367548f0c8c765926d905 | [] | no_license | HarryWei/grafalgo | aeef008c9c39ebf9242c4c70058e5dfdd4993fdf | d3a21279dc7c26b694f6e8e346b00d69bbeca912 | refs/heads/master | 2020-04-14T21:28:04.793254 | 2016-05-11T17:32:03 | 2016-05-11T17:32:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,262 | cpp | /** @file TreeMap.cpp
*
* @author Jon Turner
* @date 2011
* This is open source software licensed under the Apache 2.0 license.
* See http://www.apache.org/licenses/LICENSE-2.0 for details.
*/
#include "TreeMap.h"
/** Constructor for TreeMap, allocates space and initializes map.
* N1 is the max number of key-value pairs that can be stored.
*/
TreeMap::TreeMap(int n1) : n(n1) {
st = new BalancedBsts(n);
values = new uint32_t[n+1];
nodes = new UiSetPair(n);
root = 0;
clear();
};
/** Destructor for TreeMap. */
TreeMap::~TreeMap() {
delete st; delete [] values; delete nodes;
}
/** Clear the TreeMap contents. */
// could speed this up with a post-order traversal
// but would really need to do this in the search tree object
void TreeMap::clear() {
while (root != 0) {
nodes->swap(root); st->remove(root,root);
}
}
/** Get the value for a specified key.
* @param key is the key to be looked up in the table
* @return the value stored for the given key, or UNDEF_VAL if there is none.
*/
int TreeMap::get(keytyp key) {
if (root == 0) return UNDEF_VAL;
item x = st->access(key,root);
if (x == 0) return UNDEF_VAL;
return values[x];
}
/** Put a (key,value) pair into the map.
* If there is already a pair defined for the given key value,
* just update the value
* @param key is the key part of the pair
* @param val is the value part of the pair
* @return true on success, false on failure.
*/
bool TreeMap::put(uint64_t key, uint32_t val) {
item x;
if (root == 0 || (x = st->access(key,root)) == 0) {
x = nodes->firstOut();
if (x == 0) return false;
nodes->swap(x);
st->setkey(x,key);
if (root == 0) root = x;
else st->insert(x,root);
}
values[x] = val;
return true;
}
/** Remove a (key, value) pair from the table.
* @param key is the key of the pair to be removed
*/
void TreeMap::remove(uint64_t key) {
item x;
if (root != 0 && (x = st->access(key,root)) != 0) {
st->remove(x,root);
nodes->swap(x);
}
return;
}
// Construct string listing the key,value pairs in the map
string& TreeMap::toString(string& s) const {
stringstream ss;
for (item u = nodes->firstIn(); u != 0; u = nodes->nextIn(u)) {
ss << " " << st->key(u) << "," << values[u];
}
s = ss.str();
return s;
}
| [
"jonturner53@gmail.com"
] | jonturner53@gmail.com |
93b4db8661a106308a30237f8ba55d9967347940 | 682a576b5bfde9cf914436ea1b3d6ec7e879630a | /components/material/nodes/toolbar/MaterialTabToolbar.h | cbb0ff37fb747b2f918ca13960904880829bad89 | [
"MIT",
"BSD-3-Clause"
] | permissive | SBKarr/stappler | 6dc914eb4ce45dc8b1071a5822a0f0ba63623ae5 | 4392852d6a92dd26569d9dc1a31e65c3e47c2e6a | refs/heads/master | 2023-04-09T08:38:28.505085 | 2023-03-25T15:37:47 | 2023-03-25T15:37:47 | 42,354,380 | 10 | 3 | null | 2017-04-14T10:53:27 | 2015-09-12T11:16:09 | C++ | UTF-8 | C++ | false | false | 2,355 | h | /**
Copyright (c) 2016 Roman Katuntsev <sbkarr@stappler.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
**/
#ifndef MATERIAL_NODES_TOOLBAR_MATERIALTABTOOLBAR_H_
#define MATERIAL_NODES_TOOLBAR_MATERIALTABTOOLBAR_H_
#include "MaterialToolbar.h"
#include "MaterialTabBar.h"
NS_MD_BEGIN
class TabToolbar : public Toolbar {
public:
virtual bool init() override;
virtual void onContentSizeDirty() override;
virtual void setTabMenuSource(MenuSource *);
virtual MenuSource * getTabMenuSource() const;
virtual void setButtonStyle(const TabBar::ButtonStyle &);
virtual const TabBar::ButtonStyle & getButtonStyle() const;
virtual void setBarStyle(const TabBar::BarStyle &);
virtual const TabBar::BarStyle & getBarStyle() const;
virtual void setAlignment(const TabBar::Alignment &);
virtual const TabBar::Alignment & getAlignment() const;
virtual void setTextColor(const Color &color) override;
virtual void setSelectedColor(const Color &);
virtual Color getSelectedColor() const;
virtual void setAccentColor(const Color &);
virtual Color getAccentColor() const;
virtual void setSelectedIndex(size_t);
virtual size_t getSelectedIndex() const;
protected:
virtual float getDefaultToolbarHeight() const override;
virtual float getBaseLine() const override;
TabBar *_tabs = nullptr;
};
NS_MD_END
#endif /* MATERIAL_NODES_TOOLBAR_MATERIALTABTOOLBAR_H_ */
| [
"sbkarr@stappler.org"
] | sbkarr@stappler.org |
6bfdcdd7f3421f22bb1e8681c6addd5767eb03c3 | ac2a669ab120792ec314d28cf3fb58d325bc40fb | /wuduo/base/Thread.h | cf0e2d2d950df8856ec265e7d582b7547f63baed | [] | no_license | torn4do/wuduo | 5da8f8312268f94132d8f77cb6a6140ac3221a89 | 1cb1bb044e9cd3383166aa2b5d8d233472230df9 | refs/heads/master | 2021-01-19T20:06:10.264005 | 2017-04-24T13:18:43 | 2017-04-24T13:18:43 | 88,471,156 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 879 | h | #ifndef WUDUO_BASE_THREAD_H
#define WUDUO_BASE_THREAD_H
#include <pthread.h>
#include <functional>
#include <memory>
#include <unistd.h>
#include <sys/syscall.h>
#include "Noncopyable.h"
namespace wuduo
{
namespace CurrentThread
{
pid_t tid()
{
return static_cast<pid_t>(::syscall(SYS_gettid));
}
}
class Thread
{
typedef std::function<void()> ThreadFunc;
public:
explicit Thread(const ThreadFunc);
~Thread();
void start();
int join();
pid_t tid() const {return tid_;};
bool started() const {return started_;};
private:
static void* threadfunc(void*);//static原因:若为普通成员函数,则参数为(Thread*),不符合pthread_create的的参数(void*)
pthread_t pthreadId_;//pthread库的线程id
//shared_ptr<pid_t> tid_;//内核线程id
pid_t tid_;//内核线程id
ThreadFunc func_;
bool started_;
bool joined_;
};
}
#endif
| [
"torndo1102@163.com"
] | torndo1102@163.com |
c2ba396410e00ea2becec9869fc7ab52d8790757 | f34aafa1f0415de4db2d888a5d25ae341aa3e069 | /examples/example03.cpp | 99f24fdcb853f37d6208148472208e7b6f1991d4 | [
"MIT"
] | permissive | mambaru/wjrpc | 59fe91f0df5f8e861ae6d27e067c74b506a81322 | aabea1d07c707111c55a35e160b5a3f34e93ae5c | refs/heads/master | 2023-08-25T00:15:54.734860 | 2023-08-03T21:57:06 | 2023-08-03T21:57:07 | 71,155,902 | 5 | 2 | MIT | 2021-04-22T12:38:31 | 2016-10-17T15:59:20 | C++ | UTF-8 | C++ | false | false | 1,715 | cpp | #include "calc/api/plus.hpp"
#include "calc/api/plus_json.hpp"
#include <wjrpc/incoming/incoming_holder.hpp>
#include <wjrpc/outgoing/outgoing_holder.hpp>
#include <wjrpc/outgoing/outgoing_result.hpp>
#include <wjrpc/outgoing/outgoing_result_json.hpp>
#include <wjson/_json.hpp>
#include <iostream>
/**
* @example example03.cpp
* @brief Пример "ручной" сериализации ответа на запрос
*/
/**
* Output:
{"jsonrpc":"2.0","method":"plus","params":{"first":2,"second":3},"id":"id-1123"}
{"jsonrpc":"2.0","result":{"value":5},"id":"id-1123"}
*/
int main()
{
using namespace wjson::literals;
wjrpc::incoming_holder inholder( "{'jsonrpc':'2.0','method':'plus','params':{'first':2,'second':3},'id':'id-1123'}"_json );
std::cout << inholder.str() << std::endl;
// Парсим без проверок на ошибки
inholder.parse(nullptr);
// Есть имя метода и идентификатор вызова
if ( inholder.method() == "plus" )
{
// Десериализация параметров без проверок
auto params = inholder.get_params<request::plus_json>(nullptr);
// Объект для ответа
wjrpc::outgoing_result<response::plus> res;
res.result = std::make_unique<response::plus>();
res.result->value = params->first + params->second;
res.id = std::make_unique<wjrpc::data_type>(inholder.raw_id().first, inholder.raw_id().second);
// Сериализатор ответа
typedef wjrpc::outgoing_result_json<response::plus_json> result_json;
result_json::serializer()( res, std::ostreambuf_iterator<char>(std::cout) );
std::cout << std::endl;
}
}
| [
"migashko@gmail.com"
] | migashko@gmail.com |
9ee833cde942568d0e67bf5e351a74e38b88d90e | d515ceafa5ae2d187ab6315e1b66cdfee615dabc | /homeworks/Gayane_Nerkararyan/Shared_ptr/my_shared_ptr.cpp | b84137c344a519ed74f8d567b3d423d939e4cc11 | [] | no_license | Internal-Trainings-Vanadzor/Internal-Trainings | 9e08f8901d467c6e57e1da18de4a349cd6def6dc | b37ec79c352dfba06e6bed9b3bed95cd175616c9 | refs/heads/master | 2021-01-10T17:55:19.724266 | 2015-10-20T19:34:04 | 2015-10-20T19:34:04 | 36,315,296 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,081 | cpp | #include<iostream>
#include "my_shared_ptr.h"
my_shared_ptr::my_shared_ptr()
:m_memory(NULL)
{
m_count = new int (0);
}
my_shared_ptr::my_shared_ptr(int* memory)
:m_memory(memory)
{
if (memory != NULL)
{
m_count = new int (1);
}
else
{
m_count = new int (0);
}
}
my_shared_ptr::my_shared_ptr(my_shared_ptr& memory)
:m_memory(memory.m_memory)
{
if (memory.m_memory != NULL && memory.m_memory == m_memory)
{
m_count = memory.m_count;
*m_count = *m_count + 1;
}
}
const int my_shared_ptr::get_value()const
{
return *m_memory;
}
int my_shared_ptr::use_count()
{
if (*m_count != NULL)
{
return *m_count;
}
else
{
return 0;
}
}
void my_shared_ptr::set_value(int value)
{
*m_memory = value;
}
my_shared_ptr& my_shared_ptr::operator=(my_shared_ptr& obj)
{
m_memory = obj.m_memory;
if (obj.m_memory != NULL && obj.m_memory == m_memory)
{
*m_count = *m_count + 1;
}
return *this;
}
my_shared_ptr::~my_shared_ptr()
{
if(m_memory != NULL)
{
*m_count = *m_count - 1;
if (*m_count == 0)
{
delete m_memory;
delete m_count;
}
}
}
| [
"imagin1@yandex.ru"
] | imagin1@yandex.ru |
43792fa56cdeb140b7b740706aaee2662420ffa6 | 9f69c4c61ca2a2082643f9316354826f6144e1f5 | /CSES/Range Queries/range_xor_queries.cpp | f7e24bbb99bd9c080b86d00cddb0fd51ab35cecd | [] | no_license | julianferres/Competitive-Programming | 668c22cf5174c57a2f3023178b1517cb25bdd583 | c3b0be4f796d1c0d755a61a6d2f3665c86cd8ca9 | refs/heads/master | 2022-03-23T05:56:53.790660 | 2022-03-18T14:29:33 | 2022-03-18T14:29:33 | 146,931,407 | 4 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,456 | cpp | /******************************************
* AUTHOR: JULIAN FERRES *
* INSTITUITION: FIUBA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define FIN \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define forr(i, a, b) for (int i = (a); i < (int)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v, n) \
forn(i, n) cout << v[i] << " "; \
cout << endl
#define RAYA cerr << "===============================" << endl
const ll N = 200005; // limit for array size
ll n; // array size
ll t[2 * N];
void build()
{ // build the tree
for (ll i = n - 1; i > 0; --i)
t[i] = t[i << 1] ^ t[i << 1 | 1];
}
ll query(ll l, ll r)
{ // sum on interval [l, r)
ll res = 0;
for (l += n, r += n; l < r; l >>= 1, r >>= 1)
{
if (l & 1)
res ^= t[l++];
if (r & 1)
res ^= t[--r];
}
return res;
}
int main()
{
FIN;
int q;
cin >> n >> q;
forn(i, n) cin >> t[n + i];
build();
forn(i, q)
{
ll a, b;
cin >> a >> b;
a--;
cout << query(a, b) << endl;
}
return 0;
}
| [
"julianferres@gmail.com"
] | julianferres@gmail.com |
47e6ab7901bd3cbc7183b372b01cf6e5c2bf1850 | 90938cd781bc521eb05d46e20e635d94617132a7 | /project4/source/modes.cpp | d2f85c20c27853f9fb43fe7ff99dab9c9325f23f | [] | no_license | fonstelien/FYS4150 | 1f1daf33052cad598a2b1f7e9509969a80019b77 | 0e6cf60d44919950485600b2d9e998f2106b47aa | refs/heads/master | 2023-02-09T11:05:53.486396 | 2021-01-04T21:43:30 | 2021-01-04T21:43:30 | 288,813,427 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,195 | cpp | #include "utils.hpp"
/* Loops over temperature range T1 to T2 with steps dT. Lattice size LxL.
Returns result arma::mat. Simulation runs for equilibration_cycles before
logging of results begins. Total runs = equilibration_cycles + cycles. */
mat temp_range(int L, double entropy, double T1, double dT, double T2,
int cycles, int equilibration_cycles) {
mat results;
int n, num_accepted;
// Setting up results matrix
n = (int) ((T2 - T1)/dT + 1.);
if (n > MAX_SAMPLES) {
cerr << "error: too many steps dT" << endl;
exit(2);
}
results = mat(n, 6); // T, E, CV, Mabs, Chi, M
#pragma omp parallel
{
double E, M, T;
double Eacc, E2acc, Macc, M2acc, Macc_abs;
char *p, **lattice;
double wij[17];
mt19937_64 rng(omp_get_thread_num());
uniform_real_distribution<double> dist(0.,1.);
// Set up lattice structure
p = (char *) calloc(L*L, sizeof(char));
CHECK_ALLOC(p);
lattice = (char **) calloc(L, sizeof(char *));
CHECK_ALLOC(lattice);
for (int i = 0; i < L; i++)
lattice[i] = &p[i*L];
// Loop over temperature range
#pragma omp for
for (int i = 0; i < n; i++) {
// Initializing
T = T1 + i*dT;
init_metropolis(wij, T);
init_spins(L, entropy, lattice);
// Monte Carlo simulation
for (int c = 0; c < equilibration_cycles; c++) // thermalizing...
metropolis(L, lattice, wij, E, M, num_accepted, dist, rng);
E = energy(L, lattice);
M = magnetic_moment(L, lattice);
Eacc = E2acc = Macc = M2acc = Macc_abs = 0.;
for (int c = 0; c < cycles; c++) {
Eacc += E;
E2acc += E*E;
Macc += M;
M2acc += M*M;
Macc_abs += fabs(M);
metropolis(L, lattice, wij, E, M, num_accepted, dist, rng);
}
results(i,0) = T;
results(i,1) = sample_mean(Eacc, cycles+1, L);
results(i,2) = sample_var(E2acc, Eacc, cycles+1, L)/(T*T); // heat capacity CV
results(i,3) = sample_mean(Macc_abs, cycles+1, L);
results(i,4) = sample_var(M2acc, Macc_abs, cycles+1, L)/T; // susceptibiliy Chi
results(i,5) = sample_mean(Macc, cycles+1, L);
}
// Clean up
free(p);
free(lattice);
}
return results;
}
/* Runs Monte Carlo simulations over LxL lattice at temp. T for given number of cycles.
Returns result arma::mat */
mat equilibration(int L, double entropy, double T, int cycles, int equilibration_cycles) {
mat results;
int n, k, mod, num_accepted;
double E, M;
double Eacc, E2acc, Macc, M2acc, Macc_abs;
char *p, **lattice;
double wij[17];
mt19937_64 rng(RNG_SEED);
uniform_real_distribution<double> dist(0.,1.);
// Setting up results matrix
if (cycles+equilibration_cycles < MAX_SAMPLES) {
n = cycles + equilibration_cycles;
mod = 1;
}
else {
n = MAX_SAMPLES;
mod = (cycles+equilibration_cycles)/MAX_SAMPLES;
if ((cycles+equilibration_cycles) % MAX_SAMPLES)
mod++;
}
results = mat(n, 8); // c, E, CV, Mabs, Chi, M, acc, Eraw
results.zeros();
// Set up lattice structure
p = (char *) calloc(L*L, sizeof(char));
CHECK_ALLOC(p);
lattice = (char **) calloc(L, sizeof(char *));
CHECK_ALLOC(lattice);
for (int i = 0; i < L; i++)
lattice[i] = &p[i*L];
// Initializing
init_metropolis(wij, T);
init_spins(L, entropy, lattice);
E = energy(L, lattice);
M = magnetic_moment(L, lattice);
// Monte Carlo simulation
k = 0;
for (int c = 0; c < equilibration_cycles; c++) { // thermalizing...
if (c % mod == 0) {
results(k,0) = c;
results(k,6) = num_accepted;
results(k,7) = E/(L*L);
k++;
}
metropolis(L, lattice, wij, E, M, num_accepted, dist, rng);
}
Eacc = E2acc = Macc = M2acc = Macc_abs = 0.;
for (int c = 0; c < cycles; c++) {
Eacc += E;
E2acc += E*E;
Macc += M;
M2acc += M*M;
Macc_abs += fabs(M);
if ((c+equilibration_cycles) % mod == 0) {
results(k,0) = c + equilibration_cycles;
results(k,1) = sample_mean(Eacc, c+1, L);
results(k,2) = sample_var(E2acc, Eacc, c+1, L)/(T*T);
results(k,3) = sample_mean(Macc_abs, c+1, L);
results(k,4) = sample_var(M2acc, Macc_abs, c+1, L)/T;
results(k,5) = sample_mean(Macc, c+1, L);
results(k,6) = num_accepted;
results(k,7) = E/(L*L);
k++;
}
num_accepted = 0;
metropolis(L, lattice, wij, E, M, num_accepted, dist, rng);
}
// Clean up
free(p);
free(lattice);
return results;
}
/* Estimation of the probability distribution at temperature T.
Returns result arma::mat with bins. Simulation runs for equilibration_cycles before
logging of results begins. Total runs = equilibration_cycles + cycles. */
mat probability_distribution(int L, double entropy, double T,
int cycles, int equilibration_cycles, int bins, double &Evar) {
mat results;
int num_accepted, idx;
double E, M;
double Eacc, E2acc;
double Emin = -2., Emax = 2.;
double dE;
char *p, **lattice;
double wij[17];
mt19937_64 rng(RNG_SEED);
uniform_real_distribution<double> dist(0.,1.);
// Setting up results matrix
results = mat(bins, 3); // bins in the normalized energy range [-2,2]
results.zeros();
dE = (Emax - Emin)/bins; // step in the normalized energy range [-2,2]
for (idx = 0; idx < bins; idx++)
results(idx, 0) = Emin + idx*dE;
// Set up lattice structure
p = (char *) calloc(L*L, sizeof(char));
CHECK_ALLOC(p);
lattice = (char **) calloc(L, sizeof(char *));
CHECK_ALLOC(lattice);
for (int i = 0; i < L; i++)
lattice[i] = &p[i*L];
// Initializing
init_metropolis(wij, T);
init_spins(L, entropy, lattice);
// Monte Carlo simulation
for (int c = 0; c < equilibration_cycles; c++)
metropolis(L, lattice, wij, E, M, num_accepted, dist, rng); // thermalizing...
E = energy(L, lattice);
Eacc = E2acc = 0.;
for (int c = 0; c < cycles; c++) {
Eacc += E;
E2acc += E*E;
idx = (int) ((E/(L*L) - Emin)/dE);
if (idx >= bins)
idx = bins - 1;
results(idx,1) += 1;
results(idx,2) += 1./cycles;
metropolis(L, lattice, wij, E, M, num_accepted, dist, rng);
}
// Clean up
free(p);
free(lattice);
Evar = sample_var(E2acc, Eacc, cycles+1, L);
return results;
}
/* Returns result arma::mat with lattice at end of simulation. */
mat get_lattice(int L, double entropy, double T, int cycles) {
mat results;
int num_accepted;
double E, M;
char *p, **lattice;
double wij[17];
mt19937_64 rng(RNG_SEED);
uniform_real_distribution<double> dist(0.,1.);
// Setting up results matrix
results = mat(L, L);
// Set up lattice structure
p = (char *) calloc(L*L, sizeof(char));
CHECK_ALLOC(p);
lattice = (char **) calloc(L, sizeof(char *));
CHECK_ALLOC(lattice);
for (int i = 0; i < L; i++)
lattice[i] = &p[i*L];
// Initializing
init_metropolis(wij, T);
init_spins(L, entropy, lattice);
// Monte Carlo simulation
for (int c = 0; c < cycles; c++)
metropolis(L, lattice, wij, E, M, num_accepted, dist, rng);
for (int i = 0; i < L; i++)
for (int j = 0; j < L; j++)
results(i,j) = lattice[i][j];
// Clean up
free(p);
free(lattice);
return results;
}
| [
"olav.fonstelien@gmail.com"
] | olav.fonstelien@gmail.com |
7925faf929250772a0ef8390d00b5f46f2f59ee8 | 372ed1ff376208447c8eaa32294e939cb88cf6af | /cpp01/ex06/main.cpp | 887f8a7c9fc729a4cfdef2878af10f47fb7c7f66 | [] | no_license | IamLena/s21_cpp | 0b78ab9d76a2417d688a7af0f9e6777108fefb02 | 8d771e350f604c75d2e0013e49fbfe1b26ec8b8c | refs/heads/master | 2023-02-27T08:31:04.233744 | 2021-02-08T01:15:41 | 2021-02-08T01:15:41 | 329,557,012 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,318 | cpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nalecto <nalecto@student.21-school.ru> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/15 16:36:37 by ncolomer #+# #+# */
/* Updated: 2021/01/26 01:07:44 by nalecto ### ########.fr */
/* */
/* ************************************************************************** */
#include <iostream>
#include "Weapon.hpp"
#include "HumanA.hpp"
#include "HumanB.hpp"
int main()
{
{
Weapon club = Weapon("crude spiked club");
HumanA bob("Bob", club);
bob.attack();
club.setType("some other type of club");
bob.attack();
}
{
Weapon club = Weapon("crude spiked club");
HumanB jim("Jim");
jim.setWeapon(club);
jim.attack();
club.setType("some other type of club");
jim.attack();
}
}
| [
"helly.luchina@gmail.com"
] | helly.luchina@gmail.com |
3c8029bd1065a0b03a54c41d3e72b9b1697d70cd | df81135b7711691086abe2832bc97377d905c8e9 | /2016.02.21 PathMove/DirectX3D_Framework_1.4/cTransform.cpp | 1fc9bd7111407fe27ac86176fce340b9f23f7fb0 | [] | no_license | kwansu/3DEngineProgramming_Practice | b52b806e569cec4457701308dd2390ce2670b537 | 26d43c251b7e9f810784dffb19ff0bfd19419d49 | refs/heads/master | 2023-04-21T16:54:10.951063 | 2021-05-17T06:32:15 | 2021-05-17T06:32:15 | 368,079,698 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,849 | cpp | #include "stdafx.h"
#include "cTransform.h"
cTransform::cTransform()
: m_vPos(0, 0, 0)
, m_vDir(0, 0, 1)
, m_vRot(0, 0, 0)
{
D3DXMatrixIdentity(&m_matWorld);
m_matR = m_matT = m_matS = m_matWorld;
}
cTransform::~cTransform()
{
}
void cTransform::SetPosition(const D3DXVECTOR3 * pvPos)
{
m_vPos = *pvPos;
}
void cTransform::SetDirection(const D3DXVECTOR3 * pvDir)
{
m_vDir = *pvDir;
}
void cTransform::SetPosition(float px, float py, float pz)
{
m_vPos = D3DXVECTOR3(px, py, pz);
}
void cTransform::SetRotation(float rx, float ry, float rz)
{
m_vRot.x = rx; m_vRot.y = ry; m_vRot.z = rz;
}
void cTransform::SetScale(float sx, float sy, float sz)
{
D3DXMatrixScaling(&m_matS, sx, sy, sz);
}
void cTransform::SetWorldMatirx(const D3DXMATRIXA16 * pmatWorld)
{
m_matWorld = *pmatWorld;
}
void cTransform::SetWorldMatirxFromParent(const D3DXMATRIXA16 * pmatWorld)
{
m_matWorld *= *pmatWorld;
}
void cTransform::UpdateTranslation()
{
m_matT._41 = m_vPos.x;
m_matT._42 = m_vPos.y;
m_matT._43 = m_vPos.z;
}
void cTransform::UpdateRotation()
{
D3DXMATRIXA16 matY, matZ;
D3DXMatrixRotationX(&m_matR, D3DXToRadian(m_vRot.x));
D3DXMatrixRotationY(&matY, D3DXToRadian(m_vRot.y));
D3DXMatrixRotationZ(&matZ, D3DXToRadian(m_vRot.z));
m_matR *= matY * matZ;
}
void cTransform::UpdateDirection()
{
D3DXVec3TransformNormal(&m_vDir, &D3DXVECTOR3(0, 0, 1), &m_matR);
}
void cTransform::UpdateWorld()
{
m_matWorld = m_matS * m_matR * m_matT;
}
void cTransform::UpdateTransform()
{
UpdateTranslation();
UpdateRotation();
UpdateWorld();
}
void cTransform::TransformPosition(OUT D3DXVECTOR3 * pvOut)
{
D3DXVec3TransformCoord(pvOut, pvOut, &m_matWorld);
}
void cTransform::TransformVector(OUT D3DXVECTOR3 * pvOut)
{
D3DXVec3TransformNormal(pvOut, pvOut, &m_matWorld);
}
D3DXVECTOR3 cTransform::GetPosition()
{
return m_vPos;
}
| [
"kwansu91@naver.com"
] | kwansu91@naver.com |
e1593408b635e887e4fcd770252e21366ebb7daf | 2fd1af12b6fb4e80e3a4f7abe6cb5a7678da1197 | /SW_Expert_Academy/S:W_문제해결_기본/1228.cpp | 030fec2588b68b6e2805de8a71077bc075b238d7 | [] | no_license | KangSeungIl/Algorithm | 7d9db15051241e55548fb08e04d2bfa89dee9604 | 8ea4a38f539f219796390094e2d7db15923dacdf | refs/heads/master | 2020-04-09T02:37:59.715922 | 2019-01-06T05:01:08 | 2019-01-06T05:01:08 | 159,948,293 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,406 | cpp | #include <iostream> // 1228 암호문1
#include <vector>
using namespace std;
int main() {
int T = 10;
for(int testCase=1; testCase <=T; testCase++) {
int N;
cin >> N;
vector <int> result(10);
for(int i=0; i<N; i++) {
int temp;
cin >> temp;
if(i<10)
result[i] = temp;
}
cin >> N;
for(int i=0; i<N; i++) {
char command;
cin >> command;
int x, y;
cin >> x >> y;
if(x < 10) {
if(x+y-1 > 9) {
for(int j=x; j<10; j++)
cin >> result[j];
for(int j=10; j<x+y; j++) {
int temp;
cin >> temp;
}
}
else {
for(int j=9-y; j>=x; j--)
result[j+y] = result[j];
for(int j=x; j<x+y; j++)
cin >> result[j];
}
}
else {
for(int j=0; j<y; j++) {
int temp;
cin >> temp;
}
}
}
cout << "#" << testCase << " ";
for(int i=0; i<10; i++)
cout << result[i] << " ";
cout << endl;
}
return 0;
}
| [
"tmddlf51@naver.com"
] | tmddlf51@naver.com |
8bd9e77165ec1f9e0b324a7b4a16f68c88b38df9 | 1e965ef0826daecc28b69863168e152a7a3b1125 | /source/core/include/Material.h | 2d92ef58abc75798f6c058a26d2dac4abe63ffd1 | [
"Unlicense"
] | permissive | Betaoptics/Graphical-Programming | 419ee3593d16bcd7ca875a27f9310f5021fe9e5f | 1aa9d149aa8d7b2fecd0cdcd1329ed3ef970bc1e | refs/heads/main | 2023-05-09T14:01:35.664521 | 2021-05-28T09:52:19 | 2021-05-28T09:52:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 640 | h | /**
* ============================================================================
* Name : Material.h
* Part of : Simple OpenGL graphics engine framework
* Description : simple material
* Version : 1.00
* Author : Jani Immonen, <realdashdev@gmail.com>
* ============================================================================
**/
#pragma once
#include "../include/OpenGLRenderer.h"
class Material
{
public:
Material();
~Material();
void SetToProgram(GLuint uProgram);
glm::vec4 m_cAmbient;
glm::vec4 m_cDiffuse;
glm::vec4 m_cSpecular;
glm::vec4 m_cEmissive;
float m_fSpecularPower;
};
| [
"M3268@student.jamk.fi"
] | M3268@student.jamk.fi |
386260c520788d9ee390aa9a11223c4a79f44945 | e713cebc4b89883ad9d63221e47511772ed71bf8 | /Life/World.h | a0dd9385941acb54089fc789ed2aca4040cf02ce | [] | no_license | aportner/life | 84f96c27d77fab185a53219bc58cff7e80d61031 | 2d3b12cebf62edaac6d1eade73c2d48cbca90284 | refs/heads/master | 2020-06-29T11:17:19.642955 | 2016-08-23T03:54:29 | 2016-08-23T03:54:29 | 66,331,370 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 963 | h | #ifndef World_h
#define World_h
#include "CellTree.h"
/*
* The World class adds logic to traverse the CellTree to add/remove cells.
* This allows you to navigate 64-bit x/y coordinates by partitioning them
* via a tree (in this case a quad tree).
*/
class World {
public:
World() {}
// add a cell
CellTree* addCell( int64_t x, int64_t y, bool alive = true );
// remove a cell
CellTree* getCell( int64_t x, int64_t y );
// get the root of the world tree
CellTree* getTree();
private:
// recursive algorithm for adding
CellTree* mAddCell( CellTree *cell, int64_t x, int64_t y, int steps, bool alive = true );
// recursive algorithm for removing
CellTree* mGetCell( CellTree *cell, int64_t x, int64_t y, int steps );
// function to hash a x/y coord into tree space (in quad tree gives you 0-3)
int getBits( int64_t x, int64_t y, int steps );
// root tree
CellTree mTree;
};
#endif | [
"aportner@gmail.com"
] | aportner@gmail.com |
da995e742c89cbe952d3c93fc1b45be5f8c7a221 | 135310f251c8a074c7bfe662d06ed37826afa7b4 | /include/litehtml/box.h | d5635f4416411c23ea6579d902d6a0a15bac20e9 | [
"BSD-3-Clause"
] | permissive | axle-h/SdlPanelUi | 829acf5158a63d1b2663e8dfb7eb5b989113a771 | e0be2d30d7a38923504e16d1ee5d9fb90c9e11b1 | refs/heads/master | 2020-04-04T01:01:07.748180 | 2015-04-17T15:23:46 | 2015-04-17T15:23:46 | 31,613,484 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,203 | h | #pragma once
#include "object.h"
namespace litehtml
{
class html_tag;
enum box_type
{
box_block,
box_line
};
class box : public object
{
public:
typedef litehtml::object_ptr<litehtml::box> ptr;
typedef std::vector< litehtml::object_ptr<litehtml::box> > vector;
protected:
int m_box_top;
int m_box_left;
int m_box_right;
public:
box(int top, int left, int right)
{
m_box_top = top;
m_box_left = left;
m_box_right = right;
}
int bottom() { return m_box_top + height(); }
int top() { return m_box_top; }
int right() { return m_box_left + width(); }
int left() { return m_box_left; }
virtual litehtml::box_type get_type() = 0;
virtual int height() = 0;
virtual int width() = 0;
virtual void add_element(element* el) = 0;
virtual bool can_hold(element* el, white_space ws) = 0;
virtual void finish(bool last_box = false) = 0;
virtual bool is_empty() = 0;
virtual int baseline() = 0;
virtual void get_elements(elements_vector& els) = 0;
virtual int top_margin() = 0;
virtual int bottom_margin() = 0;
virtual void y_shift(int shift) = 0;
virtual void new_width(int left, int right, elements_vector& els) = 0;
};
//////////////////////////////////////////////////////////////////////////
class block_box : public box
{
element* m_element;
public:
block_box(int top, int left, int right) : box(top, left, right)
{
m_element = 0;
}
virtual litehtml::box_type get_type();
virtual int height();
virtual int width();
virtual void add_element(element* el);
virtual bool can_hold(element* el, white_space ws);
virtual void finish(bool last_box = false);
virtual bool is_empty();
virtual int baseline();
virtual void get_elements(elements_vector& els);
virtual int top_margin();
virtual int bottom_margin();
virtual void y_shift(int shift);
virtual void new_width(int left, int right, elements_vector& els);
};
//////////////////////////////////////////////////////////////////////////
class line_box : public box
{
std::vector<element*> m_items;
int m_height;
int m_width;
int m_line_height;
font_metrics m_font_metrics;
int m_baseline;
text_align m_text_align;
public:
line_box(int top, int left, int right, int line_height, font_metrics& fm, text_align align) : box(top, left, right)
{
m_height = 0;
m_width = 0;
m_font_metrics = fm;
m_line_height = line_height;
m_baseline = 0;
m_text_align = align;
}
virtual litehtml::box_type get_type();
virtual int height();
virtual int width();
virtual void add_element(element* el);
virtual bool can_hold(element* el, white_space ws);
virtual void finish(bool last_box = false);
virtual bool is_empty();
virtual int baseline();
virtual void get_elements(elements_vector& els);
virtual int top_margin();
virtual int bottom_margin();
virtual void y_shift(int shift);
virtual void new_width(int left, int right, elements_vector& els);
private:
element* get_last_space();
bool is_break_only();
};
} | [
"alex.haslehurst@gmail.com"
] | alex.haslehurst@gmail.com |
dce216f585d034a6f5ba336573c3d470ae829a7f | 19957b4fde7487ac9e9135f3321a71c2585c56d0 | /ecoin/src/init.h | e1d2c6bd28a29069482d5ec0a0582774909166b7 | [
"MIT"
] | permissive | pinklite34/ecoin | 335cd39587709aa5304cc766653a3e267a9dae70 | 3bf39f0d8ede043bbf7230fbbded5d9c6c22a08d | refs/heads/master | 2021-03-21T19:19:52.137093 | 2020-03-14T17:40:04 | 2020-03-14T17:40:04 | 247,323,557 | 0 | 0 | null | 2020-03-14T17:37:30 | 2020-03-14T17:37:29 | null | UTF-8 | C++ | false | false | 494 | h | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin, Novacoin, and Ecoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_INIT_H
#define BITCOIN_INIT_H
#include "wallet.h"
extern CWallet* pwalletMain;
extern std::string strWalletFileName;
void StartShutdown();
void Shutdown(void* parg);
bool AppInit2();
std::string HelpMessage();
#endif
| [
"epsylon@riseup.net"
] | epsylon@riseup.net |
61882473183e149ecf8ff7236cb3749bdd05c321 | 073f9a3b6e9defde09bdb453d7c79a2169c4a31b | /tlb.cc | f998b302b4a6114c1fde5fd7db3e32171a00d134 | [] | no_license | kenrick95/code-archive | 9dc1c802f6d733ad10324ed217bacd3d4b2c455f | 72c420353e3aa7b18af6970b6a81f710c4f5d1b0 | refs/heads/master | 2021-03-24T12:47:52.016103 | 2018-07-08T13:22:46 | 2018-07-08T13:22:46 | 69,313,404 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,269 | cc | #include "copyright.h"
#include "tlb.h"
#include "syscall.h"
#include "machine.h"
#include "thread.h"
#include "system.h"
#include "utility.h"
//----------------------------------------------------------------------
// UpdateTLB
// Called when exception is raised and a page isn't in the TLB.
// Figures out what to do (get from IPT, or pageoutpagein) and does it.
//----------------------------------------------------------------------
void UpdateTLB(int possible_badVAddr)
{
int badVAddr;
unsigned int vpn;
int phyPage;
if(possible_badVAddr) // get the bad address from the correct location
badVAddr = possible_badVAddr; // fault in kernel
else
badVAddr = machine->registers[BadVAddrReg]; // fault in userprog
vpn = (unsigned) badVAddr/PageSize;
if((phyPage=VpnToPhyPage(vpn))!=-1)
InsertToTLB(vpn, phyPage);
else {
if(vpn>=currentThread->space->numPages && !GetMmap(vpn))
machine->RaiseException(AddressErrorException, badVAddr);
else
InsertToTLB(vpn, PageOutPageIn(vpn));
}
}
//----------------------------------------------------------------------
// VpnToPhyPage
// Gets a phyPage for a vpn, if exists in ipt.
//----------------------------------------------------------------------
int VpnToPhyPage(int vpn)
{
//your code here to get a physical frame for page vpn
//you can refer to PageOutPageIn(int vpn) to see how an entry was created in ipt
IptEntry *iptPtr;
iptPtr = hashIPT(vpn, currentThread->pid);
// skip the head pointer
iptPtr = iptPtr->next;
// traverse in a linked list
while (iptPtr != NULL) {
if (iptPtr->vPage == vpn && iptPtr->pid == currentThread->pid) {
return iptPtr->phyPage;
}
iptPtr = iptPtr->next;
}
return -1;
};
//----------------------------------------------------------------------
// InsertToTLB
// Put a vpn/phyPage combination into the TLB. If TLB is full, use FIFO
// replacement
//----------------------------------------------------------------------
void InsertToTLB(int vpn, int phyPage)
{
int i = 0; //entry in the TLB
//your code to find an empty in TLB or to replace the oldest entry if TLB is full
static int FIFOPointer = 0;
// loop through TLB
while (i < TLBSize && machine->tlb[i].valid) {
i++;
}
// if no invalid entry, use oldest entry
if (i == TLBSize) i = FIFOPointer;
// update FIFO Pointer
FIFOPointer = (i + 1) % TLBSize;
// copy dirty data to memoryTable
if(machine->tlb[i].valid){
memoryTable[machine->tlb[i].physicalPage].dirty=machine->tlb[i].dirty;
memoryTable[machine->tlb[i].physicalPage].TLBentry=-1;
}
//update the TLB entry
machine->tlb[i].virtualPage = vpn;
machine->tlb[i].physicalPage = phyPage;
machine->tlb[i].valid = TRUE;
machine->tlb[i].readOnly = FALSE;
machine->tlb[i].use = FALSE;
machine->tlb[i].dirty = memoryTable[phyPage].dirty;
//update the corresponding memoryTable
memoryTable[phyPage].TLBentry=i;
DEBUG('p', "The corresponding TLBentry for Page %i in TLB is %i ", vpn, i);
//reset clockCounter to 0 since it is being used at this moment.
//for the implementation of Clock algorithm.
memoryTable[phyPage].clockCounter=0;
}
//----------------------------------------------------------------------
// PageOutPageIn
// Calls DoPageOut and DoPageIn and handles IPT and memoryTable
// bookkeeping. Use clock algorithm to find the replacement page.
//----------------------------------------------------------------------
int PageOutPageIn(int vpn)
{
int phyPage;
IptEntry *iptPtr;
//increase the number of page faults
stats->numPageFaults++;
//call the clock algorithm, which returns the freed physical frame
phyPage=clockAlgorithm();
//Page out the victim page to free the physical frame
DoPageOut(phyPage);
//Page in the new page to the freed physical frame
DoPageIn(vpn, phyPage);
//make an entry in ipt
iptPtr=hashIPT(vpn, currentThread->pid);
while(iptPtr->next) iptPtr=iptPtr->next;
iptPtr->next=new IptEntry(vpn, phyPage, iptPtr);
iptPtr=iptPtr->next;
//update memoryTable for this frame
memoryTable[phyPage].valid=TRUE;
memoryTable[phyPage].pid=currentThread->pid;
memoryTable[phyPage].vPage=vpn;
memoryTable[phyPage].corrIptPtr=iptPtr;
memoryTable[phyPage].dirty=FALSE;
memoryTable[phyPage].TLBentry=-1;
memoryTable[phyPage].clockCounter=0;
memoryTable[phyPage].swapPtr=currentThread->space->swapPtr;
return phyPage;
}
//----------------------------------------------------------------------
// DoPageOut
// Actually pages out a phyPage to it's swapfile.
//----------------------------------------------------------------------
void DoPageOut(int phyPage)
{
MmapEntry *mmapPtr;
int numBytesWritten;
int mmapBytesToWrite;
if(memoryTable[phyPage].valid){ // check if pageOut possible
if(memoryTable[phyPage].TLBentry!=-1){
memoryTable[phyPage].dirty=
machine->tlb[memoryTable[phyPage].TLBentry].dirty;
machine->tlb[memoryTable[phyPage].TLBentry].valid=FALSE;
}
if(memoryTable[phyPage].dirty){ // pageOut is necessary
if((mmapPtr=GetMmap(memoryTable[phyPage].vPage))){ // it's mmaped
DEBUG('p', "mmap paging out: pid %i, phyPage %i, vpn %i\n",
memoryTable[phyPage].pid, phyPage, memoryTable[phyPage].vPage);
if(memoryTable[phyPage].vPage==mmapPtr->endPage)
mmapBytesToWrite=mmapPtr->lastPageLength;
else
mmapBytesToWrite=PageSize;
numBytesWritten=mmapPtr->openFile->
WriteAt(machine->mainMemory+phyPage*PageSize, mmapBytesToWrite,
(memoryTable[phyPage].vPage-mmapPtr->beginPage)*PageSize);
ASSERT(mmapBytesToWrite==numBytesWritten);
} else { // it's not mmaped
DEBUG('p', "paging out: pid %i, phyPage %i, vpn %i\n",
memoryTable[phyPage].pid, phyPage, memoryTable[phyPage].vPage);
numBytesWritten=memoryTable[phyPage].swapPtr->
WriteAt(machine->mainMemory+phyPage*PageSize, PageSize,
memoryTable[phyPage].vPage*PageSize);
ASSERT(PageSize==numBytesWritten);
}
}
delete memoryTable[phyPage].corrIptPtr;
memoryTable[phyPage].valid=FALSE;
}
}
//----------------------------------------------------------------------
// DoPageIn
// Actually pages in a phyPage/vpn combo from the swapfile.
//----------------------------------------------------------------------
void DoPageIn(int vpn, int phyPage)
{
MmapEntry *mmapPtr;
int numBytesRead;
int mmapBytesToRead;
if((mmapPtr=GetMmap(vpn))){ // mmaped file
DEBUG('p', "mmap paging in: pid %i, phyPage %i, vpn %i\n",
currentThread->pid, phyPage, vpn);
if(vpn==mmapPtr->endPage)
mmapBytesToRead=mmapPtr->lastPageLength;
else
mmapBytesToRead=PageSize;
numBytesRead=
mmapPtr->openFile->ReadAt(machine->mainMemory+phyPage*PageSize,
mmapBytesToRead,
(vpn-mmapPtr->beginPage)*PageSize);
ASSERT(numBytesRead==mmapBytesToRead);
} else { // not mmaped
DEBUG('p', "paging in: pid %i, phyPage %i, vpn %i\n", currentThread->pid,
phyPage, vpn);
numBytesRead=currentThread->space->swapPtr->ReadAt(machine->mainMemory+
phyPage*PageSize,
PageSize,
vpn*PageSize);
ASSERT(PageSize==numBytesRead);
}
}
//----------------------------------------------------------------------
// clockAlgorithm
// Determine where a vpn should go in phymem, and therefore what
// should be paged out. This clock algorithm is a variant of the one
// discussed in the lectures.
//----------------------------------------------------------------------
int clockAlgorithm(void)
{
int phyPage;
//your code here to find the physical frame that should be freed
//according to the clock algorithm.
static int clockPointer = 0;
phyPage = -1;
while (phyPage < 0)
{
if ((memoryTable[clockPointer].valid == false)
// is invalid
|| (!memoryTable[clockPointer].dirty
&& memoryTable[clockPointer].clockCounter == OLD_ENOUGH)
// is not dirty and old enough
|| (memoryTable[clockPointer].dirty
&& memoryTable[clockPointer].clockCounter == OLD_ENOUGH + DIRTY_ALLOWANCE))
// is dirty, old enough, and already got a second chance
{
phyPage = clockPointer; //got it!
} else {
memoryTable[clockPointer].clockCounter++; //increase the clockCounter, to ensure that eventually one page will be old enough
}
clockPointer = (clockPointer + 1) % NumPhysPages;
}
return phyPage;
}
//----------------------------------------------------------------------
// GetMmap
// Return an MmapEntry structure corresponding to the vpn. Returns
// 0 if does not exist.
//----------------------------------------------------------------------
MmapEntry *GetMmap(int vpn)
{
MmapEntry *mmapPtr;
mmapPtr=currentThread->space->mmapEntries;
while(mmapPtr->next){
mmapPtr=mmapPtr->next;
if(vpn>=mmapPtr->beginPage && vpn<=mmapPtr->endPage)
return mmapPtr;
}
return 0;
}
//----------------------------------------------------------------------
// PageOutMmapSpace
// Pages out stuff being mmaped (or just between beginPage and
// endPage.
//----------------------------------------------------------------------
void PageOutMmapSpace(int beginPage, int endPage)
{
int vpn;
int phyPage;
for(vpn=beginPage; vpn<=endPage; vpn++){
if((phyPage=VpnToPhyPage(vpn))==-1)
continue;
DoPageOut(phyPage);
}
}
| [
"kenrick95@gmail.com"
] | kenrick95@gmail.com |
5b408e9aed0e7b2a59d4dad0d5ecc3465a0d0e36 | fdc1089c220773339b04d05c4f190f1fb4fb57b2 | /day-3/greatest-common-divisor.cpp | 61548041186cb37d95f8975f142baade2795749e | [] | no_license | suraj-kumbhar/30-days-job-challenge | b7847df6735327305c08cce85589625b2bdc2e99 | d4c98390c8db00bff4547005ccc543eaef5bf2e0 | refs/heads/master | 2022-11-22T07:03:23.533494 | 2020-07-20T06:32:45 | 2020-07-20T06:32:45 | 273,182,691 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 518 | cpp | // Greatest Common Divisor
// Given 2 non negative integers m and n, find gcd(m, n)
// GCD of 2 integers m and n is defined as the greatest integer g such that g is a divisor of both m and n.
// Both m and n fit in a 32 bit signed integer.
// Example
// m : 6
// n : 9
// GCD(m, n) : 3
// https://www.interviewbit.com/problems/greatest-common-divisor/
int Solution::gcd(int A, int B) {
if(A==0)
return B;
else {
// A=max(A,B);
// B=min(A,B);
return gcd(B%A,A);
}
}
| [
"surajkannankumbhar@gmail.com"
] | surajkannankumbhar@gmail.com |
b51120c003141984a5298c09eca75f13e83c2139 | 5d1c178763908decbcd2d63481e3b240e4ab3763 | /src/iiwa_stack/iiwa_description/urdf/ikfast71_iiwa7.cpp | e4827be3072b6e792e28ac0e557e4000dd7df9d6 | [
"BSD-2-Clause"
] | permissive | ichbindunst/ros3djs_tutorial | 0f27127e00574411babc8127db5f57c542045db8 | f840e93445ffbc7228956ce5db1fbe706224dc59 | refs/heads/master | 2023-03-31T19:51:29.409983 | 2021-04-01T17:54:43 | 2021-04-01T17:54:43 | 353,783,567 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 560,914 | cpp | /// autogenerated analytical inverse kinematics code from ikfast program part of OpenRAVE
/// \author Rosen Diankov
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// ikfast version 0x10000049 generated on 2020-08-14 13:48:17.812593
/// To compile with gcc:
/// gcc -lstdc++ ik.cpp
/// To compile without any main function as a shared object (might need -llapack):
/// gcc -fPIC -lstdc++ -DIKFAST_NO_MAIN -DIKFAST_CLIBRARY -shared -Wl,-soname,libik.so -o libik.so ik.cpp
#define IKFAST_HAS_LIBRARY
#include "ikfast.h" // found inside share/openrave-X.Y/python/ikfast.h
using namespace ikfast;
// check if the included ikfast version matches what this file was compiled with
#define IKFAST_COMPILE_ASSERT(x) extern int __dummy[(int)x]
IKFAST_COMPILE_ASSERT(IKFAST_VERSION==0x10000049);
#include <cmath>
#include <vector>
#include <limits>
#include <algorithm>
#include <complex>
#ifndef IKFAST_ASSERT
#include <stdexcept>
#include <sstream>
#include <iostream>
#ifdef _MSC_VER
#ifndef __PRETTY_FUNCTION__
#define __PRETTY_FUNCTION__ __FUNCDNAME__
#endif
#endif
#ifndef __PRETTY_FUNCTION__
#define __PRETTY_FUNCTION__ __func__
#endif
#define IKFAST_ASSERT(b) { if( !(b) ) { std::stringstream ss; ss << "ikfast exception: " << __FILE__ << ":" << __LINE__ << ": " <<__PRETTY_FUNCTION__ << ": Assertion '" << #b << "' failed"; throw std::runtime_error(ss.str()); } }
#endif
#if defined(_MSC_VER)
#define IKFAST_ALIGNED16(x) __declspec(align(16)) x
#else
#define IKFAST_ALIGNED16(x) x __attribute((aligned(16)))
#endif
#define IK2PI ((IkReal)6.28318530717959)
#define IKPI ((IkReal)3.14159265358979)
#define IKPI_2 ((IkReal)1.57079632679490)
#ifdef _MSC_VER
#ifndef isnan
#define isnan _isnan
#endif
#ifndef isinf
#define isinf _isinf
#endif
//#ifndef isfinite
//#define isfinite _isfinite
//#endif
#endif // _MSC_VER
// lapack routines
extern "C" {
void dgetrf_ (const int* m, const int* n, double* a, const int* lda, int* ipiv, int* info);
void zgetrf_ (const int* m, const int* n, std::complex<double>* a, const int* lda, int* ipiv, int* info);
void dgetri_(const int* n, const double* a, const int* lda, int* ipiv, double* work, const int* lwork, int* info);
void dgesv_ (const int* n, const int* nrhs, double* a, const int* lda, int* ipiv, double* b, const int* ldb, int* info);
void dgetrs_(const char *trans, const int *n, const int *nrhs, double *a, const int *lda, int *ipiv, double *b, const int *ldb, int *info);
void dgeev_(const char *jobvl, const char *jobvr, const int *n, double *a, const int *lda, double *wr, double *wi,double *vl, const int *ldvl, double *vr, const int *ldvr, double *work, const int *lwork, int *info);
}
using namespace std; // necessary to get std math routines
#ifdef IKFAST_NAMESPACE
namespace IKFAST_NAMESPACE {
#endif
inline float IKabs(float f) { return fabsf(f); }
inline double IKabs(double f) { return fabs(f); }
inline float IKsqr(float f) { return f*f; }
inline double IKsqr(double f) { return f*f; }
inline float IKlog(float f) { return logf(f); }
inline double IKlog(double f) { return log(f); }
// allows asin and acos to exceed 1. has to be smaller than thresholds used for branch conds and evaluation
#ifndef IKFAST_SINCOS_THRESH
#define IKFAST_SINCOS_THRESH ((IkReal)1e-7)
#endif
// used to check input to atan2 for degenerate cases. has to be smaller than thresholds used for branch conds and evaluation
#ifndef IKFAST_ATAN2_MAGTHRESH
#define IKFAST_ATAN2_MAGTHRESH ((IkReal)1e-7)
#endif
// minimum distance of separate solutions
#ifndef IKFAST_SOLUTION_THRESH
#define IKFAST_SOLUTION_THRESH ((IkReal)1e-6)
#endif
// there are checkpoints in ikfast that are evaluated to make sure they are 0. This threshold speicfies by how much they can deviate
#ifndef IKFAST_EVALCOND_THRESH
#define IKFAST_EVALCOND_THRESH ((IkReal)0.00001)
#endif
inline float IKasin(float f)
{
IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
if( f <= -1 ) return float(-IKPI_2);
else if( f >= 1 ) return float(IKPI_2);
return asinf(f);
}
inline double IKasin(double f)
{
IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
if( f <= -1 ) return -IKPI_2;
else if( f >= 1 ) return IKPI_2;
return asin(f);
}
// return positive value in [0,y)
inline float IKfmod(float x, float y)
{
while(x < 0) {
x += y;
}
return fmodf(x,y);
}
// return positive value in [0,y)
inline double IKfmod(double x, double y)
{
while(x < 0) {
x += y;
}
return fmod(x,y);
}
inline float IKacos(float f)
{
IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
if( f <= -1 ) return float(IKPI);
else if( f >= 1 ) return float(0);
return acosf(f);
}
inline double IKacos(double f)
{
IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
if( f <= -1 ) return IKPI;
else if( f >= 1 ) return 0;
return acos(f);
}
inline float IKsin(float f) { return sinf(f); }
inline double IKsin(double f) { return sin(f); }
inline float IKcos(float f) { return cosf(f); }
inline double IKcos(double f) { return cos(f); }
inline float IKtan(float f) { return tanf(f); }
inline double IKtan(double f) { return tan(f); }
inline float IKsqrt(float f) { if( f <= 0.0f ) return 0.0f; return sqrtf(f); }
inline double IKsqrt(double f) { if( f <= 0.0 ) return 0.0; return sqrt(f); }
inline float IKatan2Simple(float fy, float fx) {
return atan2f(fy,fx);
}
inline float IKatan2(float fy, float fx) {
if( isnan(fy) ) {
IKFAST_ASSERT(!isnan(fx)); // if both are nan, probably wrong value will be returned
return float(IKPI_2);
}
else if( isnan(fx) ) {
return 0;
}
return atan2f(fy,fx);
}
inline double IKatan2Simple(double fy, double fx) {
return atan2(fy,fx);
}
inline double IKatan2(double fy, double fx) {
if( isnan(fy) ) {
IKFAST_ASSERT(!isnan(fx)); // if both are nan, probably wrong value will be returned
return IKPI_2;
}
else if( isnan(fx) ) {
return 0;
}
return atan2(fy,fx);
}
template <typename T>
struct CheckValue
{
T value;
bool valid;
};
template <typename T>
inline CheckValue<T> IKatan2WithCheck(T fy, T fx, T epsilon)
{
CheckValue<T> ret;
ret.valid = false;
ret.value = 0;
if( !isnan(fy) && !isnan(fx) ) {
if( IKabs(fy) >= IKFAST_ATAN2_MAGTHRESH || IKabs(fx) > IKFAST_ATAN2_MAGTHRESH ) {
ret.value = IKatan2Simple(fy,fx);
ret.valid = true;
}
}
return ret;
}
inline float IKsign(float f) {
if( f > 0 ) {
return float(1);
}
else if( f < 0 ) {
return float(-1);
}
return 0;
}
inline double IKsign(double f) {
if( f > 0 ) {
return 1.0;
}
else if( f < 0 ) {
return -1.0;
}
return 0;
}
template <typename T>
inline CheckValue<T> IKPowWithIntegerCheck(T f, int n)
{
CheckValue<T> ret;
ret.valid = true;
if( n == 0 ) {
ret.value = 1.0;
return ret;
}
else if( n == 1 )
{
ret.value = f;
return ret;
}
else if( n < 0 )
{
if( f == 0 )
{
ret.valid = false;
ret.value = (T)1.0e30;
return ret;
}
if( n == -1 ) {
ret.value = T(1.0)/f;
return ret;
}
}
int num = n > 0 ? n : -n;
if( num == 2 ) {
ret.value = f*f;
}
else if( num == 3 ) {
ret.value = f*f*f;
}
else {
ret.value = 1.0;
while(num>0) {
if( num & 1 ) {
ret.value *= f;
}
num >>= 1;
f *= f;
}
}
if( n < 0 ) {
ret.value = T(1.0)/ret.value;
}
return ret;
}
/// solves the forward kinematics equations.
/// \param pfree is an array specifying the free joints of the chain.
IKFAST_API void ComputeFk(const IkReal* j, IkReal* eetrans, IkReal* eerot) {
IkReal x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19,x20,x21,x22,x23,x24,x25,x26,x27,x28,x29,x30,x31,x32,x33,x34,x35,x36,x37,x38,x39,x40,x41,x42,x43,x44,x45,x46,x47,x48,x49,x50,x51,x52,x53,x54,x55,x56,x57,x58,x59,x60,x61,x62,x63;
x0=IKcos(j[0]);
x1=IKcos(j[1]);
x2=IKcos(j[2]);
x3=IKsin(j[0]);
x4=IKsin(j[2]);
x5=IKcos(j[3]);
x6=IKsin(j[1]);
x7=IKsin(j[3]);
x8=IKcos(j[4]);
x9=IKsin(j[4]);
x10=IKcos(j[6]);
x11=IKsin(j[6]);
x12=IKsin(j[5]);
x13=IKcos(j[5]);
x14=((0.4)*x3);
x15=((1.0)*x5);
x16=((0.126)*x7);
x17=((1.0)*x8);
x18=((1.0)*x0);
x19=((1.0)*x3);
x20=((1.0)*x13);
x21=((0.4)*x1);
x22=((1.0)*x9);
x23=((0.4)*x0);
x24=((0.126)*x9);
x25=((0.126)*x8);
x26=(x5*x6);
x27=(x6*x7);
x28=(x0*x4);
x29=((-1.0)*x9);
x30=(x1*x7);
x31=(x1*x4);
x32=(x1*x2);
x33=((-1.0)*x8);
x34=(x1*x5);
x35=(x19*x4);
x36=(x4*x6*x9);
x37=(x15*x2*x6);
x38=(x22*x4*x6);
x39=((((-1.0)*x35))+((x0*x32)));
x40=(((x3*x32))+x28);
x41=(((x2*x27))+x34);
x42=((((-1.0)*x18*x32))+x35);
x43=(((x19*x31))+(((-1.0)*x18*x2)));
x44=((((-1.0)*x30))+x37);
x45=(((x19*x2))+((x18*x31)));
x46=((((-1.0)*x18*x4))+(((-1.0)*x19*x32)));
x47=(x12*x41);
x48=(x39*x5);
x49=(x44*x8);
x50=(x43*x9);
x51=(x45*x9);
x52=(((x0*x27))+x48);
x53=(((x27*x3))+((x40*x5)));
x54=(((x0*x26))+((x42*x7)));
x55=((((-1.0)*x38))+x49);
x56=(((x17*x4*x6))+((x22*(((((-1.0)*x30))+x37)))));
x57=((((-1.0)*x18*x27))+(((-1.0)*x15*x39)));
x58=(((x46*x7))+((x26*x3)));
x59=((((-1.0)*x15*x40))+(((-1.0)*x19*x27)));
x60=(x12*x54);
x61=(x57*x8);
x62=(x12*x58);
x63=(x50+((x59*x8)));
eerot[0]=(((x11*(((((-1.0)*x17*x45))+(((-1.0)*x22*x52))))))+(((-1.0)*x10*(((((1.0)*x13*((((x8*(((((-1.0)*x48))+(((-1.0)*x0*x27))))))+x51))))+(((1.0)*x60)))))));
eerot[1]=(((x10*((((x33*x45))+((x29*x52))))))+((x11*((((x13*((x51+x61))))+x60)))));
eerot[2]=(((x13*x54))+((x12*(((((-1.0)*x22*x45))+(((-1.0)*x17*x57)))))));
eetrans[0]=(((x23*x26))+((x12*(((((-1.0)*x24*x45))+(((-1.0)*x25*x57))))))+((x23*x6))+((x13*(((((0.126)*x0*x26))+((x16*x42))))))+((x7*(((((-1.0)*x0*x2*x21))+((x14*x4)))))));
eerot[3]=(((x11*((((x33*x43))+((x29*x53))))))+((x10*(((((-1.0)*x20*x63))+(((-1.0)*x62)))))));
eerot[4]=(((x11*((((x13*x63))+x62))))+((x10*(((((-1.0)*x17*x43))+(((-1.0)*x22*x53)))))));
eerot[5]=(((x13*x58))+((x12*(((((-1.0)*x22*x43))+(((-1.0)*x17*x59)))))));
eetrans[1]=(((x7*(((((-1.0)*x14*x32))+(((-1.0)*x23*x4))))))+((x14*x26))+((x14*x6))+((x12*(((((-1.0)*x24*x43))+(((-1.0)*x25*x59))))))+((x13*(((((0.126)*x26*x3))+((x16*x46)))))));
eerot[6]=(((x10*(((((-1.0)*x47))+(((-1.0)*x20*x55))))))+((x11*x56)));
eerot[7]=(((x11*((((x13*x55))+x47))))+((x10*x56)));
eerot[8]=(((x12*(((((-1.0)*x17*x44))+x38))))+((x13*x41)));
eetrans[2]=((0.34)+((x21*x5))+((x13*((((x16*x2*x6))+(((0.126)*x34))))))+((x12*(((((-1.0)*x25*x44))+((x24*x4*x6))))))+x21+(((0.4)*x2*x27)));
}
IKFAST_API int GetNumFreeParameters() { return 1; }
IKFAST_API int* GetFreeParameters() { static int freeparams[] = {1}; return freeparams; }
IKFAST_API int GetNumJoints() { return 7; }
IKFAST_API int GetIkRealSize() { return sizeof(IkReal); }
IKFAST_API int GetIkType() { return 0x67000001; }
class IKSolver {
public:
IkReal j0,cj0,sj0,htj0,j0mul,j2,cj2,sj2,htj2,j2mul,j3,cj3,sj3,htj3,j3mul,j4,cj4,sj4,htj4,j4mul,j5,cj5,sj5,htj5,j5mul,j6,cj6,sj6,htj6,j6mul,j1,cj1,sj1,htj1,new_r00,r00,rxp0_0,new_r01,r01,rxp0_1,new_r02,r02,rxp0_2,new_r10,r10,rxp1_0,new_r11,r11,rxp1_1,new_r12,r12,rxp1_2,new_r20,r20,rxp2_0,new_r21,r21,rxp2_1,new_r22,r22,rxp2_2,new_px,px,npx,new_py,py,npy,new_pz,pz,npz,pp;
unsigned char _ij0[2], _nj0,_ij2[2], _nj2,_ij3[2], _nj3,_ij4[2], _nj4,_ij5[2], _nj5,_ij6[2], _nj6,_ij1[2], _nj1;
IkReal j100, cj100, sj100;
unsigned char _ij100[2], _nj100;
bool ComputeIk(const IkReal* eetrans, const IkReal* eerot, const IkReal* pfree, IkSolutionListBase<IkReal>& solutions) {
j0=numeric_limits<IkReal>::quiet_NaN(); _ij0[0] = -1; _ij0[1] = -1; _nj0 = -1; j2=numeric_limits<IkReal>::quiet_NaN(); _ij2[0] = -1; _ij2[1] = -1; _nj2 = -1; j3=numeric_limits<IkReal>::quiet_NaN(); _ij3[0] = -1; _ij3[1] = -1; _nj3 = -1; j4=numeric_limits<IkReal>::quiet_NaN(); _ij4[0] = -1; _ij4[1] = -1; _nj4 = -1; j5=numeric_limits<IkReal>::quiet_NaN(); _ij5[0] = -1; _ij5[1] = -1; _nj5 = -1; j6=numeric_limits<IkReal>::quiet_NaN(); _ij6[0] = -1; _ij6[1] = -1; _nj6 = -1; _ij1[0] = -1; _ij1[1] = -1; _nj1 = 0;
for(int dummyiter = 0; dummyiter < 1; ++dummyiter) {
solutions.Clear();
j1=pfree[0]; cj1=cos(pfree[0]); sj1=sin(pfree[0]), htj1=tan(pfree[0]*0.5);
r00 = eerot[0*3+0];
r01 = eerot[0*3+1];
r02 = eerot[0*3+2];
r10 = eerot[1*3+0];
r11 = eerot[1*3+1];
r12 = eerot[1*3+2];
r20 = eerot[2*3+0];
r21 = eerot[2*3+1];
r22 = eerot[2*3+2];
px = eetrans[0]; py = eetrans[1]; pz = eetrans[2];
new_r00=((-1.0)*r00);
new_r01=((-1.0)*r01);
new_r02=r02;
new_px=((((-0.126)*r02))+px);
new_r10=((-1.0)*r10);
new_r11=((-1.0)*r11);
new_r12=r12;
new_py=((((-0.126)*r12))+py);
new_r20=((-1.0)*r20);
new_r21=((-1.0)*r21);
new_r22=r22;
new_pz=((-0.34)+(((-0.126)*r22))+pz);
r00 = new_r00; r01 = new_r01; r02 = new_r02; r10 = new_r10; r11 = new_r11; r12 = new_r12; r20 = new_r20; r21 = new_r21; r22 = new_r22; px = new_px; py = new_py; pz = new_pz;
IkReal x64=((1.0)*px);
IkReal x65=((1.0)*pz);
IkReal x66=((1.0)*py);
pp=((px*px)+(py*py)+(pz*pz));
npx=(((px*r00))+((py*r10))+((pz*r20)));
npy=(((px*r01))+((py*r11))+((pz*r21)));
npz=(((px*r02))+((py*r12))+((pz*r22)));
rxp0_0=((((-1.0)*r20*x66))+((pz*r10)));
rxp0_1=(((px*r20))+(((-1.0)*r00*x65)));
rxp0_2=((((-1.0)*r10*x64))+((py*r00)));
rxp1_0=((((-1.0)*r21*x66))+((pz*r11)));
rxp1_1=(((px*r21))+(((-1.0)*r01*x65)));
rxp1_2=((((-1.0)*r11*x64))+((py*r01)));
rxp2_0=(((pz*r12))+(((-1.0)*r22*x66)));
rxp2_1=(((px*r22))+(((-1.0)*r02*x65)));
rxp2_2=((((-1.0)*r12*x64))+((py*r02)));
{
IkReal j0eval[4];
IkReal x67=sj1*sj1;
j0eval[0]=0.64;
j0eval[1]=sj1;
j0eval[2]=(pp+(((-1.0)*(pz*pz))));
j0eval[3]=(((x67*(py*py)))+((x67*(px*px))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 || IKabs(j0eval[3]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j6eval[1];
IkReal x68=((0.4)*cj1);
IkReal x69=((0.4)*r22);
IkReal x70=((1.0)*pz);
IkReal x71=pz*pz;
IkReal x72=(pz*r22);
IkReal x73=((0.8)*x72);
IkReal x74=(pz*x70);
IkReal x75=((-1.0)*pz);
IkReal x76=((((-1.0)*x70))+x68+x69);
IkReal x77=((((-1.0)*x70))+x68+(((-1.0)*x69)));
IkReal x78=((((-1.0)*x74))+x73);
IkReal x79=((((-1.0)*x73))+(((-1.0)*x74)));
px=0;
py=0;
pp=x71;
npx=(pz*r20);
npy=(pz*r21);
npz=x72;
rxp0_0=(pz*r10);
rxp0_1=(r00*x75);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x75);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x75);
rxp2_2=0;
IkReal gconst0=x76;
IkReal gconst1=x77;
IkReal gconst2=x78;
IkReal gconst3=x79;
IkReal gconst4=x76;
IkReal gconst5=x77;
IkReal gconst6=x78;
IkReal gconst7=x79;
IkReal gconst8=x76;
IkReal gconst9=x77;
IkReal gconst10=x78;
IkReal gconst11=x79;
IkReal gconst12=x76;
IkReal gconst13=x77;
IkReal gconst14=x78;
IkReal gconst15=x79;
IkReal x80=r20*r20;
IkReal x81=pz*pz*pz;
IkReal x82=pz*pz*pz*pz;
IkReal x83=r22*r22;
IkReal x84=cj1*cj1;
IkReal x85=pz*pz;
IkReal x86=r21*r21;
IkReal x87=(r20*r21);
IkReal x88=((2.56)*x82);
IkReal x89=(cj1*x81);
IkReal x90=((0.64)*x82);
IkReal x91=(x84*x85);
IkReal x92=((4.096)*x87*x89);
IkReal x93=((((1.6384)*x87*x91))+((x87*x88)));
j6eval[0]=((IKabs(((((-1.0)*x83*x88))+(((4.096)*x86*x89))+(((-1.6384)*x83*x91))+(((-1.6384)*x86*x91))+(((-1.0)*x86*x88))+(((4.096)*x83*x89)))))+(((0.5)*(IKabs(((((1.024)*x80*x89))+(((-0.4096)*x80*x91))+(((1.024)*x83*x89))+(((-1.0)*x80*x90))+(((-1.0)*x83*x90))+(((-0.4096)*x83*x91)))))))+(IKabs((x92+(((-1.0)*x93)))))+(((0.5)*(IKabs(((((-2.4576)*x83*x91))+(((8.192)*x86*x89))+(((-5.12)*x82*x86))+(((6.144)*x83*x89))+(((-3.2768)*x86*x91))+(((-3.84)*x82*x83))+(((1.28)*x80*x82))+(((0.8192)*x80*x91))+(((-2.048)*x80*x89)))))))+(IKabs((x93+(((-1.0)*x92))))));
if( IKabs(j6eval[0]) < 0.0000000010000000 )
{
continue; // no branches [j0, j5, j6]
} else
{
IkReal op[8+1], zeror[8];
int numroots;
IkReal x94=r20*r20;
IkReal x95=pz*pz;
IkReal x96=r21*r21;
IkReal x97=(gconst0*gconst11);
IkReal x98=(gconst5*gconst6);
IkReal x99=((1.0)*gconst12);
IkReal x100=((0.64)*gconst14);
IkReal x101=((2.56)*gconst1);
IkReal x102=(gconst13*gconst14);
IkReal x103=(gconst9*pz);
IkReal x104=(gconst14*gconst5);
IkReal x105=(gconst4*gconst9);
IkReal x106=(gconst10*gconst7);
IkReal x107=(gconst0*gconst3);
IkReal x108=(gconst11*gconst8);
IkReal x109=((1.28)*pz);
IkReal x110=((1.0)*gconst1);
IkReal x111=(r20*r21);
IkReal x112=((5.12)*gconst14);
IkReal x113=((2.56)*pz);
IkReal x114=(gconst1*pz);
IkReal x115=(gconst2*gconst9);
IkReal x116=((5.12)*gconst6);
IkReal x117=(gconst1*gconst12);
IkReal x118=(gconst3*gconst8);
IkReal x119=((2.56)*gconst6);
IkReal x120=(gconst12*gconst9);
IkReal x121=(gconst1*gconst4);
IkReal x122=(gconst10*gconst15);
IkReal x123=((2.56)*gconst14);
IkReal x124=((1.0)*gconst9);
IkReal x125=(gconst13*gconst6);
IkReal x126=(gconst15*gconst2);
IkReal x127=(gconst2*gconst7);
IkReal x128=(gconst11*x94);
IkReal x129=((1.0)*gconst4*gconst7);
IkReal x130=(gconst10*x125);
IkReal x131=(gconst14*x94);
IkReal x132=(gconst6*x94);
IkReal x133=((5.12)*gconst4*pz);
IkReal x134=(gconst11*x96);
IkReal x135=((10.24)*x95);
IkReal x136=(gconst3*x96);
IkReal x137=((5.12)*gconst12*pz);
IkReal x138=((1.0)*gconst15*gconst4);
IkReal x139=(x94*x95);
IkReal x140=((1.28)*x132);
IkReal x141=(x116*x96);
IkReal x142=(gconst3*gconst4*x94);
IkReal x143=(gconst12*gconst3*x94);
IkReal x144=(gconst11*x111*x123);
IkReal x145=(x100*x128);
IkReal x146=(gconst11*x111*x119);
IkReal x147=(gconst3*x111*x123);
IkReal x148=((0.64)*gconst6*x128);
IkReal x149=(gconst3*x100*x94);
IkReal x150=(gconst3*x111*x119);
IkReal x151=((0.64)*gconst3*x132);
IkReal x152=(x121*x135);
IkReal x153=(gconst11*x111*x137);
IkReal x154=(x103*x111*x112);
IkReal x155=(gconst12*x109*x128);
IkReal x156=((1.28)*x103*x131);
IkReal x157=(gconst3*x111*x137);
IkReal x158=(gconst11*x111*x133);
IkReal x159=(x103*x111*x116);
IkReal x160=(x111*x112*x114);
IkReal x161=(gconst1*x109*x131);
IkReal x162=(x103*x140);
IkReal x163=(x109*x143);
IkReal x164=(gconst4*x109*x128);
IkReal x165=(gconst3*x111*x133);
IkReal x166=(x111*x114*x116);
IkReal x167=(x109*x142);
IkReal x168=(gconst1*x109*x132);
IkReal x169=(x111*x120*x135);
IkReal x170=((2.56)*x120*x139);
IkReal x171=(x111*x117*x135);
IkReal x172=(x105*x111*x135);
IkReal x173=((2.56)*x105*x139);
IkReal x174=(gconst12*x101*x139);
IkReal x175=(x111*x152);
IkReal x176=(gconst4*x101*x139);
IkReal x177=(x170+x145);
IkReal x178=(x176+x151);
IkReal x179=(x154+x153);
IkReal x180=(x168+x167);
IkReal x181=(x169+x144);
IkReal x182=(x166+x165);
IkReal x183=(x175+x150);
IkReal x184=(x156+x155);
IkReal x185=(x171+x172+x146+x147);
IkReal x186=(x160+x157+x159+x158);
IkReal x187=(x162+x163+x161+x164);
IkReal x188=(x173+x174+x148+x149);
op[0]=((((-1.0)*x177))+(((-1.0)*gconst15*x108*x99))+x184+((x102*x108))+((x120*x122))+(((-1.0)*gconst10*x102*x124)));
op[1]=((((-1.0)*x181))+x179);
op[2]=((((1.28)*gconst14*x128))+((x117*x122))+(((-1.0)*x123*x134))+(((5.12)*x120*x139))+(((-1.0)*gconst15*x118*x99))+(((-1.0)*x102*x115))+(((-1.0)*x188))+((x102*x97))+(((-1.0)*gconst15*x97*x99))+((x106*x120))+((gconst12*gconst15*x115))+(((-1.0)*gconst10*x104*x124))+((x102*x118))+((x108*x125))+(((-1.0)*x124*x130))+x187+((x103*x112*x96))+(((-1.0)*x103*x123*x94))+((x105*x122))+((x134*x137))+(((-1.0)*x108*x138))+(((-1.0)*gconst7*x108*x99))+(((-1.0)*gconst10*x102*x110))+((x104*x108))+(((-1.0)*x120*x135*x96))+(((-1.0)*gconst12*x113*x128)));
op[3]=((((-1.0)*x179))+(((-1.0)*x185))+x186+x181);
op[4]=(((x117*x126))+(((-1.0)*x123*x136))+(((5.12)*x105*x139))+(((-1.0)*x115*x125))+((x121*x122))+(((-1.0)*gconst7*x118*x99))+((x103*x141))+((x106*x117))+(((-1.0)*x178))+(((-1.0)*x177))+(((-1.0)*gconst7*x97*x99))+((x125*x97))+(((-1.0)*x110*x130))+((x112*x114*x96))+(((-1.0)*x103*x119*x94))+(((-1.0)*x105*x135*x96))+(((-1.0)*gconst10*x124*x98))+(((-1.0)*gconst15*x107*x99))+(((1.28)*gconst3*x131))+(((5.12)*x117*x139))+((x136*x137))+(((-1.0)*gconst10*x104*x110))+x184+x180+((x102*x107))+((gconst12*gconst7*x115))+((x108*x98))+(((1.28)*gconst6*x128))+((x105*x126))+((x133*x134))+((x104*x118))+((x105*x106))+(((-1.0)*x138*x97))+(((-1.0)*x108*x129))+(((-1.0)*gconst2*x102*x110))+(((-1.0)*x104*x115))+((x118*x125))+(((-1.0)*x113*x143))+(((-1.0)*x117*x135*x96))+(((-1.0)*pz*x101*x131))+(((-1.0)*gconst4*x113*x128))+((x104*x97))+(((-1.0)*x118*x138))+(((-1.0)*x119*x134)));
op[5]=((((-1.0)*x186))+(((-1.0)*x183))+x185+x182);
op[6]=(((x117*x127))+(((-1.0)*gconst10*x110*x98))+(((-1.0)*x118*x129))+(((5.12)*x121*x139))+((x121*x126))+((gconst3*x140))+(((-1.0)*gconst2*x104*x110))+(((-1.0)*x188))+((x106*x121))+((x97*x98))+(((-1.0)*x107*x138))+x187+(((-1.0)*gconst2*x110*x125))+(((-1.0)*gconst7*x107*x99))+((x105*x127))+((x118*x98))+((x133*x136))+((x104*x107))+(((-1.0)*x115*x98))+(((-1.0)*x152*x96))+(((-1.0)*x113*x142))+((x107*x125))+((x114*x141))+(((-1.0)*x129*x97))+(((-1.0)*pz*x101*x132))+(((-1.0)*x119*x136)));
op[7]=((((-1.0)*x182))+x183);
op[8]=(((x121*x127))+((x107*x98))+(((-1.0)*x178))+x180+(((-1.0)*x107*x129))+(((-1.0)*gconst2*x110*x98)));
polyroots8(op,zeror,numroots);
IkReal j6array[8], cj6array[8], sj6array[8], tempj6array[1];
int numsolutions = 0;
for(int ij6 = 0; ij6 < numroots; ++ij6)
{
IkReal htj6 = zeror[ij6];
tempj6array[0]=((2.0)*(atan(htj6)));
for(int kj6 = 0; kj6 < 1; ++kj6)
{
j6array[numsolutions] = tempj6array[kj6];
if( j6array[numsolutions] > IKPI )
{
j6array[numsolutions]-=IK2PI;
}
else if( j6array[numsolutions] < -IKPI )
{
j6array[numsolutions]+=IK2PI;
}
sj6array[numsolutions] = IKsin(j6array[numsolutions]);
cj6array[numsolutions] = IKcos(j6array[numsolutions]);
numsolutions++;
}
}
bool j6valid[8]={true,true,true,true,true,true,true,true};
_nj6 = 8;
for(int ij6 = 0; ij6 < numsolutions; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
htj6 = IKtan(j6/2);
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < numsolutions; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
{
IkReal j5eval[2];
IkReal x189=((-1.0)*pz);
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=(pz*r22);
rxp0_0=(pz*r10);
rxp0_1=(r00*x189);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x189);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x189);
rxp2_2=0;
IkReal x190=(r21*sj6);
IkReal x191=(cj6*r20);
j5eval[0]=((IKabs(r22))+(((2.5)*(IKabs(((((0.4)*x191))+(((-0.4)*x190))))))));
j5eval[1]=((r22*r22)+(((-2.0)*x190*x191))+(x190*x190)+(x191*x191));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 )
{
{
IkReal j5eval[2];
IkReal x192=((-1.0)*pz);
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=(pz*r22);
rxp0_0=(pz*r10);
rxp0_1=(r00*x192);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x192);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x192);
rxp2_2=0;
IkReal x193=pz*pz;
IkReal x194=(cj6*r20);
IkReal x195=(r21*sj6);
j5eval[0]=((IKabs((pz*r22)))+(IKabs(((((-1.0)*pz*x195))+((pz*x194))))));
j5eval[1]=(((x193*(r22*r22)))+((x193*(x194*x194)))+(((-2.0)*x193*x194*x195))+((x193*(x195*x195))));
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 )
{
{
IkReal j0eval[2];
IkReal x196=((-1.0)*pz);
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=(pz*r22);
rxp0_0=(pz*r10);
rxp0_1=(r00*x196);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x196);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x196);
rxp2_2=0;
IkReal x197=sj1*sj1;
IkReal x198=cj6*cj6;
IkReal x199=sj6*sj6;
IkReal x200=(sj1*sj6);
IkReal x201=(cj6*sj1);
IkReal x202=(x197*x199);
IkReal x203=(x197*x198);
IkReal x204=((2.0)*cj6*sj6*x197);
j0eval[0]=(((x202*(r00*r00)))+((r10*r11*x204))+((x202*(r10*r10)))+((r00*r01*x204))+((x203*(r01*r01)))+((x203*(r11*r11))));
j0eval[1]=((IKabs((((r11*x201))+((r10*x200)))))+(IKabs((((r01*x201))+((r00*x200))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
continue; // no branches [j0, j5]
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
IkReal x205=(cj6*r21);
IkReal x206=((1.0)*pz);
IkReal x207=((0.4)*sj1);
IkReal x208=((0.4)*cj1);
IkReal x209=(r20*sj6);
IkReal x210=(((cj6*r01*x207))+((r00*sj6*x207)));
IkReal x211=(((cj6*r11*x207))+((r10*sj6*x207)));
CheckValue<IkReal> x214 = IKatan2WithCheck(IkReal(x210),IkReal(x211),IKFAST_ATAN2_MAGTHRESH);
if(!x214.valid){
continue;
}
IkReal x212=((1.0)*(x214.value));
if((((x211*x211)+(x210*x210))) < -0.00001)
continue;
CheckValue<IkReal> x215=IKPowWithIntegerCheck(IKabs(IKsqrt(((x211*x211)+(x210*x210)))),-1);
if(!x215.valid){
continue;
}
if( (((x215.value)*((((x205*x208))+(((-1.0)*x206*x209))+(((-1.0)*x205*x206))+((x208*x209)))))) < -1-IKFAST_SINCOS_THRESH || (((x215.value)*((((x205*x208))+(((-1.0)*x206*x209))+(((-1.0)*x205*x206))+((x208*x209)))))) > 1+IKFAST_SINCOS_THRESH )
continue;
IkReal x213=IKasin(((x215.value)*((((x205*x208))+(((-1.0)*x206*x209))+(((-1.0)*x205*x206))+((x208*x209))))));
j0array[0]=((((-1.0)*x213))+(((-1.0)*x212)));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+x213+(((-1.0)*x212)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal j5eval[1];
IkReal x216=((-1.0)*pz);
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=(pz*r22);
rxp0_0=(pz*r10);
rxp0_1=(r00*x216);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x216);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x216);
rxp2_2=0;
j5eval[0]=((((-1.0)*r01*sj6))+((cj6*r00)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x217=((-1.0)*pz);
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=(pz*r22);
rxp0_0=(pz*r10);
rxp0_1=(r00*x217);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x217);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x217);
rxp2_2=0;
j5eval[0]=((((-1.0)*r11*sj6))+((cj6*r10)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
IkReal x218=((-1.0)*pz);
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=(pz*r22);
rxp0_0=(pz*r10);
rxp0_1=(r00*x218);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x218);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x218);
rxp2_2=0;
j5eval[0]=(((cj6*r21))+((r20*sj6)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
IkReal x220 = ((1.0)+(((-1.0)*(r22*r22))));
if(IKabs(x220)==0){
continue;
}
IkReal x219=pow(x220,-0.5);
CheckValue<IkReal> x221 = IKatan2WithCheck(IkReal(r21),IkReal(r20),IKFAST_ATAN2_MAGTHRESH);
if(!x221.valid){
continue;
}
IkReal gconst32=((-1.0)*(x221.value));
IkReal gconst33=((-1.0)*r21*x219);
IkReal gconst34=(r20*x219);
CheckValue<IkReal> x222 = IKatan2WithCheck(IkReal(r21),IkReal(r20),IKFAST_ATAN2_MAGTHRESH);
if(!x222.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((x222.value)+j6)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x223=((2.0)*sj1);
IkReal x224=(pz*r22);
IkReal x225=(r12*sj0);
IkReal x226=(cj1*r22);
IkReal x227=((1.0)*sj1);
CheckValue<IkReal> x228=IKPowWithIntegerCheck(((((-2.0)*gconst33*r01))+(((2.0)*gconst34*r00))),-1);
if(!x228.valid){
continue;
}
if( IKabs(((x228.value)*(((((-1.0)*cj0*x223))+(((2.0)*r02*x226))+((r02*x223*x225))+(((-5.0)*r02*x224))+((cj0*x223*(r02*r02))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((2.5)*x224))+(((-1.0)*x225*x227))+(((-1.0)*cj0*r02*x227))+(((-1.0)*x226)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x228.value)*(((((-1.0)*cj0*x223))+(((2.0)*r02*x226))+((r02*x223*x225))+(((-5.0)*r02*x224))+((cj0*x223*(r02*r02)))))))+IKsqr(((((2.5)*x224))+(((-1.0)*x225*x227))+(((-1.0)*cj0*r02*x227))+(((-1.0)*x226))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((x228.value)*(((((-1.0)*cj0*x223))+(((2.0)*r02*x226))+((r02*x223*x225))+(((-5.0)*r02*x224))+((cj0*x223*(r02*r02)))))), ((((2.5)*x224))+(((-1.0)*x225*x227))+(((-1.0)*cj0*r02*x227))+(((-1.0)*x226))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x229=IKcos(j5);
IkReal x230=IKsin(j5);
IkReal x231=((0.4)*gconst34);
IkReal x232=(gconst33*r01);
IkReal x233=((0.8)*pz);
IkReal x234=(gconst33*r21);
IkReal x235=((1.0)*pz);
IkReal x236=(gconst33*r11);
IkReal x237=((0.4)*cj1);
IkReal x238=((0.4)*x229);
IkReal x239=((0.4)*cj0*sj1);
IkReal x240=((0.4)*x230);
IkReal x241=((0.4)*sj0*sj1);
IkReal x242=(r20*x230);
evalcond[0]=(((r02*x239))+(((-1.0)*r22*x235))+x238+((r12*x241))+((r22*x237)));
evalcond[1]=(((r02*x238))+(((-1.0)*x232*x240))+x239+((r00*x230*x231)));
evalcond[2]=(((r10*x230*x231))+(((-1.0)*x236*x240))+x241+((r12*x238)));
evalcond[3]=((((-1.0)*x234*x240))+(((-1.0)*x235))+x237+((x231*x242))+((r22*x238)));
evalcond[4]=(((r22*x229*x233))+(((-1.0)*pz*x235))+(((-1.0)*x230*x233*x234))+((gconst34*x233*x242)));
evalcond[5]=((((-1.0)*x236*x241))+((pz*x234))+(((-1.0)*gconst34*r20*x235))+x240+((cj1*r20*x231))+((cj0*r00*sj1*x231))+(((-1.0)*x234*x237))+((r10*sj0*sj1*x231))+(((-1.0)*x232*x239)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1168 = ((1.0)+(((-1.0)*(r22*r22))));
if(IKabs(x1168)==0){
continue;
}
IkReal x1167=pow(x1168,-0.5);
CheckValue<IkReal> x1169 = IKatan2WithCheck(IkReal(r21),IkReal(r20),IKFAST_ATAN2_MAGTHRESH);
if(!x1169.valid){
continue;
}
IkReal gconst35=((3.14159265358979)+(((-1.0)*(x1169.value))));
IkReal gconst36=((1.0)*r21*x1167);
IkReal gconst37=((-1.0)*r20*x1167);
CheckValue<IkReal> x1170 = IKatan2WithCheck(IkReal(r21),IkReal(r20),IKFAST_ATAN2_MAGTHRESH);
if(!x1170.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+(x1170.value)+j6)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1171=((2.0)*sj1);
IkReal x1172=(pz*r22);
IkReal x1173=(r12*sj0);
IkReal x1174=(cj1*r22);
IkReal x1175=((1.0)*sj1);
CheckValue<IkReal> x1176=IKPowWithIntegerCheck(((((-2.0)*gconst36*r01))+(((2.0)*gconst37*r00))),-1);
if(!x1176.valid){
continue;
}
if( IKabs(((x1176.value)*((((cj0*x1171*(r02*r02)))+(((-1.0)*cj0*x1171))+((r02*x1171*x1173))+(((2.0)*r02*x1174))+(((-5.0)*r02*x1172)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*x1173*x1175))+(((2.5)*x1172))+(((-1.0)*cj0*r02*x1175))+(((-1.0)*x1174)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x1176.value)*((((cj0*x1171*(r02*r02)))+(((-1.0)*cj0*x1171))+((r02*x1171*x1173))+(((2.0)*r02*x1174))+(((-5.0)*r02*x1172))))))+IKsqr(((((-1.0)*x1173*x1175))+(((2.5)*x1172))+(((-1.0)*cj0*r02*x1175))+(((-1.0)*x1174))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((x1176.value)*((((cj0*x1171*(r02*r02)))+(((-1.0)*cj0*x1171))+((r02*x1171*x1173))+(((2.0)*r02*x1174))+(((-5.0)*r02*x1172))))), ((((-1.0)*x1173*x1175))+(((2.5)*x1172))+(((-1.0)*cj0*r02*x1175))+(((-1.0)*x1174))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1177=IKcos(j5);
IkReal x1178=IKsin(j5);
IkReal x1179=(gconst37*r20);
IkReal x1180=(gconst36*r11);
IkReal x1181=(gconst37*r00);
IkReal x1182=(pz*r22);
IkReal x1183=((0.4)*sj1);
IkReal x1184=((1.0)*pz);
IkReal x1185=((0.4)*cj1);
IkReal x1186=(gconst37*r10);
IkReal x1187=(gconst36*r01);
IkReal x1188=(gconst36*r21);
IkReal x1189=((0.4)*x1178);
IkReal x1190=((0.4)*x1177);
IkReal x1191=(pz*x1188);
IkReal x1192=((0.8)*x1178);
evalcond[0]=(x1190+((r22*x1185))+((r12*sj0*x1183))+((cj0*r02*x1183))+(((-1.0)*x1182)));
evalcond[1]=(((cj0*x1183))+(((-1.0)*x1187*x1189))+((x1181*x1189))+((r02*x1190)));
evalcond[2]=(((x1186*x1189))+((sj0*x1183))+(((-1.0)*x1180*x1189))+((r12*x1190)));
evalcond[3]=(x1185+(((-1.0)*x1188*x1189))+((x1179*x1189))+((r22*x1190))+(((-1.0)*x1184)));
evalcond[4]=((((-1.0)*x1191*x1192))+(((0.8)*x1177*x1182))+(((-1.0)*pz*x1184))+((pz*x1179*x1192)));
evalcond[5]=(x1189+x1191+((x1179*x1185))+(((-1.0)*x1179*x1184))+((cj0*x1181*x1183))+(((-1.0)*cj0*x1183*x1187))+(((-1.0)*x1185*x1188))+(((-1.0)*sj0*x1180*x1183))+((sj0*x1183*x1186)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1195 = ((1.0)+(((-1.0)*(r12*r12))));
if(IKabs(x1195)==0){
continue;
}
IkReal x1193=pow(x1195,-0.5);
IkReal x1194=((-1.0)*x1193);
CheckValue<IkReal> x1196 = IKatan2WithCheck(IkReal(r10),IkReal(((-1.0)*r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x1196.valid){
continue;
}
IkReal gconst38=((-1.0)*(x1196.value));
IkReal gconst39=(r10*x1194);
IkReal gconst40=(r11*x1194);
CheckValue<IkReal> x1197 = IKatan2WithCheck(IkReal(r10),IkReal(((-1.0)*r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x1197.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs((j6+(x1197.value))))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1198=((2.0)*sj1);
IkReal x1199=(pz*r22);
IkReal x1200=(r12*sj0);
IkReal x1201=((1.0)*sj1);
IkReal x1202=(cj1*r22);
CheckValue<IkReal> x1203=IKPowWithIntegerCheck(((((-2.0)*gconst39*r01))+(((2.0)*gconst40*r00))),-1);
if(!x1203.valid){
continue;
}
if( IKabs(((x1203.value)*(((((2.0)*r02*x1202))+((r02*x1198*x1200))+((cj0*x1198*(r02*r02)))+(((-5.0)*r02*x1199))+(((-1.0)*cj0*x1198)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*cj0*r02*x1201))+(((2.5)*x1199))+(((-1.0)*x1200*x1201))+(((-1.0)*x1202)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x1203.value)*(((((2.0)*r02*x1202))+((r02*x1198*x1200))+((cj0*x1198*(r02*r02)))+(((-5.0)*r02*x1199))+(((-1.0)*cj0*x1198))))))+IKsqr(((((-1.0)*cj0*r02*x1201))+(((2.5)*x1199))+(((-1.0)*x1200*x1201))+(((-1.0)*x1202))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((x1203.value)*(((((2.0)*r02*x1202))+((r02*x1198*x1200))+((cj0*x1198*(r02*r02)))+(((-5.0)*r02*x1199))+(((-1.0)*cj0*x1198))))), ((((-1.0)*cj0*r02*x1201))+(((2.5)*x1199))+(((-1.0)*x1200*x1201))+(((-1.0)*x1202))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1204=IKcos(j5);
IkReal x1205=IKsin(j5);
IkReal x1206=(gconst39*r21);
IkReal x1207=(gconst40*r20);
IkReal x1208=(gconst40*r10);
IkReal x1209=(pz*r22);
IkReal x1210=(gconst39*r01);
IkReal x1211=((1.0)*pz);
IkReal x1212=((0.4)*cj1);
IkReal x1213=(gconst39*r11);
IkReal x1214=(gconst40*r00);
IkReal x1215=((0.4)*x1204);
IkReal x1216=((0.4)*x1205);
IkReal x1217=((0.4)*cj0*sj1);
IkReal x1218=((0.4)*sj0*sj1);
IkReal x1219=((0.8)*pz*x1205);
evalcond[0]=(((r12*x1218))+x1215+((r22*x1212))+((r02*x1217))+(((-1.0)*x1209)));
evalcond[1]=(((x1214*x1216))+x1217+((r02*x1215))+(((-1.0)*x1210*x1216)));
evalcond[2]=(((r12*x1215))+x1218+(((-1.0)*x1213*x1216))+((x1208*x1216)));
evalcond[3]=(x1212+((r22*x1215))+(((-1.0)*x1206*x1216))+((x1207*x1216))+(((-1.0)*x1211)));
evalcond[4]=((((-1.0)*x1206*x1219))+((x1207*x1219))+(((-1.0)*pz*x1211))+(((0.8)*x1204*x1209)));
evalcond[5]=(((x1214*x1217))+x1216+(((-1.0)*x1207*x1211))+(((-1.0)*x1206*x1212))+((x1207*x1212))+(((-1.0)*x1213*x1218))+(((-1.0)*x1210*x1217))+((pz*x1206))+((x1208*x1218)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1222 = ((1.0)+(((-1.0)*(r12*r12))));
if(IKabs(x1222)==0){
continue;
}
IkReal x1220=pow(x1222,-0.5);
IkReal x1221=((1.0)*x1220);
CheckValue<IkReal> x1223 = IKatan2WithCheck(IkReal(r10),IkReal(((-1.0)*r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x1223.valid){
continue;
}
IkReal gconst41=((3.14159265358979)+(((-1.0)*(x1223.value))));
IkReal gconst42=(r10*x1221);
IkReal gconst43=(r11*x1221);
CheckValue<IkReal> x1224 = IKatan2WithCheck(IkReal(r10),IkReal(((-1.0)*r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x1224.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j6+(x1224.value))))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1225=((2.0)*sj1);
IkReal x1226=(pz*r22);
IkReal x1227=(r12*sj0);
IkReal x1228=((1.0)*sj1);
IkReal x1229=(cj1*r22);
CheckValue<IkReal> x1230=IKPowWithIntegerCheck(((((-2.0)*gconst42*r01))+(((2.0)*gconst43*r00))),-1);
if(!x1230.valid){
continue;
}
if( IKabs(((x1230.value)*(((((-5.0)*r02*x1226))+(((-1.0)*cj0*x1225))+((r02*x1225*x1227))+((cj0*x1225*(r02*r02)))+(((2.0)*r02*x1229)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*x1229))+(((-1.0)*x1227*x1228))+(((-1.0)*cj0*r02*x1228))+(((2.5)*x1226)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x1230.value)*(((((-5.0)*r02*x1226))+(((-1.0)*cj0*x1225))+((r02*x1225*x1227))+((cj0*x1225*(r02*r02)))+(((2.0)*r02*x1229))))))+IKsqr(((((-1.0)*x1229))+(((-1.0)*x1227*x1228))+(((-1.0)*cj0*r02*x1228))+(((2.5)*x1226))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((x1230.value)*(((((-5.0)*r02*x1226))+(((-1.0)*cj0*x1225))+((r02*x1225*x1227))+((cj0*x1225*(r02*r02)))+(((2.0)*r02*x1229))))), ((((-1.0)*x1229))+(((-1.0)*x1227*x1228))+(((-1.0)*cj0*r02*x1228))+(((2.5)*x1226))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1231=IKcos(j5);
IkReal x1232=IKsin(j5);
IkReal x1233=(gconst42*r21);
IkReal x1234=((0.4)*cj1);
IkReal x1235=(pz*r22);
IkReal x1236=((0.4)*sj1);
IkReal x1237=(gconst43*r10);
IkReal x1238=((1.0)*pz);
IkReal x1239=(gconst43*r00);
IkReal x1240=(gconst43*r20);
IkReal x1241=(gconst42*x1236);
IkReal x1242=((0.4)*x1231);
IkReal x1243=((0.4)*x1232);
IkReal x1244=((0.8)*pz*x1232);
evalcond[0]=((((-1.0)*x1235))+x1242+((cj0*r02*x1236))+((r22*x1234))+((r12*sj0*x1236)));
evalcond[1]=(((x1239*x1243))+((cj0*x1236))+((r02*x1242))+(((-1.0)*gconst42*r01*x1243)));
evalcond[2]=((((-1.0)*gconst42*r11*x1243))+((sj0*x1236))+((r12*x1242))+((x1237*x1243)));
evalcond[3]=(x1234+(((-1.0)*x1238))+((x1240*x1243))+(((-1.0)*x1233*x1243))+((r22*x1242)));
evalcond[4]=(((x1240*x1244))+(((-1.0)*x1233*x1244))+(((-1.0)*pz*x1238))+(((0.8)*x1231*x1235)));
evalcond[5]=(x1243+((pz*x1233))+((cj0*x1236*x1239))+((sj0*x1236*x1237))+(((-1.0)*x1238*x1240))+(((-1.0)*x1233*x1234))+(((-1.0)*r11*sj0*x1241))+(((-1.0)*cj0*r01*x1241))+((x1234*x1240)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1247 = ((1.0)+(((-1.0)*(r02*r02))));
if(IKabs(x1247)==0){
continue;
}
IkReal x1245=pow(x1247,-0.5);
IkReal x1246=((-1.0)*x1245);
CheckValue<IkReal> x1248 = IKatan2WithCheck(IkReal(r00),IkReal(((-1.0)*r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x1248.valid){
continue;
}
IkReal gconst44=((-1.0)*(x1248.value));
IkReal gconst45=(r00*x1246);
IkReal gconst46=(r01*x1246);
CheckValue<IkReal> x1249 = IKatan2WithCheck(IkReal(r00),IkReal(((-1.0)*r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x1249.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((x1249.value)+j6)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1250=(r12*r22);
IkReal x1251=(r12*sj1);
IkReal x1252=(cj0*r02);
IkReal x1253=((2.0)*sj0*sj1);
CheckValue<IkReal> x1254=IKPowWithIntegerCheck(((((2.0)*gconst46*r10))+(((-2.0)*gconst45*r11))),-1);
if(!x1254.valid){
continue;
}
if( IKabs(((x1254.value)*(((((-1.0)*x1253))+(((2.0)*cj1*x1250))+(((2.0)*r12*sj0*x1251))+(((2.0)*x1251*x1252))+(((-5.0)*pz*x1250)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((2.5)*pz*r22))+(((-1.0)*cj1*r22))+(((-1.0)*sj1*x1252))+(((-1.0)*sj0*x1251)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x1254.value)*(((((-1.0)*x1253))+(((2.0)*cj1*x1250))+(((2.0)*r12*sj0*x1251))+(((2.0)*x1251*x1252))+(((-5.0)*pz*x1250))))))+IKsqr(((((2.5)*pz*r22))+(((-1.0)*cj1*r22))+(((-1.0)*sj1*x1252))+(((-1.0)*sj0*x1251))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((x1254.value)*(((((-1.0)*x1253))+(((2.0)*cj1*x1250))+(((2.0)*r12*sj0*x1251))+(((2.0)*x1251*x1252))+(((-5.0)*pz*x1250))))), ((((2.5)*pz*r22))+(((-1.0)*cj1*r22))+(((-1.0)*sj1*x1252))+(((-1.0)*sj0*x1251))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1255=IKcos(j5);
IkReal x1256=IKsin(j5);
IkReal x1257=((0.4)*sj1);
IkReal x1258=(gconst45*r11);
IkReal x1259=(pz*r22);
IkReal x1260=(gconst46*r00);
IkReal x1261=(gconst46*r10);
IkReal x1262=((0.4)*cj1);
IkReal x1263=(gconst46*r20);
IkReal x1264=(gconst45*r01);
IkReal x1265=(gconst45*r21);
IkReal x1266=((0.4)*x1255);
IkReal x1267=(pz*x1263);
IkReal x1268=(pz*x1265);
IkReal x1269=((0.8)*x1256);
IkReal x1270=((0.4)*x1256);
evalcond[0]=(x1266+((r22*x1262))+((r12*sj0*x1257))+(((-1.0)*x1259))+((cj0*r02*x1257)));
evalcond[1]=(((cj0*x1257))+((r02*x1266))+((x1260*x1270))+(((-1.0)*x1264*x1270)));
evalcond[2]=(((r12*x1266))+((x1261*x1270))+((sj0*x1257))+(((-1.0)*x1258*x1270)));
evalcond[3]=(x1262+((r22*x1266))+(((-1.0)*pz))+((x1263*x1270))+(((-1.0)*x1265*x1270)));
evalcond[4]=((((-1.0)*x1268*x1269))+((x1267*x1269))+(((-1.0)*(pz*pz)))+(((0.8)*x1255*x1259)));
evalcond[5]=(x1270+x1268+(((-1.0)*x1262*x1265))+((sj0*x1257*x1261))+(((-1.0)*sj0*x1257*x1258))+((x1262*x1263))+(((-1.0)*cj0*x1257*x1264))+((cj0*x1257*x1260))+(((-1.0)*x1267)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1273 = ((1.0)+(((-1.0)*(r02*r02))));
if(IKabs(x1273)==0){
continue;
}
IkReal x1271=pow(x1273,-0.5);
IkReal x1272=((1.0)*x1271);
CheckValue<IkReal> x1274 = IKatan2WithCheck(IkReal(r00),IkReal(((-1.0)*r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x1274.valid){
continue;
}
IkReal gconst47=((3.14159265358979)+(((-1.0)*(x1274.value))));
IkReal gconst48=(r00*x1272);
IkReal gconst49=(r01*x1272);
CheckValue<IkReal> x1275 = IKatan2WithCheck(IkReal(r00),IkReal(((-1.0)*r01)),IKFAST_ATAN2_MAGTHRESH);
if(!x1275.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+(x1275.value)+j6)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1276=(r12*r22);
IkReal x1277=((1.0)*sj1);
IkReal x1278=(cj0*r02);
IkReal x1279=((2.0)*sj0*sj1);
CheckValue<IkReal> x1280=IKPowWithIntegerCheck(((((-2.0)*gconst48*r11))+(((2.0)*gconst49*r10))),-1);
if(!x1280.valid){
continue;
}
if( IKabs(((x1280.value)*(((((-1.0)*x1279))+(((2.0)*r12*sj1*x1278))+(((2.0)*cj1*x1276))+(((-5.0)*pz*x1276))+((x1279*(r12*r12))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*r12*sj0*x1277))+(((2.5)*pz*r22))+(((-1.0)*x1277*x1278))+(((-1.0)*cj1*r22)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x1280.value)*(((((-1.0)*x1279))+(((2.0)*r12*sj1*x1278))+(((2.0)*cj1*x1276))+(((-5.0)*pz*x1276))+((x1279*(r12*r12)))))))+IKsqr(((((-1.0)*r12*sj0*x1277))+(((2.5)*pz*r22))+(((-1.0)*x1277*x1278))+(((-1.0)*cj1*r22))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((x1280.value)*(((((-1.0)*x1279))+(((2.0)*r12*sj1*x1278))+(((2.0)*cj1*x1276))+(((-5.0)*pz*x1276))+((x1279*(r12*r12)))))), ((((-1.0)*r12*sj0*x1277))+(((2.5)*pz*r22))+(((-1.0)*x1277*x1278))+(((-1.0)*cj1*r22))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1281=IKcos(j5);
IkReal x1282=IKsin(j5);
IkReal x1283=(gconst48*r21);
IkReal x1284=((1.0)*pz);
IkReal x1285=(gconst49*r20);
IkReal x1286=((0.8)*pz);
IkReal x1287=(gconst48*r01);
IkReal x1288=(gconst48*r11);
IkReal x1289=((0.4)*cj1);
IkReal x1290=((0.4)*sj0*sj1);
IkReal x1291=((0.4)*x1281);
IkReal x1292=((0.4)*x1282);
IkReal x1293=((0.4)*cj0*sj1);
IkReal x1294=(gconst49*x1292);
evalcond[0]=(x1291+(((-1.0)*r22*x1284))+((r22*x1289))+((r12*x1290))+((r02*x1293)));
evalcond[1]=(x1293+(((-1.0)*x1287*x1292))+((r02*x1291))+((r00*x1294)));
evalcond[2]=(x1290+(((-1.0)*x1288*x1292))+((r12*x1291))+((r10*x1294)));
evalcond[3]=(x1289+(((-1.0)*x1283*x1292))+((x1285*x1292))+(((-1.0)*x1284))+((r22*x1291)));
evalcond[4]=(((r22*x1281*x1286))+(((-1.0)*x1282*x1283*x1286))+((x1282*x1285*x1286))+(((-1.0)*pz*x1284)));
evalcond[5]=(((x1285*x1289))+x1292+(((-1.0)*x1287*x1293))+(((-1.0)*x1288*x1290))+(((-1.0)*x1284*x1285))+((gconst49*r10*x1290))+(((-1.0)*x1283*x1289))+((pz*x1283))+((gconst49*r00*x1293)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(r01))+(IKabs(r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=0;
rxp0_0=(pz*r10);
rxp0_1=0;
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=0;
rxp1_2=0;
rxp2_0=0;
rxp2_1=((-1.0)*pz*r02);
rxp2_2=0;
r00=0;
r01=0;
r12=0;
r22=0;
j5eval[0]=((((-1.0)*r11*sj6))+((cj6*r10)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=0;
rxp0_0=(pz*r10);
rxp0_1=0;
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=0;
rxp1_2=0;
rxp2_0=0;
rxp2_1=((-1.0)*pz*r02);
rxp2_2=0;
r00=0;
r01=0;
r12=0;
r22=0;
j5eval[0]=(((cj6*r20))+(((-1.0)*r21*sj6)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=0;
rxp0_0=(pz*r10);
rxp0_1=0;
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=0;
rxp1_2=0;
rxp2_0=0;
rxp2_1=((-1.0)*pz*r02);
rxp2_2=0;
r00=0;
r01=0;
r12=0;
r22=0;
j5eval[0]=(((cj6*pz*r20))+(((-1.0)*pz*r21*sj6)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
evalcond[0]=IKabs(pz);
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j5eval[1];
px=0;
py=0;
pp=0;
npx=0;
npy=0;
npz=0;
rxp0_0=0;
rxp0_1=0;
rxp0_2=0;
rxp1_0=0;
rxp1_1=0;
rxp1_2=0;
rxp2_0=0;
rxp2_1=0;
rxp2_2=0;
r00=0;
r01=0;
r12=0;
r22=0;
pz=0;
j5eval[0]=(((cj6*r20))+(((-1.0)*r21*sj6)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[1];
px=0;
py=0;
pp=0;
npx=0;
npy=0;
npz=0;
rxp0_0=0;
rxp0_1=0;
rxp0_2=0;
rxp1_0=0;
rxp1_1=0;
rxp1_2=0;
rxp2_0=0;
rxp2_1=0;
rxp2_2=0;
r00=0;
r01=0;
r12=0;
r22=0;
pz=0;
j5eval[0]=((((-1.0)*r11*sj6))+((cj6*r10)));
if( IKabs(j5eval[0]) < 0.0000010000000000 )
{
{
IkReal j5eval[2];
px=0;
py=0;
pp=0;
npx=0;
npy=0;
npz=0;
rxp0_0=0;
rxp0_1=0;
rxp0_2=0;
rxp1_0=0;
rxp1_1=0;
rxp1_2=0;
rxp2_0=0;
rxp2_1=0;
rxp2_2=0;
r00=0;
r01=0;
r12=0;
r22=0;
pz=0;
j5eval[0]=(((cj6*r20))+(((-1.0)*r21*sj6)));
j5eval[1]=r02;
if( IKabs(j5eval[0]) < 0.0000010000000000 || IKabs(j5eval[1]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1295=IKPowWithIntegerCheck(((((-2.0)*r21*sj6))+(((2.0)*cj6*r20))),-1);
if(!x1295.valid){
continue;
}
CheckValue<IkReal> x1296=IKPowWithIntegerCheck(r02,-1);
if(!x1296.valid){
continue;
}
if( IKabs(((-2.0)*cj1*(x1295.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*cj0*sj1*(x1296.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-2.0)*cj1*(x1295.value)))+IKsqr(((-1.0)*cj0*sj1*(x1296.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-2.0)*cj1*(x1295.value)), ((-1.0)*cj0*sj1*(x1296.value)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[5];
IkReal x1297=IKcos(j5);
IkReal x1298=IKsin(j5);
IkReal x1299=((0.4)*r02);
IkReal x1300=(r21*sj6);
IkReal x1301=(cj0*sj1);
IkReal x1302=((0.4)*cj1);
IkReal x1303=(r11*sj6);
IkReal x1304=(cj6*r10);
IkReal x1305=(cj6*r20);
IkReal x1306=((0.4)*x1298);
IkReal x1307=((0.4)*sj0*sj1);
evalcond[0]=(((x1299*x1301))+(((0.4)*x1297)));
evalcond[1]=(((x1297*x1299))+(((0.4)*x1301)));
evalcond[2]=(x1302+((x1305*x1306))+(((-1.0)*x1300*x1306)));
evalcond[3]=(x1307+(((-1.0)*x1303*x1306))+((x1304*x1306)));
evalcond[4]=(x1306+(((-1.0)*x1300*x1302))+(((-1.0)*x1303*x1307))+((x1302*x1305))+((x1304*x1307)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1308=IKPowWithIntegerCheck(((((2.0)*cj6*r10))+(((-2.0)*r11*sj6))),-1);
if(!x1308.valid){
continue;
}
if( IKabs(((-2.0)*sj0*sj1*(x1308.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*cj0*r02*sj1)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-2.0)*sj0*sj1*(x1308.value)))+IKsqr(((-1.0)*cj0*r02*sj1))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-2.0)*sj0*sj1*(x1308.value)), ((-1.0)*cj0*r02*sj1));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[5];
IkReal x1309=IKcos(j5);
IkReal x1310=IKsin(j5);
IkReal x1311=((0.4)*r02);
IkReal x1312=(r21*sj6);
IkReal x1313=(cj0*sj1);
IkReal x1314=((0.4)*cj1);
IkReal x1315=(r11*sj6);
IkReal x1316=(cj6*r10);
IkReal x1317=(cj6*r20);
IkReal x1318=((0.4)*x1310);
IkReal x1319=((0.4)*sj0*sj1);
evalcond[0]=(((x1311*x1313))+(((0.4)*x1309)));
evalcond[1]=((((0.4)*x1313))+((x1309*x1311)));
evalcond[2]=(x1314+((x1317*x1318))+(((-1.0)*x1312*x1318)));
evalcond[3]=(x1319+(((-1.0)*x1315*x1318))+((x1316*x1318)));
evalcond[4]=(x1318+(((-1.0)*x1315*x1319))+((x1314*x1317))+((x1316*x1319))+(((-1.0)*x1312*x1314)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1320=IKPowWithIntegerCheck(((((-2.0)*r21*sj6))+(((2.0)*cj6*r20))),-1);
if(!x1320.valid){
continue;
}
if( IKabs(((-2.0)*cj1*(x1320.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*cj0*r02*sj1)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-2.0)*cj1*(x1320.value)))+IKsqr(((-1.0)*cj0*r02*sj1))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-2.0)*cj1*(x1320.value)), ((-1.0)*cj0*r02*sj1));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[5];
IkReal x1321=IKcos(j5);
IkReal x1322=IKsin(j5);
IkReal x1323=((0.4)*r02);
IkReal x1324=(r21*sj6);
IkReal x1325=(cj0*sj1);
IkReal x1326=((0.4)*cj1);
IkReal x1327=(r11*sj6);
IkReal x1328=(cj6*r10);
IkReal x1329=(cj6*r20);
IkReal x1330=((0.4)*x1322);
IkReal x1331=((0.4)*sj0*sj1);
evalcond[0]=((((0.4)*x1321))+((x1323*x1325)));
evalcond[1]=((((0.4)*x1325))+((x1321*x1323)));
evalcond[2]=(x1326+((x1329*x1330))+(((-1.0)*x1324*x1330)));
evalcond[3]=(x1331+(((-1.0)*x1327*x1330))+((x1328*x1330)));
evalcond[4]=(x1330+(((-1.0)*x1327*x1331))+(((-1.0)*x1324*x1326))+((x1326*x1329))+((x1328*x1331)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1332=((0.8)*pz);
CheckValue<IkReal> x1333=IKPowWithIntegerCheck(((((-1.0)*r21*sj6*x1332))+((cj6*r20*x1332))),-1);
if(!x1333.valid){
continue;
}
if( IKabs(((pz*pz)*(x1333.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*cj0*r02*sj1)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((pz*pz)*(x1333.value)))+IKsqr(((-1.0)*cj0*r02*sj1))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((pz*pz)*(x1333.value)), ((-1.0)*cj0*r02*sj1));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1334=IKcos(j5);
IkReal x1335=IKsin(j5);
IkReal x1336=((0.4)*sj6);
IkReal x1337=(sj0*sj1);
IkReal x1338=((1.0)*pz);
IkReal x1339=(cj6*r20);
IkReal x1340=((0.8)*pz);
IkReal x1341=((0.4)*cj1);
IkReal x1342=(cj6*r10);
IkReal x1343=((0.4)*x1334);
IkReal x1344=(r21*x1335);
IkReal x1345=((0.4)*x1335);
IkReal x1346=((0.4)*cj0*sj1);
evalcond[0]=(x1343+((r02*x1346)));
evalcond[1]=(x1346+((r02*x1343)));
evalcond[2]=(((x1342*x1345))+(((0.4)*x1337))+(((-1.0)*r11*x1335*x1336)));
evalcond[3]=(x1341+(((-1.0)*x1336*x1344))+((x1339*x1345))+(((-1.0)*x1338)));
evalcond[4]=((((-1.0)*sj6*x1340*x1344))+(((-1.0)*pz*x1338))+((x1335*x1339*x1340)));
evalcond[5]=(x1345+(((0.4)*x1337*x1342))+((x1339*x1341))+((pz*r21*sj6))+(((-1.0)*x1338*x1339))+(((-1.0)*r11*x1336*x1337))+(((-1.0)*cj1*r21*x1336)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1347=IKPowWithIntegerCheck(((((0.4)*cj6*r20))+(((-0.4)*r21*sj6))),-1);
if(!x1347.valid){
continue;
}
if( IKabs(((x1347.value)*((pz+(((-0.4)*cj1)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*cj0*r02*sj1)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x1347.value)*((pz+(((-0.4)*cj1))))))+IKsqr(((-1.0)*cj0*r02*sj1))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((x1347.value)*((pz+(((-0.4)*cj1))))), ((-1.0)*cj0*r02*sj1));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1348=IKcos(j5);
IkReal x1349=IKsin(j5);
IkReal x1350=((0.4)*sj6);
IkReal x1351=(sj0*sj1);
IkReal x1352=((1.0)*pz);
IkReal x1353=(cj6*r20);
IkReal x1354=((0.8)*pz);
IkReal x1355=((0.4)*cj1);
IkReal x1356=(cj6*r10);
IkReal x1357=((0.4)*x1348);
IkReal x1358=(r21*x1349);
IkReal x1359=((0.4)*x1349);
IkReal x1360=((0.4)*cj0*sj1);
evalcond[0]=(x1357+((r02*x1360)));
evalcond[1]=(x1360+((r02*x1357)));
evalcond[2]=((((-1.0)*r11*x1349*x1350))+(((0.4)*x1351))+((x1356*x1359)));
evalcond[3]=(x1355+(((-1.0)*x1352))+(((-1.0)*x1350*x1358))+((x1353*x1359)));
evalcond[4]=(((x1349*x1353*x1354))+(((-1.0)*sj6*x1354*x1358))+(((-1.0)*pz*x1352)));
evalcond[5]=(x1359+(((-1.0)*x1352*x1353))+(((0.4)*x1351*x1356))+((pz*r21*sj6))+((x1353*x1355))+(((-1.0)*cj1*r21*x1350))+(((-1.0)*r11*x1350*x1351)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
CheckValue<IkReal> x1361=IKPowWithIntegerCheck(((((2.0)*cj6*r10))+(((-2.0)*r11*sj6))),-1);
if(!x1361.valid){
continue;
}
if( IKabs(((-2.0)*sj0*sj1*(x1361.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*cj0*r02*sj1)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-2.0)*sj0*sj1*(x1361.value)))+IKsqr(((-1.0)*cj0*r02*sj1))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((-2.0)*sj0*sj1*(x1361.value)), ((-1.0)*cj0*r02*sj1));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1362=IKcos(j5);
IkReal x1363=IKsin(j5);
IkReal x1364=((0.4)*sj6);
IkReal x1365=(sj0*sj1);
IkReal x1366=((1.0)*pz);
IkReal x1367=(cj6*r20);
IkReal x1368=((0.8)*pz);
IkReal x1369=((0.4)*cj1);
IkReal x1370=(cj6*r10);
IkReal x1371=((0.4)*x1362);
IkReal x1372=(r21*x1363);
IkReal x1373=((0.4)*x1363);
IkReal x1374=((0.4)*cj0*sj1);
evalcond[0]=(x1371+((r02*x1374)));
evalcond[1]=(x1374+((r02*x1371)));
evalcond[2]=((((0.4)*x1365))+((x1370*x1373))+(((-1.0)*r11*x1363*x1364)));
evalcond[3]=(x1369+((x1367*x1373))+(((-1.0)*x1364*x1372))+(((-1.0)*x1366)));
evalcond[4]=((((-1.0)*pz*x1366))+((x1363*x1367*x1368))+(((-1.0)*sj6*x1368*x1372)));
evalcond[5]=((((-1.0)*x1366*x1367))+x1373+((x1367*x1369))+(((-1.0)*r11*x1364*x1365))+(((0.4)*x1365*x1370))+((pz*r21*sj6))+(((-1.0)*cj1*r21*x1364)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j5]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1375=(cj0*sj1);
IkReal x1376=((0.4)*sj6);
IkReal x1377=((0.4)*cj6);
IkReal x1378=(sj0*sj1);
CheckValue<IkReal> x1379=IKPowWithIntegerCheck(((((2.0)*cj6*r21))+(((2.0)*r20*sj6))),-1);
if(!x1379.valid){
continue;
}
CheckValue<IkReal> x1380=IKPowWithIntegerCheck((((r21*x1377))+((r20*x1376))),-1);
if(!x1380.valid){
continue;
}
if( IKabs(((x1379.value)*(((((-2.0)*r02*x1378))+(((2.0)*r12*x1375)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((x1380.value)*(((((-1.0)*r01*x1376*x1378))+(((-1.0)*r10*x1375*x1377))+((r11*x1375*x1376))+((r00*x1377*x1378)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x1379.value)*(((((-2.0)*r02*x1378))+(((2.0)*r12*x1375))))))+IKsqr(((x1380.value)*(((((-1.0)*r01*x1376*x1378))+(((-1.0)*r10*x1375*x1377))+((r11*x1375*x1376))+((r00*x1377*x1378))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((x1379.value)*(((((-2.0)*r02*x1378))+(((2.0)*r12*x1375))))), ((x1380.value)*(((((-1.0)*r01*x1376*x1378))+(((-1.0)*r10*x1375*x1377))+((r11*x1375*x1376))+((r00*x1377*x1378))))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1381=IKcos(j5);
IkReal x1382=IKsin(j5);
IkReal x1383=(sj0*sj1);
IkReal x1384=((0.8)*pz);
IkReal x1385=(cj6*r20);
IkReal x1386=((0.4)*sj6);
IkReal x1387=(r21*sj6);
IkReal x1388=((1.0)*pz);
IkReal x1389=((0.4)*cj1);
IkReal x1390=(cj6*r00);
IkReal x1391=((0.4)*cj6*r10);
IkReal x1392=((0.4)*x1381);
IkReal x1393=((0.4)*x1382);
IkReal x1394=((0.4)*cj0*sj1);
evalcond[0]=(x1392+(((0.4)*r12*x1383))+((r22*x1389))+(((-1.0)*r22*x1388))+((r02*x1394)));
evalcond[1]=(x1394+(((-1.0)*r01*x1382*x1386))+((x1390*x1393))+((r02*x1392)));
evalcond[2]=(((x1382*x1391))+(((-1.0)*r11*x1382*x1386))+(((0.4)*x1383))+((r12*x1392)));
evalcond[3]=((((-1.0)*x1388))+x1389+(((-1.0)*r21*x1382*x1386))+((x1385*x1393))+((r22*x1392)));
evalcond[4]=((((-1.0)*x1382*x1384*x1387))+((x1382*x1384*x1385))+(((-1.0)*pz*x1388))+((r22*x1381*x1384)));
evalcond[5]=(x1393+(((-1.0)*r11*x1383*x1386))+((x1390*x1394))+((pz*x1387))+(((-1.0)*cj1*r21*x1386))+((x1385*x1389))+((x1383*x1391))+(((-1.0)*x1385*x1388))+(((-1.0)*cj0*r01*sj1*x1386)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1395=(r12*r22);
IkReal x1396=(r12*sj1);
IkReal x1397=(cj0*r02);
IkReal x1398=((2.0)*sj0*sj1);
CheckValue<IkReal> x1399=IKPowWithIntegerCheck(((((2.0)*cj6*r10))+(((-2.0)*r11*sj6))),-1);
if(!x1399.valid){
continue;
}
if( IKabs(((x1399.value)*(((((2.0)*r12*sj0*x1396))+(((2.0)*x1396*x1397))+(((2.0)*cj1*x1395))+(((-5.0)*pz*x1395))+(((-1.0)*x1398)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((2.5)*pz*r22))+(((-1.0)*sj0*x1396))+(((-1.0)*sj1*x1397))+(((-1.0)*cj1*r22)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x1399.value)*(((((2.0)*r12*sj0*x1396))+(((2.0)*x1396*x1397))+(((2.0)*cj1*x1395))+(((-5.0)*pz*x1395))+(((-1.0)*x1398))))))+IKsqr(((((2.5)*pz*r22))+(((-1.0)*sj0*x1396))+(((-1.0)*sj1*x1397))+(((-1.0)*cj1*r22))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((x1399.value)*(((((2.0)*r12*sj0*x1396))+(((2.0)*x1396*x1397))+(((2.0)*cj1*x1395))+(((-5.0)*pz*x1395))+(((-1.0)*x1398))))), ((((2.5)*pz*r22))+(((-1.0)*sj0*x1396))+(((-1.0)*sj1*x1397))+(((-1.0)*cj1*r22))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1400=IKcos(j5);
IkReal x1401=IKsin(j5);
IkReal x1402=(sj0*sj1);
IkReal x1403=((0.8)*pz);
IkReal x1404=(cj6*r20);
IkReal x1405=((0.4)*sj6);
IkReal x1406=(r21*sj6);
IkReal x1407=((1.0)*pz);
IkReal x1408=((0.4)*cj1);
IkReal x1409=(cj6*r00);
IkReal x1410=((0.4)*cj6*r10);
IkReal x1411=((0.4)*x1400);
IkReal x1412=((0.4)*x1401);
IkReal x1413=((0.4)*cj0*sj1);
evalcond[0]=((((-1.0)*r22*x1407))+x1411+((r02*x1413))+((r22*x1408))+(((0.4)*r12*x1402)));
evalcond[1]=((((-1.0)*r01*x1401*x1405))+x1413+((r02*x1411))+((x1409*x1412)));
evalcond[2]=((((0.4)*x1402))+((x1401*x1410))+(((-1.0)*r11*x1401*x1405))+((r12*x1411)));
evalcond[3]=(((r22*x1411))+(((-1.0)*x1407))+((x1404*x1412))+x1408+(((-1.0)*r21*x1401*x1405)));
evalcond[4]=(((r22*x1400*x1403))+((x1401*x1403*x1404))+(((-1.0)*pz*x1407))+(((-1.0)*x1401*x1403*x1406)));
evalcond[5]=((((-1.0)*cj1*r21*x1405))+((x1402*x1410))+((pz*x1406))+(((-1.0)*cj0*r01*sj1*x1405))+(((-1.0)*r11*x1402*x1405))+(((-1.0)*x1404*x1407))+((x1404*x1408))+x1412+((x1409*x1413)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j5array[1], cj5array[1], sj5array[1];
bool j5valid[1]={false};
_nj5 = 1;
IkReal x1414=((2.0)*sj1);
IkReal x1415=(pz*r22);
IkReal x1416=(r12*sj0);
IkReal x1417=((1.0)*sj1);
IkReal x1418=(cj1*r22);
CheckValue<IkReal> x1419=IKPowWithIntegerCheck(((((2.0)*cj6*r00))+(((-2.0)*r01*sj6))),-1);
if(!x1419.valid){
continue;
}
if( IKabs(((x1419.value)*((((cj0*x1414*(r02*r02)))+(((-5.0)*r02*x1415))+((r02*x1414*x1416))+(((2.0)*r02*x1418))+(((-1.0)*cj0*x1414)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((2.5)*x1415))+(((-1.0)*x1416*x1417))+(((-1.0)*cj0*r02*x1417))+(((-1.0)*x1418)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x1419.value)*((((cj0*x1414*(r02*r02)))+(((-5.0)*r02*x1415))+((r02*x1414*x1416))+(((2.0)*r02*x1418))+(((-1.0)*cj0*x1414))))))+IKsqr(((((2.5)*x1415))+(((-1.0)*x1416*x1417))+(((-1.0)*cj0*r02*x1417))+(((-1.0)*x1418))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j5array[0]=IKatan2(((x1419.value)*((((cj0*x1414*(r02*r02)))+(((-5.0)*r02*x1415))+((r02*x1414*x1416))+(((2.0)*r02*x1418))+(((-1.0)*cj0*x1414))))), ((((2.5)*x1415))+(((-1.0)*x1416*x1417))+(((-1.0)*cj0*r02*x1417))+(((-1.0)*x1418))));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
for(int ij5 = 0; ij5 < 1; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 1; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[6];
IkReal x1420=IKcos(j5);
IkReal x1421=IKsin(j5);
IkReal x1422=(sj0*sj1);
IkReal x1423=((0.8)*pz);
IkReal x1424=(cj6*r20);
IkReal x1425=((0.4)*sj6);
IkReal x1426=(r21*sj6);
IkReal x1427=((1.0)*pz);
IkReal x1428=((0.4)*cj1);
IkReal x1429=(cj6*r00);
IkReal x1430=((0.4)*cj6*r10);
IkReal x1431=((0.4)*x1420);
IkReal x1432=((0.4)*x1421);
IkReal x1433=((0.4)*cj0*sj1);
evalcond[0]=(((r02*x1433))+((r22*x1428))+(((0.4)*r12*x1422))+x1431+(((-1.0)*r22*x1427)));
evalcond[1]=(((x1429*x1432))+(((-1.0)*r01*x1421*x1425))+((r02*x1431))+x1433);
evalcond[2]=(((r12*x1431))+((x1421*x1430))+(((0.4)*x1422))+(((-1.0)*r11*x1421*x1425)));
evalcond[3]=((((-1.0)*r21*x1421*x1425))+((x1424*x1432))+x1428+((r22*x1431))+(((-1.0)*x1427)));
evalcond[4]=(((r22*x1420*x1423))+(((-1.0)*x1421*x1423*x1426))+(((-1.0)*pz*x1427))+((x1421*x1423*x1424)));
evalcond[5]=(((x1429*x1433))+((x1424*x1428))+(((-1.0)*x1424*x1427))+(((-1.0)*cj0*r01*sj1*x1425))+(((-1.0)*r11*x1422*x1425))+(((-1.0)*cj1*r21*x1425))+x1432+((x1422*x1430))+((pz*x1426)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
IkReal x1434=pz*pz;
IkReal x1435=((0.8)*pz);
IkReal x1436=(((cj6*r20*x1435))+(((-1.0)*r21*sj6*x1435)));
CheckValue<IkReal> x1439 = IKatan2WithCheck(IkReal((r22*x1435)),IkReal(x1436),IKFAST_ATAN2_MAGTHRESH);
if(!x1439.valid){
continue;
}
IkReal x1437=((1.0)*(x1439.value));
if((((((0.64)*x1434*(r22*r22)))+(x1436*x1436))) < -0.00001)
continue;
CheckValue<IkReal> x1440=IKPowWithIntegerCheck(IKabs(IKsqrt(((((0.64)*x1434*(r22*r22)))+(x1436*x1436)))),-1);
if(!x1440.valid){
continue;
}
if( ((x1434*(x1440.value))) < -1-IKFAST_SINCOS_THRESH || ((x1434*(x1440.value))) > 1+IKFAST_SINCOS_THRESH )
continue;
IkReal x1438=IKasin((x1434*(x1440.value)));
j5array[0]=((((-1.0)*x1437))+x1438);
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
j5array[1]=((3.14159265358979)+(((-1.0)*x1438))+(((-1.0)*x1437)));
sj5array[1]=IKsin(j5array[1]);
cj5array[1]=IKcos(j5array[1]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
if( j5array[1] > IKPI )
{
j5array[1]-=IK2PI;
}
else if( j5array[1] < -IKPI )
{ j5array[1]+=IK2PI;
}
j5valid[1] = true;
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[1];
IkReal x1441=IKsin(j5);
IkReal x1442=((0.4)*x1441);
evalcond[0]=((((-1.0)*r21*sj6*x1442))+(((0.4)*r22*(IKcos(j5))))+(((0.4)*cj1))+(((-1.0)*pz))+((cj6*r20*x1442)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j0eval[3];
IkReal x1443=((-1.0)*pz);
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=(pz*r22);
rxp0_0=(pz*r10);
rxp0_1=(r00*x1443);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x1443);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x1443);
rxp2_2=0;
IkReal x1444=((2.0)*sj5);
IkReal x1445=((2.0)*cj5);
j0eval[0]=sj1;
j0eval[1]=((IKabs(((((-1.0)*cj6*r10*x1444))+(((-1.0)*r12*x1445))+((r11*sj6*x1444)))))+(IKabs(((((-1.0)*cj6*r00*x1444))+(((-1.0)*r02*x1445))+((r01*sj6*x1444))))));
j0eval[2]=IKsign(sj1);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[2];
IkReal x1446=((-1.0)*pz);
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=(pz*r22);
rxp0_0=(pz*r10);
rxp0_1=(r00*x1446);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x1446);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x1446);
rxp2_2=0;
IkReal x1447=cj1*cj1;
IkReal x1448=(r10*sj6);
IkReal x1449=(cj6*r11);
IkReal x1450=((1.0)*x1447);
j0eval[0]=((((-1.0)*x1448*x1450))+x1449+x1448+(((-1.0)*x1449*x1450)));
j0eval[1]=sj1;
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
{
IkReal j0eval[2];
IkReal x1451=((-1.0)*pz);
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=(pz*r22);
rxp0_0=(pz*r10);
rxp0_1=(r00*x1451);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x1451);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x1451);
rxp2_2=0;
j0eval[0]=r12;
j0eval[1]=sj1;
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
continue; // no branches [j0]
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
CheckValue<IkReal> x1458=IKPowWithIntegerCheck(sj1,-1);
if(!x1458.valid){
continue;
}
IkReal x1452=x1458.value;
IkReal x1453=((2.0)*sj5);
IkReal x1454=(cj6*r00);
IkReal x1455=(r01*sj6);
IkReal x1456=((2.0)*cj5);
IkReal x1457=((0.5)*x1452);
CheckValue<IkReal> x1459=IKPowWithIntegerCheck(r12,-1);
if(!x1459.valid){
continue;
}
if( IKabs((x1457*(x1459.value)*(((((-1.0)*r02*x1453*x1455))+(((-2.0)*cj1*r22))+(((-1.0)*x1456))+((r02*x1453*x1454))+((x1456*(r02*r02)))+(((5.0)*pz*r22)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs((x1457*(((((-1.0)*r02*x1456))+(((-1.0)*x1453*x1454))+((x1453*x1455)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((x1457*(x1459.value)*(((((-1.0)*r02*x1453*x1455))+(((-2.0)*cj1*r22))+(((-1.0)*x1456))+((r02*x1453*x1454))+((x1456*(r02*r02)))+(((5.0)*pz*r22))))))+IKsqr((x1457*(((((-1.0)*r02*x1456))+(((-1.0)*x1453*x1454))+((x1453*x1455))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j0array[0]=IKatan2((x1457*(x1459.value)*(((((-1.0)*r02*x1453*x1455))+(((-2.0)*cj1*r22))+(((-1.0)*x1456))+((r02*x1453*x1454))+((x1456*(r02*r02)))+(((5.0)*pz*r22))))), (x1457*(((((-1.0)*r02*x1456))+(((-1.0)*x1453*x1454))+((x1453*x1455))))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1460=IKsin(j0);
IkReal x1461=IKcos(j0);
IkReal x1462=((0.4)*sj6);
IkReal x1463=((0.4)*cj6);
IkReal x1464=(pz*sj6);
IkReal x1465=((1.0)*r20);
IkReal x1466=(cj1*r21);
IkReal x1467=(cj6*pz);
IkReal x1468=((0.4)*r02);
IkReal x1469=(cj1*r20);
IkReal x1470=((0.4)*cj5);
IkReal x1471=(sj1*x1461);
IkReal x1472=(r10*sj1*x1460);
IkReal x1473=((0.4)*sj1*x1460);
IkReal x1474=(r11*sj1*x1460);
evalcond[0]=(((r00*sj5*x1463))+(((-1.0)*r01*sj5*x1462))+((cj5*x1468))+(((0.4)*x1471)));
evalcond[1]=(((r12*x1470))+((r10*sj5*x1463))+x1473+(((-1.0)*r11*sj5*x1462)));
evalcond[2]=(((r12*x1473))+(((-1.0)*pz*r22))+(((0.4)*cj1*r22))+x1470+((x1468*x1471)));
evalcond[3]=(((x1463*x1466))+((x1462*x1472))+((r00*x1462*x1471))+(((-1.0)*x1464*x1465))+((x1463*x1474))+((r01*x1463*x1471))+((x1462*x1469))+(((-1.0)*r21*x1467)));
evalcond[4]=(((x1463*x1469))+((r00*x1463*x1471))+(((-1.0)*x1462*x1466))+((x1463*x1472))+(((0.4)*sj5))+(((-1.0)*r01*x1462*x1471))+((r21*x1464))+(((-1.0)*x1465*x1467))+(((-1.0)*x1462*x1474)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1475=cj1*cj1;
IkReal x1476=((2.0)*sj6);
IkReal x1477=(pz*sj1);
IkReal x1478=(r01*sj5);
IkReal x1479=(cj5*r02);
IkReal x1480=(r00*sj1);
IkReal x1481=(sj5*sj6);
IkReal x1482=((2.0)*cj6);
IkReal x1483=((0.8)*sj6);
IkReal x1484=((0.8)*cj6*sj1);
IkReal x1485=(r10*x1483);
IkReal x1486=((0.8)*cj6*r11);
CheckValue<IkReal> x1487=IKPowWithIntegerCheck(((((-1.0)*x1475*x1486))+(((-1.0)*x1475*x1485))+x1486+x1485),-1);
if(!x1487.valid){
continue;
}
CheckValue<IkReal> x1488=IKPowWithIntegerCheck(sj1,-1);
if(!x1488.valid){
continue;
}
if( IKabs(((x1487.value)*((((x1479*x1480*x1483))+(((0.8)*cj6*r00*x1480*x1481))+(((-1.0)*cj1*r21*x1484))+((r01*x1479*x1484))+(((-0.8)*x1478*x1480))+(((1.6)*x1478*x1480*(cj6*cj6)))+(((-1.0)*cj6*r01*sj1*x1478*x1483))+((r21*x1477*x1482))+((r20*x1476*x1477))+(((-1.0)*cj1*r20*sj1*x1483)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((0.5)*(x1488.value)*(((((-1.0)*r00*sj5*x1482))+((x1476*x1478))+(((-2.0)*x1479)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x1487.value)*((((x1479*x1480*x1483))+(((0.8)*cj6*r00*x1480*x1481))+(((-1.0)*cj1*r21*x1484))+((r01*x1479*x1484))+(((-0.8)*x1478*x1480))+(((1.6)*x1478*x1480*(cj6*cj6)))+(((-1.0)*cj6*r01*sj1*x1478*x1483))+((r21*x1477*x1482))+((r20*x1476*x1477))+(((-1.0)*cj1*r20*sj1*x1483))))))+IKsqr(((0.5)*(x1488.value)*(((((-1.0)*r00*sj5*x1482))+((x1476*x1478))+(((-2.0)*x1479))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j0array[0]=IKatan2(((x1487.value)*((((x1479*x1480*x1483))+(((0.8)*cj6*r00*x1480*x1481))+(((-1.0)*cj1*r21*x1484))+((r01*x1479*x1484))+(((-0.8)*x1478*x1480))+(((1.6)*x1478*x1480*(cj6*cj6)))+(((-1.0)*cj6*r01*sj1*x1478*x1483))+((r21*x1477*x1482))+((r20*x1476*x1477))+(((-1.0)*cj1*r20*sj1*x1483))))), ((0.5)*(x1488.value)*(((((-1.0)*r00*sj5*x1482))+((x1476*x1478))+(((-2.0)*x1479))))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1489=IKsin(j0);
IkReal x1490=IKcos(j0);
IkReal x1491=((0.4)*sj6);
IkReal x1492=((0.4)*cj6);
IkReal x1493=(pz*sj6);
IkReal x1494=((1.0)*r20);
IkReal x1495=(cj1*r21);
IkReal x1496=(cj6*pz);
IkReal x1497=((0.4)*r02);
IkReal x1498=(cj1*r20);
IkReal x1499=((0.4)*cj5);
IkReal x1500=(sj1*x1490);
IkReal x1501=(r10*sj1*x1489);
IkReal x1502=((0.4)*sj1*x1489);
IkReal x1503=(r11*sj1*x1489);
evalcond[0]=(((cj5*x1497))+(((-1.0)*r01*sj5*x1491))+((r00*sj5*x1492))+(((0.4)*x1500)));
evalcond[1]=((((-1.0)*r11*sj5*x1491))+((r12*x1499))+x1502+((r10*sj5*x1492)));
evalcond[2]=((((-1.0)*pz*r22))+((r12*x1502))+(((0.4)*cj1*r22))+((x1497*x1500))+x1499);
evalcond[3]=(((x1492*x1503))+((r00*x1491*x1500))+(((-1.0)*x1493*x1494))+(((-1.0)*r21*x1496))+((x1491*x1498))+((r01*x1492*x1500))+((x1492*x1495))+((x1491*x1501)));
evalcond[4]=(((x1492*x1501))+(((-1.0)*x1494*x1496))+((r00*x1492*x1500))+(((-1.0)*x1491*x1503))+(((-1.0)*r01*x1491*x1500))+((r21*x1493))+(((0.4)*sj5))+((x1492*x1498))+(((-1.0)*x1491*x1495)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1504=((2.0)*sj5);
IkReal x1505=((2.0)*cj5);
CheckValue<IkReal> x1506=IKPowWithIntegerCheck(IKsign(sj1),-1);
if(!x1506.valid){
continue;
}
CheckValue<IkReal> x1507 = IKatan2WithCheck(IkReal((((r11*sj6*x1504))+(((-1.0)*cj6*r10*x1504))+(((-1.0)*r12*x1505)))),IkReal((((r01*sj6*x1504))+(((-1.0)*cj6*r00*x1504))+(((-1.0)*r02*x1505)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1507.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1506.value)))+(x1507.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1508=IKsin(j0);
IkReal x1509=IKcos(j0);
IkReal x1510=((0.4)*sj6);
IkReal x1511=((0.4)*cj6);
IkReal x1512=(pz*sj6);
IkReal x1513=((1.0)*r20);
IkReal x1514=(cj1*r21);
IkReal x1515=(cj6*pz);
IkReal x1516=((0.4)*r02);
IkReal x1517=(cj1*r20);
IkReal x1518=((0.4)*cj5);
IkReal x1519=(sj1*x1509);
IkReal x1520=(r10*sj1*x1508);
IkReal x1521=((0.4)*sj1*x1508);
IkReal x1522=(r11*sj1*x1508);
evalcond[0]=(((cj5*x1516))+((r00*sj5*x1511))+(((-1.0)*r01*sj5*x1510))+(((0.4)*x1519)));
evalcond[1]=(((r12*x1518))+(((-1.0)*r11*sj5*x1510))+x1521+((r10*sj5*x1511)));
evalcond[2]=(((r12*x1521))+(((-1.0)*pz*r22))+(((0.4)*cj1*r22))+((x1516*x1519))+x1518);
evalcond[3]=(((r01*x1511*x1519))+((x1510*x1520))+((x1510*x1517))+(((-1.0)*r21*x1515))+((r00*x1510*x1519))+(((-1.0)*x1512*x1513))+((x1511*x1522))+((x1511*x1514)));
evalcond[4]=(((r00*x1511*x1519))+(((-1.0)*x1513*x1515))+(((-1.0)*x1510*x1514))+(((-1.0)*x1510*x1522))+(((-1.0)*r01*x1510*x1519))+(((0.4)*sj5))+((r21*x1512))+((x1511*x1520))+((x1511*x1517)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
}
}
}
} else
{
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
IkReal x1523=((((0.4)*cj6*r20))+(((-0.4)*r21*sj6)));
CheckValue<IkReal> x1526 = IKatan2WithCheck(IkReal(((0.4)*r22)),IkReal(x1523),IKFAST_ATAN2_MAGTHRESH);
if(!x1526.valid){
continue;
}
IkReal x1524=((1.0)*(x1526.value));
if((((x1523*x1523)+(((0.16)*(r22*r22))))) < -0.00001)
continue;
CheckValue<IkReal> x1527=IKPowWithIntegerCheck(IKabs(IKsqrt(((x1523*x1523)+(((0.16)*(r22*r22)))))),-1);
if(!x1527.valid){
continue;
}
if( (((x1527.value)*(((((0.4)*cj1))+(((-1.0)*pz)))))) < -1-IKFAST_SINCOS_THRESH || (((x1527.value)*(((((0.4)*cj1))+(((-1.0)*pz)))))) > 1+IKFAST_SINCOS_THRESH )
continue;
IkReal x1525=IKasin(((x1527.value)*(((((0.4)*cj1))+(((-1.0)*pz))))));
j5array[0]=((((-1.0)*x1524))+(((-1.0)*x1525)));
sj5array[0]=IKsin(j5array[0]);
cj5array[0]=IKcos(j5array[0]);
j5array[1]=((3.14159265358979)+(((-1.0)*x1524))+x1525);
sj5array[1]=IKsin(j5array[1]);
cj5array[1]=IKcos(j5array[1]);
if( j5array[0] > IKPI )
{
j5array[0]-=IK2PI;
}
else if( j5array[0] < -IKPI )
{ j5array[0]+=IK2PI;
}
j5valid[0] = true;
if( j5array[1] > IKPI )
{
j5array[1]-=IK2PI;
}
else if( j5array[1] < -IKPI )
{ j5array[1]+=IK2PI;
}
j5valid[1] = true;
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal evalcond[1];
IkReal x1528=IKsin(j5);
IkReal x1529=((0.8)*pz);
evalcond[0]=(((r22*x1529*(IKcos(j5))))+(((-1.0)*(pz*pz)))+((cj6*r20*x1528*x1529))+(((-1.0)*r21*sj6*x1528*x1529)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j0eval[3];
IkReal x1530=((-1.0)*pz);
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=(pz*r22);
rxp0_0=(pz*r10);
rxp0_1=(r00*x1530);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x1530);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x1530);
rxp2_2=0;
IkReal x1531=((2.0)*sj5);
IkReal x1532=((2.0)*cj5);
j0eval[0]=sj1;
j0eval[1]=((IKabs((((r01*sj6*x1531))+(((-1.0)*r02*x1532))+(((-1.0)*cj6*r00*x1531)))))+(IKabs(((((-1.0)*cj6*r10*x1531))+(((-1.0)*r12*x1532))+((r11*sj6*x1531))))));
j0eval[2]=IKsign(sj1);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[2];
IkReal x1533=((-1.0)*pz);
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=(pz*r22);
rxp0_0=(pz*r10);
rxp0_1=(r00*x1533);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x1533);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x1533);
rxp2_2=0;
IkReal x1534=cj1*cj1;
IkReal x1535=(r10*sj6);
IkReal x1536=(cj6*r11);
IkReal x1537=((1.0)*x1534);
j0eval[0]=((((-1.0)*x1535*x1537))+x1536+x1535+(((-1.0)*x1536*x1537)));
j0eval[1]=sj1;
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
{
IkReal j0eval[2];
IkReal x1538=((-1.0)*pz);
px=0;
py=0;
pp=pz*pz;
npx=(pz*r20);
npy=(pz*r21);
npz=(pz*r22);
rxp0_0=(pz*r10);
rxp0_1=(r00*x1538);
rxp0_2=0;
rxp1_0=(pz*r11);
rxp1_1=(r01*x1538);
rxp1_2=0;
rxp2_0=(pz*r12);
rxp2_1=(r02*x1538);
rxp2_2=0;
j0eval[0]=r12;
j0eval[1]=sj1;
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
continue; // no branches [j0]
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
CheckValue<IkReal> x1545=IKPowWithIntegerCheck(sj1,-1);
if(!x1545.valid){
continue;
}
IkReal x1539=x1545.value;
IkReal x1540=((2.0)*sj5);
IkReal x1541=(cj6*r00);
IkReal x1542=(r01*sj6);
IkReal x1543=((2.0)*cj5);
IkReal x1544=((0.5)*x1539);
CheckValue<IkReal> x1546=IKPowWithIntegerCheck(r12,-1);
if(!x1546.valid){
continue;
}
if( IKabs((x1544*(x1546.value)*(((((-2.0)*cj1*r22))+((x1543*(r02*r02)))+(((-1.0)*r02*x1540*x1542))+(((-1.0)*x1543))+(((5.0)*pz*r22))+((r02*x1540*x1541)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs((x1544*(((((-1.0)*r02*x1543))+(((-1.0)*x1540*x1541))+((x1540*x1542)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((x1544*(x1546.value)*(((((-2.0)*cj1*r22))+((x1543*(r02*r02)))+(((-1.0)*r02*x1540*x1542))+(((-1.0)*x1543))+(((5.0)*pz*r22))+((r02*x1540*x1541))))))+IKsqr((x1544*(((((-1.0)*r02*x1543))+(((-1.0)*x1540*x1541))+((x1540*x1542))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j0array[0]=IKatan2((x1544*(x1546.value)*(((((-2.0)*cj1*r22))+((x1543*(r02*r02)))+(((-1.0)*r02*x1540*x1542))+(((-1.0)*x1543))+(((5.0)*pz*r22))+((r02*x1540*x1541))))), (x1544*(((((-1.0)*r02*x1543))+(((-1.0)*x1540*x1541))+((x1540*x1542))))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1547=IKsin(j0);
IkReal x1548=IKcos(j0);
IkReal x1549=((0.4)*sj6);
IkReal x1550=((0.4)*cj6);
IkReal x1551=(pz*sj6);
IkReal x1552=((1.0)*r20);
IkReal x1553=(cj1*r21);
IkReal x1554=(cj6*pz);
IkReal x1555=((0.4)*r02);
IkReal x1556=(cj1*r20);
IkReal x1557=((0.4)*cj5);
IkReal x1558=(sj1*x1548);
IkReal x1559=(r10*sj1*x1547);
IkReal x1560=((0.4)*sj1*x1547);
IkReal x1561=(r11*sj1*x1547);
evalcond[0]=(((r00*sj5*x1550))+(((-1.0)*r01*sj5*x1549))+(((0.4)*x1558))+((cj5*x1555)));
evalcond[1]=((((-1.0)*r11*sj5*x1549))+((r10*sj5*x1550))+((r12*x1557))+x1560);
evalcond[2]=(((x1555*x1558))+(((-1.0)*pz*r22))+(((0.4)*cj1*r22))+((r12*x1560))+x1557);
evalcond[3]=(((x1550*x1561))+(((-1.0)*r21*x1554))+((x1550*x1553))+((r00*x1549*x1558))+((x1549*x1559))+((x1549*x1556))+((r01*x1550*x1558))+(((-1.0)*x1551*x1552)));
evalcond[4]=((((-1.0)*x1549*x1553))+(((-1.0)*x1552*x1554))+((x1550*x1556))+((x1550*x1559))+(((-1.0)*x1549*x1561))+(((-1.0)*r01*x1549*x1558))+(((0.4)*sj5))+((r00*x1550*x1558))+((r21*x1551)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1562=cj1*cj1;
IkReal x1563=((2.0)*sj6);
IkReal x1564=(pz*sj1);
IkReal x1565=(r01*sj5);
IkReal x1566=(cj5*r02);
IkReal x1567=(r00*sj1);
IkReal x1568=(sj5*sj6);
IkReal x1569=((2.0)*cj6);
IkReal x1570=((0.8)*sj6);
IkReal x1571=((0.8)*cj6*sj1);
IkReal x1572=(r10*x1570);
IkReal x1573=((0.8)*cj6*r11);
CheckValue<IkReal> x1574=IKPowWithIntegerCheck(((((-1.0)*x1562*x1573))+(((-1.0)*x1562*x1572))+x1573+x1572),-1);
if(!x1574.valid){
continue;
}
CheckValue<IkReal> x1575=IKPowWithIntegerCheck(sj1,-1);
if(!x1575.valid){
continue;
}
if( IKabs(((x1574.value)*(((((-1.0)*cj1*r21*x1571))+((r01*x1566*x1571))+(((-1.0)*cj1*r20*sj1*x1570))+((x1566*x1567*x1570))+(((-1.0)*cj6*r01*sj1*x1565*x1570))+((r21*x1564*x1569))+(((1.6)*x1565*x1567*(cj6*cj6)))+(((-0.8)*x1565*x1567))+(((0.8)*cj6*r00*x1567*x1568))+((r20*x1563*x1564)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((0.5)*(x1575.value)*(((((-1.0)*r00*sj5*x1569))+(((-2.0)*x1566))+((x1563*x1565)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x1574.value)*(((((-1.0)*cj1*r21*x1571))+((r01*x1566*x1571))+(((-1.0)*cj1*r20*sj1*x1570))+((x1566*x1567*x1570))+(((-1.0)*cj6*r01*sj1*x1565*x1570))+((r21*x1564*x1569))+(((1.6)*x1565*x1567*(cj6*cj6)))+(((-0.8)*x1565*x1567))+(((0.8)*cj6*r00*x1567*x1568))+((r20*x1563*x1564))))))+IKsqr(((0.5)*(x1575.value)*(((((-1.0)*r00*sj5*x1569))+(((-2.0)*x1566))+((x1563*x1565))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j0array[0]=IKatan2(((x1574.value)*(((((-1.0)*cj1*r21*x1571))+((r01*x1566*x1571))+(((-1.0)*cj1*r20*sj1*x1570))+((x1566*x1567*x1570))+(((-1.0)*cj6*r01*sj1*x1565*x1570))+((r21*x1564*x1569))+(((1.6)*x1565*x1567*(cj6*cj6)))+(((-0.8)*x1565*x1567))+(((0.8)*cj6*r00*x1567*x1568))+((r20*x1563*x1564))))), ((0.5)*(x1575.value)*(((((-1.0)*r00*sj5*x1569))+(((-2.0)*x1566))+((x1563*x1565))))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1576=IKsin(j0);
IkReal x1577=IKcos(j0);
IkReal x1578=((0.4)*sj6);
IkReal x1579=((0.4)*cj6);
IkReal x1580=(pz*sj6);
IkReal x1581=((1.0)*r20);
IkReal x1582=(cj1*r21);
IkReal x1583=(cj6*pz);
IkReal x1584=((0.4)*r02);
IkReal x1585=(cj1*r20);
IkReal x1586=((0.4)*cj5);
IkReal x1587=(sj1*x1577);
IkReal x1588=(r10*sj1*x1576);
IkReal x1589=((0.4)*sj1*x1576);
IkReal x1590=(r11*sj1*x1576);
evalcond[0]=((((-1.0)*r01*sj5*x1578))+(((0.4)*x1587))+((r00*sj5*x1579))+((cj5*x1584)));
evalcond[1]=(((r12*x1586))+(((-1.0)*r11*sj5*x1578))+x1589+((r10*sj5*x1579)));
evalcond[2]=(((x1584*x1587))+(((-1.0)*pz*r22))+((r12*x1589))+(((0.4)*cj1*r22))+x1586);
evalcond[3]=((((-1.0)*x1580*x1581))+(((-1.0)*r21*x1583))+((r00*x1578*x1587))+((x1579*x1582))+((x1579*x1590))+((x1578*x1588))+((x1578*x1585))+((r01*x1579*x1587)));
evalcond[4]=((((-1.0)*x1578*x1582))+(((-1.0)*x1578*x1590))+((r00*x1579*x1587))+(((0.4)*sj5))+(((-1.0)*r01*x1578*x1587))+((r21*x1580))+(((-1.0)*x1581*x1583))+((x1579*x1588))+((x1579*x1585)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1591=((2.0)*sj5);
IkReal x1592=((2.0)*cj5);
CheckValue<IkReal> x1593 = IKatan2WithCheck(IkReal((((r11*sj6*x1591))+(((-1.0)*cj6*r10*x1591))+(((-1.0)*r12*x1592)))),IkReal(((((-1.0)*r02*x1592))+((r01*sj6*x1591))+(((-1.0)*cj6*r00*x1591)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1593.valid){
continue;
}
CheckValue<IkReal> x1594=IKPowWithIntegerCheck(IKsign(sj1),-1);
if(!x1594.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1593.value)+(((1.5707963267949)*(x1594.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1595=IKsin(j0);
IkReal x1596=IKcos(j0);
IkReal x1597=((0.4)*sj6);
IkReal x1598=((0.4)*cj6);
IkReal x1599=(pz*sj6);
IkReal x1600=((1.0)*r20);
IkReal x1601=(cj1*r21);
IkReal x1602=(cj6*pz);
IkReal x1603=((0.4)*r02);
IkReal x1604=(cj1*r20);
IkReal x1605=((0.4)*cj5);
IkReal x1606=(sj1*x1596);
IkReal x1607=(r10*sj1*x1595);
IkReal x1608=((0.4)*sj1*x1595);
IkReal x1609=(r11*sj1*x1595);
evalcond[0]=(((r00*sj5*x1598))+(((0.4)*x1606))+((cj5*x1603))+(((-1.0)*r01*sj5*x1597)));
evalcond[1]=(x1608+((r10*sj5*x1598))+(((-1.0)*r11*sj5*x1597))+((r12*x1605)));
evalcond[2]=((((-1.0)*pz*r22))+x1605+(((0.4)*cj1*r22))+((r12*x1608))+((x1603*x1606)));
evalcond[3]=(((r01*x1598*x1606))+(((-1.0)*x1599*x1600))+(((-1.0)*r21*x1602))+((r00*x1597*x1606))+((x1598*x1601))+((x1598*x1609))+((x1597*x1607))+((x1597*x1604)));
evalcond[4]=((((-1.0)*x1600*x1602))+((r00*x1598*x1606))+(((-1.0)*x1597*x1609))+(((-1.0)*x1597*x1601))+(((0.4)*sj5))+((x1598*x1607))+((x1598*x1604))+(((-1.0)*r01*x1597*x1606))+((r21*x1599)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
}
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0, j5, j6]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
IkReal x1610=sj1*sj1;
IkReal x1611=((-0.8)*sj1);
IkReal x1612=((0.64)*x1610);
CheckValue<IkReal> x1615 = IKatan2WithCheck(IkReal((px*x1611)),IkReal((py*x1611)),IKFAST_ATAN2_MAGTHRESH);
if(!x1615.valid){
continue;
}
IkReal x1613=((1.0)*(x1615.value));
if(((((x1612*(py*py)))+((x1612*(px*px))))) < -0.00001)
continue;
CheckValue<IkReal> x1616=IKPowWithIntegerCheck(IKabs(IKsqrt((((x1612*(py*py)))+((x1612*(px*px)))))),-1);
if(!x1616.valid){
continue;
}
if( (((x1616.value)*((pp+(((-0.8)*cj1*pz)))))) < -1-IKFAST_SINCOS_THRESH || (((x1616.value)*((pp+(((-0.8)*cj1*pz)))))) > 1+IKFAST_SINCOS_THRESH )
continue;
IkReal x1614=IKasin(((x1616.value)*((pp+(((-0.8)*cj1*pz))))));
j0array[0]=((((-1.0)*x1614))+(((-1.0)*x1613)));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+x1614+(((-1.0)*x1613)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
IkReal x1617=((1.0)*sj1);
cj5array[0]=((((2.5)*npz))+(((-1.0)*r12*sj0*x1617))+(((-1.0)*cj0*r02*x1617))+(((-1.0)*cj1*r22)));
if( cj5array[0] >= -1-IKFAST_SINCOS_THRESH && cj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKacos(cj5array[0]);
sj5array[0] = IKsin(j5array[0]);
cj5array[1] = cj5array[0];
j5array[1] = -j5array[0];
sj5array[1] = -sj5array[0];
}
else if( isnan(cj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal j6eval[3];
IkReal x1618=(r12*sj5);
IkReal x1619=((2.0)*cj5);
IkReal x1620=((2.0)*cj1);
IkReal x1621=((2.0)*cj0*sj1);
j6eval[0]=x1618;
j6eval[1]=((IKabs(((((-1.0)*r20*x1621))+((r00*x1620))+((r11*x1619))+(((5.0)*rxp0_1)))))+(IKabs(((((-1.0)*r21*x1621))+((r01*x1620))+(((5.0)*rxp1_1))+(((-1.0)*r10*x1619))))));
j6eval[2]=IKsign(x1618);
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 || IKabs(j6eval[2]) < 0.0000010000000000 )
{
{
IkReal j6eval[3];
IkReal x1622=((5.0)*pp);
IkReal x1623=((4.0)*cj5);
IkReal x1624=((4.0)*npx);
IkReal x1625=(r21*sj5);
IkReal x1626=((10.0)*pz);
IkReal x1627=(npy*r20*sj5);
j6eval[0]=((((-1.0)*npx*x1625))+x1627);
j6eval[1]=IKsign(((((4.0)*x1627))+(((-1.0)*x1624*x1625))));
j6eval[2]=((IKabs(((((-1.0)*r20*x1622))+(((-1.0)*npx*r22*x1623))+((npz*r20*x1623))+(((-1.0)*cj1*x1624))+((npx*x1626)))))+(IKabs(((((-4.0)*cj1*npy))+((npy*x1626))+(((-1.0)*r21*x1622))+(((-1.0)*npy*r22*x1623))+((npz*r21*x1623))))));
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 || IKabs(j6eval[2]) < 0.0000010000000000 )
{
{
IkReal j6eval[3];
IkReal x1628=((4.0)*npx);
IkReal x1629=(cj0*sj1);
IkReal x1630=(r01*sj5);
IkReal x1631=(cj5*r02);
IkReal x1632=((5.0)*pp);
IkReal x1633=((10.0)*px);
IkReal x1634=((4.0)*npy);
IkReal x1635=((4.0)*cj5*npz);
IkReal x1636=(npy*r00*sj5);
j6eval[0]=((((-1.0)*npx*x1630))+x1636);
j6eval[1]=((IKabs(((((-1.0)*r01*x1632))+((r01*x1635))+(((-1.0)*x1629*x1634))+(((-1.0)*x1631*x1634))+((npy*x1633)))))+(IKabs((((npx*x1633))+(((-1.0)*r00*x1632))+((r00*x1635))+(((-1.0)*x1628*x1629))+(((-1.0)*x1628*x1631))))));
j6eval[2]=IKsign((((r00*sj5*x1634))+(((-1.0)*x1628*x1630))));
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 || IKabs(j6eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j5))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j6eval[1];
sj5=0;
cj5=1.0;
j5=0;
IkReal x1637=((0.4)*cj1);
IkReal x1638=((0.4)*sj1);
j6eval[0]=((IKabs(((((-1.0)*r11*sj0*x1638))+npy+(((-1.0)*r21*x1637))+(((-1.0)*cj0*r01*x1638)))))+(IKabs((((r20*x1637))+((r10*sj0*x1638))+(((-1.0)*npx))+((cj0*r00*x1638))))));
if( IKabs(j6eval[0]) < 0.0000010000000000 )
{
{
IkReal j6eval[1];
sj5=0;
cj5=1.0;
j5=0;
IkReal x1639=((0.4)*cj1);
IkReal x1640=((0.4)*sj1);
j6eval[0]=((IKabs((((r20*x1639))+(((-1.0)*npx))+((r10*sj0*x1640))+((cj0*r00*x1640)))))+(IKabs((((r21*x1639))+(((-1.0)*npy))+((cj0*r01*x1640))+((r11*sj0*x1640))))));
if( IKabs(j6eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j6]
} else
{
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
IkReal x1641=((0.4)*cj1);
IkReal x1642=((0.4)*sj1);
CheckValue<IkReal> x1644 = IKatan2WithCheck(IkReal((((r21*x1641))+(((-1.0)*npy))+((cj0*r01*x1642))+((r11*sj0*x1642)))),IkReal((((r20*x1641))+(((-1.0)*npx))+((r10*sj0*x1642))+((cj0*r00*x1642)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1644.valid){
continue;
}
IkReal x1643=x1644.value;
j6array[0]=((-1.0)*x1643);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
j6array[1]=((3.14159265358979)+(((-1.0)*x1643)));
sj6array[1]=IKsin(j6array[1]);
cj6array[1]=IKcos(j6array[1]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
if( j6array[1] > IKPI )
{
j6array[1]-=IK2PI;
}
else if( j6array[1] < -IKPI )
{ j6array[1]+=IK2PI;
}
j6valid[1] = true;
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[1];
IkReal x1645=IKcos(j6);
IkReal x1646=IKsin(j6);
IkReal x1647=((0.4)*cj1);
IkReal x1648=((0.4)*sj0*sj1);
IkReal x1649=((0.4)*cj0*sj1);
evalcond[0]=(((r00*x1645*x1649))+((r10*x1645*x1648))+(((-1.0)*npx*x1645))+(((-1.0)*r01*x1646*x1649))+(((-1.0)*r21*x1646*x1647))+(((-1.0)*r11*x1646*x1648))+((r20*x1645*x1647))+((npy*x1646)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
IkReal x1650=((0.4)*cj1);
IkReal x1651=((0.4)*sj1);
CheckValue<IkReal> x1653 = IKatan2WithCheck(IkReal((((r20*x1650))+(((-1.0)*npx))+((r10*sj0*x1651))+((cj0*r00*x1651)))),IkReal(((((-1.0)*r21*x1650))+(((-1.0)*r11*sj0*x1651))+npy+(((-1.0)*cj0*r01*x1651)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1653.valid){
continue;
}
IkReal x1652=x1653.value;
j6array[0]=((-1.0)*x1652);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
j6array[1]=((3.14159265358979)+(((-1.0)*x1652)));
sj6array[1]=IKsin(j6array[1]);
cj6array[1]=IKcos(j6array[1]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
if( j6array[1] > IKPI )
{
j6array[1]-=IK2PI;
}
else if( j6array[1] < -IKPI )
{ j6array[1]+=IK2PI;
}
j6valid[1] = true;
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[1];
IkReal x1654=IKsin(j6);
IkReal x1655=IKcos(j6);
IkReal x1656=((0.4)*sj1);
IkReal x1657=((0.4)*cj1);
evalcond[0]=((((-1.0)*npx*x1654))+((cj0*r01*x1655*x1656))+((r20*x1654*x1657))+((r21*x1655*x1657))+((r11*sj0*x1655*x1656))+((r10*sj0*x1654*x1656))+(((-1.0)*npy*x1655))+((cj0*r00*x1654*x1656)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j5)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j6eval[1];
sj5=0;
cj5=-1.0;
j5=3.14159265358979;
IkReal x1658=((0.4)*cj1);
IkReal x1659=((0.4)*sj1);
j6eval[0]=((IKabs((((r20*x1658))+(((-1.0)*npx))+((r10*sj0*x1659))+((cj0*r00*x1659)))))+(IKabs(((((-1.0)*r21*x1658))+(((-1.0)*r11*sj0*x1659))+npy+(((-1.0)*cj0*r01*x1659))))));
if( IKabs(j6eval[0]) < 0.0000010000000000 )
{
{
IkReal j6eval[1];
sj5=0;
cj5=-1.0;
j5=3.14159265358979;
IkReal x1660=((0.4)*cj1);
IkReal x1661=((0.4)*sj1);
j6eval[0]=((IKabs(((((-1.0)*npx))+((r20*x1660))+((r10*sj0*x1661))+((cj0*r00*x1661)))))+(IKabs(((((-1.0)*npy))+((cj0*r01*x1661))+((r11*sj0*x1661))+((r21*x1660))))));
if( IKabs(j6eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j6]
} else
{
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
IkReal x1662=((0.4)*cj1);
IkReal x1663=((0.4)*sj1);
CheckValue<IkReal> x1665 = IKatan2WithCheck(IkReal(((((-1.0)*npy))+((cj0*r01*x1663))+((r11*sj0*x1663))+((r21*x1662)))),IkReal(((((-1.0)*npx))+((r20*x1662))+((r10*sj0*x1663))+((cj0*r00*x1663)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1665.valid){
continue;
}
IkReal x1664=x1665.value;
j6array[0]=((-1.0)*x1664);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
j6array[1]=((3.14159265358979)+(((-1.0)*x1664)));
sj6array[1]=IKsin(j6array[1]);
cj6array[1]=IKcos(j6array[1]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
if( j6array[1] > IKPI )
{
j6array[1]-=IK2PI;
}
else if( j6array[1] < -IKPI )
{ j6array[1]+=IK2PI;
}
j6valid[1] = true;
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[1];
IkReal x1666=IKcos(j6);
IkReal x1667=IKsin(j6);
IkReal x1668=((0.4)*cj1);
IkReal x1669=((0.4)*sj0*sj1);
IkReal x1670=((0.4)*cj0*sj1);
evalcond[0]=((((-1.0)*r21*x1667*x1668))+((r10*x1666*x1669))+(((-1.0)*npx*x1666))+(((-1.0)*r11*x1667*x1669))+((r00*x1666*x1670))+((npy*x1667))+(((-1.0)*r01*x1667*x1670))+((r20*x1666*x1668)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
IkReal x1671=((0.4)*cj1);
IkReal x1672=((0.4)*sj1);
CheckValue<IkReal> x1674 = IKatan2WithCheck(IkReal((((r10*sj0*x1672))+((cj0*r00*x1672))+(((-1.0)*npx))+((r20*x1671)))),IkReal(((((-1.0)*r11*sj0*x1672))+npy+(((-1.0)*cj0*r01*x1672))+(((-1.0)*r21*x1671)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1674.valid){
continue;
}
IkReal x1673=x1674.value;
j6array[0]=((-1.0)*x1673);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
j6array[1]=((3.14159265358979)+(((-1.0)*x1673)));
sj6array[1]=IKsin(j6array[1]);
cj6array[1]=IKcos(j6array[1]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
if( j6array[1] > IKPI )
{
j6array[1]-=IK2PI;
}
else if( j6array[1] < -IKPI )
{ j6array[1]+=IK2PI;
}
j6valid[1] = true;
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[1];
IkReal x1675=IKsin(j6);
IkReal x1676=IKcos(j6);
IkReal x1677=((0.4)*sj1);
IkReal x1678=((0.4)*cj1);
evalcond[0]=(((r11*sj0*x1676*x1677))+((r10*sj0*x1675*x1677))+((r21*x1676*x1678))+((cj0*r00*x1675*x1677))+((r20*x1675*x1678))+(((-1.0)*npx*x1675))+((cj0*r01*x1676*x1677))+(((-1.0)*npy*x1676)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=IKabs(r12);
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j6eval[3];
r12=0;
npz=(((px*r02))+((pz*r22)));
rxp2_0=((-1.0)*py*r22);
rxp2_2=(py*r02);
IkReal x1679=(r02*sj5);
IkReal x1680=((2.0)*r10);
IkReal x1681=(cj5*r22);
IkReal x1682=((2.0)*r11);
IkReal x1683=((2.0)*sj0*sj1);
j6eval[0]=x1679;
j6eval[1]=((IKabs((((cj1*x1680))+((x1680*x1681))+(((-1.0)*r20*x1683))+(((-5.0)*rxp0_0)))))+(IKabs(((((-5.0)*rxp1_0))+((cj1*x1682))+((x1681*x1682))+(((-1.0)*r21*x1683))))));
j6eval[2]=IKsign(x1679);
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 || IKabs(j6eval[2]) < 0.0000010000000000 )
{
{
IkReal j6eval[3];
r12=0;
npz=(((px*r02))+((pz*r22)));
rxp2_0=((-1.0)*py*r22);
rxp2_2=(py*r02);
IkReal x1684=(r22*sj5);
IkReal x1685=((2.0)*r10);
IkReal x1686=(cj5*r02);
IkReal x1687=(cj0*sj1);
IkReal x1688=((2.0)*r11);
IkReal x1689=((2.0)*sj0*sj1);
j6eval[0]=x1684;
j6eval[1]=IKsign(x1684);
j6eval[2]=((IKabs(((((-5.0)*rxp1_2))+(((-1.0)*x1686*x1688))+(((-1.0)*x1687*x1688))+((r01*x1689)))))+(IKabs((((r00*x1689))+(((-1.0)*x1685*x1686))+(((-1.0)*x1685*x1687))+(((-5.0)*rxp0_2))))));
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 || IKabs(j6eval[2]) < 0.0000010000000000 )
{
{
IkReal j6eval[3];
r12=0;
npz=(((px*r02))+((pz*r22)));
rxp2_0=((-1.0)*py*r22);
rxp2_2=(py*r02);
IkReal x1690=((5.0)*pp);
IkReal x1691=((10.0)*py);
IkReal x1692=((4.0)*sj0*sj1);
IkReal x1693=(npx*r11*sj5);
IkReal x1694=(npy*r10*sj5);
IkReal x1695=((4.0)*cj5*pz*r22);
IkReal x1696=((4.0)*cj5*px*r02);
j6eval[0]=(x1694+(((-1.0)*x1693)));
j6eval[1]=((IKabs((((r10*x1696))+((r10*x1695))+(((-1.0)*npx*x1692))+((npx*x1691))+(((-1.0)*r10*x1690)))))+(IKabs(((((-1.0)*r11*x1690))+((r11*x1695))+((r11*x1696))+(((-1.0)*npy*x1692))+((npy*x1691))))));
j6eval[2]=IKsign(((((4.0)*x1694))+(((-4.0)*x1693))));
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 || IKabs(j6eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j5))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j6eval[1];
r12=0;
npz=(((px*r02))+((pz*r22)));
rxp2_0=((-1.0)*py*r22);
rxp2_2=(py*r02);
sj5=0;
cj5=1.0;
j5=0;
IkReal x1697=((0.4)*r02);
IkReal x1698=((0.4)*cj1);
IkReal x1699=((1.0)*pz);
j6eval[0]=((IKabs(((((-1.0)*r21*x1699))+((r21*x1698))+(((-1.0)*r01*x1697)))))+(IKabs((((r20*x1698))+(((-1.0)*r20*x1699))+(((-1.0)*r00*x1697))))));
if( IKabs(j6eval[0]) < 0.0000010000000000 )
{
{
IkReal j6eval[1];
r12=0;
npz=(((px*r02))+((pz*r22)));
rxp2_0=((-1.0)*py*r22);
rxp2_2=(py*r02);
sj5=0;
cj5=1.0;
j5=0;
IkReal x1700=((0.4)*r02);
IkReal x1701=((0.4)*cj1);
j6eval[0]=((IKabs(((((-1.0)*r21*x1701))+((r01*x1700))+((pz*r21)))))+(IKabs(((((-1.0)*pz*r20))+((r20*x1701))+(((-1.0)*r00*x1700))))));
if( IKabs(j6eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j6]
} else
{
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
IkReal x1702=((0.4)*r02);
IkReal x1703=((0.4)*cj1);
CheckValue<IkReal> x1705 = IKatan2WithCheck(IkReal((((px*r00))+(((-1.0)*npx))+((r20*x1703))+((py*r10))+(((-1.0)*r00*x1702)))),IkReal(((((-1.0)*px*r01))+(((-1.0)*r21*x1703))+((r01*x1702))+npy+(((-1.0)*py*r11)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1705.valid){
continue;
}
IkReal x1704=x1705.value;
j6array[0]=((-1.0)*x1704);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
j6array[1]=((3.14159265358979)+(((-1.0)*x1704)));
sj6array[1]=IKsin(j6array[1]);
cj6array[1]=IKcos(j6array[1]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
if( j6array[1] > IKPI )
{
j6array[1]-=IK2PI;
}
else if( j6array[1] < -IKPI )
{ j6array[1]+=IK2PI;
}
j6valid[1] = true;
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[1];
IkReal x1706=IKsin(j6);
IkReal x1707=IKcos(j6);
IkReal x1708=((0.4)*r02);
IkReal x1709=((0.4)*cj1);
IkReal x1710=(r01*x1707);
IkReal x1711=(r00*x1706);
evalcond[0]=(((r21*x1707*x1709))+((r20*x1706*x1709))+((py*r11*x1707))+(((-1.0)*x1708*x1711))+(((-1.0)*x1708*x1710))+((py*r10*x1706))+(((-1.0)*npx*x1706))+((px*x1711))+((px*x1710))+(((-1.0)*npy*x1707)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
IkReal x1712=((0.4)*r02);
IkReal x1713=((0.4)*cj1);
CheckValue<IkReal> x1715 = IKatan2WithCheck(IkReal((((px*r01))+(((-1.0)*npy))+((r21*x1713))+((py*r11))+(((-1.0)*r01*x1712)))),IkReal(((((-1.0)*r00*x1712))+((px*r00))+((r20*x1713))+(((-1.0)*npx))+((py*r10)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1715.valid){
continue;
}
IkReal x1714=x1715.value;
j6array[0]=((-1.0)*x1714);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
j6array[1]=((3.14159265358979)+(((-1.0)*x1714)));
sj6array[1]=IKsin(j6array[1]);
cj6array[1]=IKcos(j6array[1]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
if( j6array[1] > IKPI )
{
j6array[1]-=IK2PI;
}
else if( j6array[1] < -IKPI )
{ j6array[1]+=IK2PI;
}
j6valid[1] = true;
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[1];
IkReal x1716=IKcos(j6);
IkReal x1717=IKsin(j6);
IkReal x1718=((0.4)*x1717);
IkReal x1719=(r00*x1716);
IkReal x1720=((1.0)*x1717);
evalcond[0]=(((npy*x1717))+(((-1.0)*npx*x1716))+((py*r10*x1716))+(((-0.4)*r02*x1719))+((px*x1719))+(((-1.0)*py*r11*x1720))+(((0.4)*cj1*r20*x1716))+(((-1.0)*cj1*r21*x1718))+(((-1.0)*px*r01*x1720))+((r01*r02*x1718)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j5)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j6eval[1];
r12=0;
npz=(((px*r02))+((pz*r22)));
rxp2_0=((-1.0)*py*r22);
rxp2_2=(py*r02);
sj5=0;
cj5=-1.0;
j5=3.14159265358979;
IkReal x1721=((0.4)*r02);
IkReal x1722=((0.4)*cj1);
IkReal x1723=((1.0)*pz);
j6eval[0]=((IKabs((((r00*x1721))+((r20*x1722))+(((-1.0)*r20*x1723)))))+(IKabs((((r01*x1721))+((r21*x1722))+(((-1.0)*r21*x1723))))));
if( IKabs(j6eval[0]) < 0.0000010000000000 )
{
{
IkReal j6eval[1];
r12=0;
npz=(((px*r02))+((pz*r22)));
rxp2_0=((-1.0)*py*r22);
rxp2_2=(py*r02);
sj5=0;
cj5=-1.0;
j5=3.14159265358979;
IkReal x1724=((0.4)*r02);
IkReal x1725=((0.4)*cj1);
j6eval[0]=((IKabs((((r00*x1724))+(((-1.0)*pz*r20))+((r20*x1725)))))+(IKabs(((((-1.0)*r01*x1724))+((pz*r21))+(((-1.0)*r21*x1725))))));
if( IKabs(j6eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j6]
} else
{
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
IkReal x1726=((0.4)*r02);
IkReal x1727=((0.4)*cj1);
CheckValue<IkReal> x1729 = IKatan2WithCheck(IkReal((((r00*x1726))+((px*r00))+(((-1.0)*npx))+((py*r10))+((r20*x1727)))),IkReal(((((-1.0)*px*r01))+(((-1.0)*r01*x1726))+npy+(((-1.0)*py*r11))+(((-1.0)*r21*x1727)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1729.valid){
continue;
}
IkReal x1728=x1729.value;
j6array[0]=((-1.0)*x1728);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
j6array[1]=((3.14159265358979)+(((-1.0)*x1728)));
sj6array[1]=IKsin(j6array[1]);
cj6array[1]=IKcos(j6array[1]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
if( j6array[1] > IKPI )
{
j6array[1]-=IK2PI;
}
else if( j6array[1] < -IKPI )
{ j6array[1]+=IK2PI;
}
j6valid[1] = true;
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[1];
IkReal x1730=IKsin(j6);
IkReal x1731=IKcos(j6);
IkReal x1732=((0.4)*r02);
IkReal x1733=((0.4)*cj1);
IkReal x1734=(r01*x1731);
IkReal x1735=(r00*x1730);
evalcond[0]=(((r20*x1730*x1733))+((py*r11*x1731))+((r21*x1731*x1733))+((px*x1735))+((px*x1734))+(((-1.0)*npy*x1731))+((x1732*x1735))+((x1732*x1734))+((py*r10*x1730))+(((-1.0)*npx*x1730)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
IkReal x1736=((0.4)*r02);
IkReal x1737=((0.4)*cj1);
CheckValue<IkReal> x1739 = IKatan2WithCheck(IkReal((((r01*x1736))+((px*r01))+((r21*x1737))+(((-1.0)*npy))+((py*r11)))),IkReal((((r00*x1736))+((px*r00))+(((-1.0)*npx))+((py*r10))+((r20*x1737)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1739.valid){
continue;
}
IkReal x1738=x1739.value;
j6array[0]=((-1.0)*x1738);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
j6array[1]=((3.14159265358979)+(((-1.0)*x1738)));
sj6array[1]=IKsin(j6array[1]);
cj6array[1]=IKcos(j6array[1]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
if( j6array[1] > IKPI )
{
j6array[1]-=IK2PI;
}
else if( j6array[1] < -IKPI )
{ j6array[1]+=IK2PI;
}
j6valid[1] = true;
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[1];
IkReal x1740=IKcos(j6);
IkReal x1741=IKsin(j6);
IkReal x1742=((0.4)*x1741);
IkReal x1743=(r00*x1740);
IkReal x1744=((1.0)*x1741);
evalcond[0]=(((npy*x1741))+(((0.4)*r02*x1743))+((px*x1743))+(((-1.0)*py*r11*x1744))+(((0.4)*cj1*r20*x1740))+(((-1.0)*cj1*r21*x1742))+(((-1.0)*r01*r02*x1742))+(((-1.0)*npx*x1740))+((py*r10*x1740))+(((-1.0)*px*r01*x1744)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=IKabs(r02);
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j6eval[3];
r12=0;
npz=(pz*r22);
rxp2_0=((-1.0)*py*r22);
rxp2_2=0;
r02=0;
rxp2_1=(px*r22);
IkReal x1745=(r22*sj5);
IkReal x1746=((2.0)*sj1);
j6eval[0]=x1745;
j6eval[1]=((IKabs(((((-5.0)*rxp0_2))+(((-1.0)*cj0*r10*x1746))+((r00*sj0*x1746)))))+(IKabs(((((-5.0)*rxp1_2))+((r01*sj0*x1746))+(((-1.0)*cj0*r11*x1746))))));
j6eval[2]=IKsign(x1745);
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 || IKabs(j6eval[2]) < 0.0000010000000000 )
{
{
IkReal j6eval[3];
r12=0;
npz=(pz*r22);
rxp2_0=((-1.0)*py*r22);
rxp2_2=0;
r02=0;
rxp2_1=(px*r22);
IkReal x1747=((4.0)*npx);
IkReal x1748=(cj0*sj1);
IkReal x1749=(r01*sj5);
IkReal x1750=((5.0)*pp);
IkReal x1751=((10.0)*px);
IkReal x1752=(npy*r00*sj5);
IkReal x1753=((4.0)*cj5*pz*r22);
j6eval[0]=(x1752+(((-1.0)*npx*x1749)));
j6eval[1]=IKsign(((((-1.0)*x1747*x1749))+(((4.0)*x1752))));
j6eval[2]=((IKabs((((npy*x1751))+(((-4.0)*npy*x1748))+(((-1.0)*r01*x1750))+((r01*x1753)))))+(IKabs((((npx*x1751))+(((-1.0)*x1747*x1748))+(((-1.0)*r00*x1750))+((r00*x1753))))));
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 || IKabs(j6eval[2]) < 0.0000010000000000 )
{
{
IkReal j6eval[3];
r12=0;
npz=(pz*r22);
rxp2_0=((-1.0)*py*r22);
rxp2_2=0;
r02=0;
rxp2_1=(px*r22);
IkReal x1754=((10.0)*py);
IkReal x1755=((5.0)*pp);
IkReal x1756=((4.0)*sj0*sj1);
IkReal x1757=(npx*r11*sj5);
IkReal x1758=(npy*r10*sj5);
IkReal x1759=((4.0)*cj5*pz*r22);
j6eval[0]=(x1758+(((-1.0)*x1757)));
j6eval[1]=((IKabs((((npx*x1754))+(((-1.0)*r10*x1755))+(((-1.0)*npx*x1756))+((r10*x1759)))))+(IKabs(((((-1.0)*r11*x1755))+((npy*x1754))+(((-1.0)*npy*x1756))+((r11*x1759))))));
j6eval[2]=IKsign(((((-4.0)*x1757))+(((4.0)*x1758))));
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 || IKabs(j6eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j5))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j6eval[2];
r12=0;
npz=(pz*r22);
rxp2_0=((-1.0)*py*r22);
rxp2_2=0;
r02=0;
rxp2_1=(px*r22);
sj5=0;
cj5=1.0;
j5=0;
CheckValue<IkReal> x1764=IKPowWithIntegerCheck(r22,-1);
if(!x1764.valid){
continue;
}
IkReal x1760=x1764.value;
IkReal x1761=((20.0)*pz);
IkReal x1762=((8.0)*r22);
IkReal x1763=((25.0)*pp*x1760);
j6eval[0]=((IKabs((((r20*x1763))+(((-1.0)*r20*x1761))+(((-1.0)*r20*x1762)))))+(IKabs((((r21*x1763))+(((-1.0)*r21*x1762))+(((-1.0)*r21*x1761))))));
j6eval[1]=r22;
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 )
{
{
IkReal j6eval[2];
r12=0;
npz=(pz*r22);
rxp2_0=((-1.0)*py*r22);
rxp2_2=0;
r02=0;
rxp2_1=(px*r22);
sj5=0;
cj5=1.0;
j5=0;
CheckValue<IkReal> x1769=IKPowWithIntegerCheck(r22,-1);
if(!x1769.valid){
continue;
}
IkReal x1765=x1769.value;
IkReal x1766=((20.0)*pz);
IkReal x1767=((8.0)*r22);
IkReal x1768=((25.0)*pp*x1765);
j6eval[0]=((IKabs((((r20*x1768))+(((-1.0)*r20*x1767))+(((-1.0)*r20*x1766)))))+(IKabs((((r21*x1766))+((r21*x1767))+(((-1.0)*r21*x1768))))));
j6eval[1]=r22;
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
CheckValue<IkReal> x1774=IKPowWithIntegerCheck(r22,-1);
if(!x1774.valid){
continue;
}
IkReal x1770=x1774.value;
IkReal x1771=((0.4)*r22);
IkReal x1772=((1.25)*pp*x1770);
CheckValue<IkReal> x1775 = IKatan2WithCheck(IkReal((((px*r00))+(((-1.0)*r20*x1771))+(((-1.0)*npx))+((r20*x1772))+((py*r10)))),IkReal(((((-1.0)*px*r01))+(((-1.0)*r21*x1772))+npy+(((-1.0)*py*r11))+((r21*x1771)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1775.valid){
continue;
}
IkReal x1773=x1775.value;
j6array[0]=((-1.0)*x1773);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
j6array[1]=((3.14159265358979)+(((-1.0)*x1773)));
sj6array[1]=IKsin(j6array[1]);
cj6array[1]=IKcos(j6array[1]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
if( j6array[1] > IKPI )
{
j6array[1]-=IK2PI;
}
else if( j6array[1] < -IKPI )
{ j6array[1]+=IK2PI;
}
j6valid[1] = true;
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[1];
IkReal x1776=IKsin(j6);
IkReal x1777=IKcos(j6);
CheckValue<IkReal> x1783=IKPowWithIntegerCheck(r22,-1);
if(!x1783.valid){
continue;
}
IkReal x1778=x1783.value;
IkReal x1779=((0.4)*r22);
IkReal x1780=(r20*x1776);
IkReal x1781=(r21*x1777);
IkReal x1782=((1.25)*pp*x1778);
evalcond[0]=(((px*r00*x1776))+((py*r11*x1777))+((py*r10*x1776))+(((-1.0)*npx*x1776))+(((-1.0)*npy*x1777))+(((-1.0)*x1779*x1780))+(((-1.0)*x1779*x1781))+((x1780*x1782))+((x1781*x1782))+((px*r01*x1777)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
CheckValue<IkReal> x1788=IKPowWithIntegerCheck(r22,-1);
if(!x1788.valid){
continue;
}
IkReal x1784=x1788.value;
IkReal x1785=((0.4)*r22);
IkReal x1786=((1.25)*pp*x1784);
CheckValue<IkReal> x1789 = IKatan2WithCheck(IkReal((((r21*x1786))+((px*r01))+(((-1.0)*npy))+((py*r11))+(((-1.0)*r21*x1785)))),IkReal((((r20*x1786))+((px*r00))+(((-1.0)*npx))+(((-1.0)*r20*x1785))+((py*r10)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1789.valid){
continue;
}
IkReal x1787=x1789.value;
j6array[0]=((-1.0)*x1787);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
j6array[1]=((3.14159265358979)+(((-1.0)*x1787)));
sj6array[1]=IKsin(j6array[1]);
cj6array[1]=IKcos(j6array[1]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
if( j6array[1] > IKPI )
{
j6array[1]-=IK2PI;
}
else if( j6array[1] < -IKPI )
{ j6array[1]+=IK2PI;
}
j6valid[1] = true;
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[1];
IkReal x1790=IKcos(j6);
IkReal x1791=IKsin(j6);
CheckValue<IkReal> x1798=IKPowWithIntegerCheck(r22,-1);
if(!x1798.valid){
continue;
}
IkReal x1792=x1798.value;
IkReal x1793=((0.4)*r22);
IkReal x1794=(r21*x1791);
IkReal x1795=((1.25)*pp*x1792);
IkReal x1796=(r20*x1790);
IkReal x1797=((1.0)*x1791);
evalcond[0]=(((x1793*x1794))+(((-1.0)*x1793*x1796))+((px*r00*x1790))+(((-1.0)*py*r11*x1797))+((npy*x1791))+((x1795*x1796))+(((-1.0)*px*r01*x1797))+((py*r10*x1790))+(((-1.0)*npx*x1790))+(((-1.0)*x1794*x1795)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j5)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j6eval[2];
r12=0;
npz=(pz*r22);
rxp2_0=((-1.0)*py*r22);
rxp2_2=0;
r02=0;
rxp2_1=(px*r22);
sj5=0;
cj5=-1.0;
j5=3.14159265358979;
CheckValue<IkReal> x1803=IKPowWithIntegerCheck(r22,-1);
if(!x1803.valid){
continue;
}
IkReal x1799=x1803.value;
IkReal x1800=((20.0)*pz);
IkReal x1801=((8.0)*r22);
IkReal x1802=((25.0)*pp*x1799);
j6eval[0]=((IKabs(((((-1.0)*r21*x1802))+(((-1.0)*r21*x1800))+((r21*x1801)))))+(IKabs(((((-1.0)*r20*x1800))+(((-1.0)*r20*x1802))+((r20*x1801))))));
j6eval[1]=r22;
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 )
{
{
IkReal j6eval[2];
r12=0;
npz=(pz*r22);
rxp2_0=((-1.0)*py*r22);
rxp2_2=0;
r02=0;
rxp2_1=(px*r22);
sj5=0;
cj5=-1.0;
j5=3.14159265358979;
CheckValue<IkReal> x1808=IKPowWithIntegerCheck(r22,-1);
if(!x1808.valid){
continue;
}
IkReal x1804=x1808.value;
IkReal x1805=((20.0)*pz);
IkReal x1806=((8.0)*r22);
IkReal x1807=((25.0)*pp*x1804);
j6eval[0]=((IKabs(((((-1.0)*r21*x1806))+((r21*x1807))+((r21*x1805)))))+(IKabs(((((-1.0)*r20*x1805))+(((-1.0)*r20*x1807))+((r20*x1806))))));
j6eval[1]=r22;
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
CheckValue<IkReal> x1813=IKPowWithIntegerCheck(r22,-1);
if(!x1813.valid){
continue;
}
IkReal x1809=x1813.value;
IkReal x1810=((0.4)*r22);
IkReal x1811=((1.25)*pp*x1809);
CheckValue<IkReal> x1814 = IKatan2WithCheck(IkReal((((px*r00))+(((-1.0)*npx))+((r20*x1810))+((py*r10))+(((-1.0)*r20*x1811)))),IkReal(((((-1.0)*px*r01))+npy+(((-1.0)*py*r11))+((r21*x1811))+(((-1.0)*r21*x1810)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1814.valid){
continue;
}
IkReal x1812=x1814.value;
j6array[0]=((-1.0)*x1812);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
j6array[1]=((3.14159265358979)+(((-1.0)*x1812)));
sj6array[1]=IKsin(j6array[1]);
cj6array[1]=IKcos(j6array[1]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
if( j6array[1] > IKPI )
{
j6array[1]-=IK2PI;
}
else if( j6array[1] < -IKPI )
{ j6array[1]+=IK2PI;
}
j6valid[1] = true;
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[1];
IkReal x1815=IKsin(j6);
IkReal x1816=IKcos(j6);
CheckValue<IkReal> x1822=IKPowWithIntegerCheck(r22,-1);
if(!x1822.valid){
continue;
}
IkReal x1817=x1822.value;
IkReal x1818=((0.4)*r22);
IkReal x1819=(r20*x1815);
IkReal x1820=(r21*x1816);
IkReal x1821=((1.25)*pp*x1817);
evalcond[0]=(((x1818*x1819))+((py*r10*x1815))+(((-1.0)*npx*x1815))+((x1818*x1820))+(((-1.0)*x1819*x1821))+((px*r00*x1815))+((py*r11*x1816))+(((-1.0)*npy*x1816))+(((-1.0)*x1820*x1821))+((px*r01*x1816)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j6array[2], cj6array[2], sj6array[2];
bool j6valid[2]={false};
_nj6 = 2;
CheckValue<IkReal> x1827=IKPowWithIntegerCheck(r22,-1);
if(!x1827.valid){
continue;
}
IkReal x1823=x1827.value;
IkReal x1824=((0.4)*r22);
IkReal x1825=((1.25)*pp*x1823);
CheckValue<IkReal> x1828 = IKatan2WithCheck(IkReal((((px*r01))+(((-1.0)*npy))+((py*r11))+((r21*x1824))+(((-1.0)*r21*x1825)))),IkReal((((px*r00))+(((-1.0)*npx))+((py*r10))+(((-1.0)*r20*x1825))+((r20*x1824)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1828.valid){
continue;
}
IkReal x1826=x1828.value;
j6array[0]=((-1.0)*x1826);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
j6array[1]=((3.14159265358979)+(((-1.0)*x1826)));
sj6array[1]=IKsin(j6array[1]);
cj6array[1]=IKcos(j6array[1]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
if( j6array[1] > IKPI )
{
j6array[1]-=IK2PI;
}
else if( j6array[1] < -IKPI )
{ j6array[1]+=IK2PI;
}
j6valid[1] = true;
for(int ij6 = 0; ij6 < 2; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 2; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[1];
IkReal x1829=IKcos(j6);
IkReal x1830=IKsin(j6);
CheckValue<IkReal> x1837=IKPowWithIntegerCheck(r22,-1);
if(!x1837.valid){
continue;
}
IkReal x1831=x1837.value;
IkReal x1832=((0.4)*r22);
IkReal x1833=(r21*x1830);
IkReal x1834=((1.25)*pp*x1831);
IkReal x1835=(r20*x1829);
IkReal x1836=((1.0)*x1830);
evalcond[0]=((((-1.0)*x1834*x1835))+(((-1.0)*x1832*x1833))+(((-1.0)*px*r01*x1836))+((npy*x1830))+((px*r00*x1829))+((py*r10*x1829))+(((-1.0)*npx*x1829))+((x1832*x1835))+(((-1.0)*py*r11*x1836))+((x1833*x1834)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j6]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x1838=((10.0)*py);
IkReal x1839=((4.0)*sj5);
IkReal x1840=((5.0)*pp);
IkReal x1841=((4.0)*sj0*sj1);
IkReal x1842=((4.0)*cj5*pz*r22);
CheckValue<IkReal> x1843=IKPowWithIntegerCheck(IKsign(((((-1.0)*npx*r11*x1839))+((npy*r10*x1839)))),-1);
if(!x1843.valid){
continue;
}
CheckValue<IkReal> x1844 = IKatan2WithCheck(IkReal(((((-1.0)*npx*x1841))+((npx*x1838))+(((-1.0)*r10*x1840))+((r10*x1842)))),IkReal((((npy*x1838))+(((-1.0)*npy*x1841))+(((-1.0)*r11*x1840))+((r11*x1842)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1844.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1843.value)))+(x1844.value));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[6];
IkReal x1845=IKcos(j6);
IkReal x1846=IKsin(j6);
IkReal x1847=(r11*sj0);
IkReal x1848=(cj1*r20);
IkReal x1849=(cj0*r00);
IkReal x1850=(r10*sj0);
IkReal x1851=(cj0*r01);
IkReal x1852=((0.8)*sj5);
IkReal x1853=((1.0)*npx);
IkReal x1854=((0.4)*cj1);
IkReal x1855=(cj5*r22);
IkReal x1856=((0.4)*sj1);
IkReal x1857=((0.4)*sj5);
IkReal x1858=(npy*x1846);
IkReal x1859=((0.4)*x1845);
IkReal x1860=(r21*x1846);
IkReal x1861=((0.4)*x1846);
IkReal x1862=(x1846*x1856);
evalcond[0]=((((-1.0)*px))+((r00*x1845*x1857))+((cj0*x1856))+(((-1.0)*r01*x1846*x1857)));
evalcond[1]=((((-1.0)*py))+((sj0*x1856))+((r10*x1845*x1857))+(((-1.0)*r11*x1846*x1857)));
evalcond[2]=((((0.8)*pz*x1855))+(((-1.0)*x1852*x1858))+((npx*x1845*x1852))+(((-1.0)*pp)));
evalcond[3]=((((0.4)*x1855))+(((-1.0)*pz))+((r20*x1845*x1857))+x1854+(((-1.0)*x1857*x1860)));
evalcond[4]=(((x1848*x1861))+((x1850*x1862))+((r21*x1845*x1854))+((x1845*x1847*x1856))+((x1845*x1851*x1856))+(((-1.0)*npy*x1845))+(((-1.0)*x1846*x1853))+((x1849*x1862)));
evalcond[5]=((((-1.0)*x1845*x1853))+((x1848*x1859))+(((-1.0)*x1854*x1860))+(((-1.0)*x1851*x1862))+(((-1.0)*x1847*x1862))+((x1845*x1849*x1856))+((x1845*x1850*x1856))+x1858+x1857);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x1863=((4.0)*npx);
IkReal x1864=(cj0*sj1);
IkReal x1865=((4.0)*npy);
IkReal x1866=((5.0)*pp);
IkReal x1867=((10.0)*px);
IkReal x1868=((4.0)*cj5*pz*r22);
CheckValue<IkReal> x1869 = IKatan2WithCheck(IkReal(((((-1.0)*x1863*x1864))+((npx*x1867))+(((-1.0)*r00*x1866))+((r00*x1868)))),IkReal(((((-1.0)*x1864*x1865))+(((-1.0)*r01*x1866))+((npy*x1867))+((r01*x1868)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1869.valid){
continue;
}
CheckValue<IkReal> x1870=IKPowWithIntegerCheck(IKsign(((((-1.0)*r01*sj5*x1863))+((r00*sj5*x1865)))),-1);
if(!x1870.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(x1869.value)+(((1.5707963267949)*(x1870.value))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[6];
IkReal x1871=IKcos(j6);
IkReal x1872=IKsin(j6);
IkReal x1873=(r11*sj0);
IkReal x1874=(cj1*r20);
IkReal x1875=(cj0*r00);
IkReal x1876=(r10*sj0);
IkReal x1877=(cj0*r01);
IkReal x1878=((0.8)*sj5);
IkReal x1879=((1.0)*npx);
IkReal x1880=((0.4)*cj1);
IkReal x1881=(cj5*r22);
IkReal x1882=((0.4)*sj1);
IkReal x1883=((0.4)*sj5);
IkReal x1884=(npy*x1872);
IkReal x1885=((0.4)*x1871);
IkReal x1886=(r21*x1872);
IkReal x1887=((0.4)*x1872);
IkReal x1888=(x1872*x1882);
evalcond[0]=(((r00*x1871*x1883))+(((-1.0)*px))+(((-1.0)*r01*x1872*x1883))+((cj0*x1882)));
evalcond[1]=(((r10*x1871*x1883))+(((-1.0)*py))+(((-1.0)*r11*x1872*x1883))+((sj0*x1882)));
evalcond[2]=((((-1.0)*x1878*x1884))+(((-1.0)*pp))+(((0.8)*pz*x1881))+((npx*x1871*x1878)));
evalcond[3]=(((r20*x1871*x1883))+(((-1.0)*x1883*x1886))+(((-1.0)*pz))+x1880+(((0.4)*x1881)));
evalcond[4]=(((x1874*x1887))+(((-1.0)*x1872*x1879))+((x1876*x1888))+((x1875*x1888))+((x1871*x1877*x1882))+((r21*x1871*x1880))+(((-1.0)*npy*x1871))+((x1871*x1873*x1882)));
evalcond[5]=((((-1.0)*x1873*x1888))+((x1874*x1885))+(((-1.0)*x1880*x1886))+((x1871*x1876*x1882))+x1884+x1883+(((-1.0)*x1871*x1879))+((x1871*x1875*x1882))+(((-1.0)*x1877*x1888)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x1889=((2.0)*sj1);
CheckValue<IkReal> x1890=IKPowWithIntegerCheck(IKsign((r22*sj5)),-1);
if(!x1890.valid){
continue;
}
CheckValue<IkReal> x1891 = IKatan2WithCheck(IkReal((((r00*sj0*x1889))+(((-1.0)*cj0*r10*x1889))+(((-5.0)*rxp0_2)))),IkReal(((((-5.0)*rxp1_2))+(((-1.0)*cj0*r11*x1889))+((r01*sj0*x1889)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1891.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1890.value)))+(x1891.value));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[6];
IkReal x1892=IKcos(j6);
IkReal x1893=IKsin(j6);
IkReal x1894=(r11*sj0);
IkReal x1895=(cj1*r20);
IkReal x1896=(cj0*r00);
IkReal x1897=(r10*sj0);
IkReal x1898=(cj0*r01);
IkReal x1899=((0.8)*sj5);
IkReal x1900=((1.0)*npx);
IkReal x1901=((0.4)*cj1);
IkReal x1902=(cj5*r22);
IkReal x1903=((0.4)*sj1);
IkReal x1904=((0.4)*sj5);
IkReal x1905=(npy*x1893);
IkReal x1906=((0.4)*x1892);
IkReal x1907=(r21*x1893);
IkReal x1908=((0.4)*x1893);
IkReal x1909=(x1893*x1903);
evalcond[0]=((((-1.0)*r01*x1893*x1904))+(((-1.0)*px))+((cj0*x1903))+((r00*x1892*x1904)));
evalcond[1]=(((r10*x1892*x1904))+(((-1.0)*py))+((sj0*x1903))+(((-1.0)*r11*x1893*x1904)));
evalcond[2]=((((-1.0)*x1899*x1905))+((npx*x1892*x1899))+(((-1.0)*pp))+(((0.8)*pz*x1902)));
evalcond[3]=((((0.4)*x1902))+(((-1.0)*x1904*x1907))+(((-1.0)*pz))+x1901+((r20*x1892*x1904)));
evalcond[4]=(((r21*x1892*x1901))+(((-1.0)*x1893*x1900))+((x1892*x1898*x1903))+((x1895*x1908))+((x1892*x1894*x1903))+(((-1.0)*npy*x1892))+((x1897*x1909))+((x1896*x1909)));
evalcond[5]=((((-1.0)*x1901*x1907))+(((-1.0)*x1898*x1909))+(((-1.0)*x1892*x1900))+(((-1.0)*x1894*x1909))+((x1892*x1897*x1903))+x1904+x1905+((x1895*x1906))+((x1892*x1896*x1903)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j6]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x1910=((10.0)*py);
IkReal x1911=((5.0)*pp);
IkReal x1912=((4.0)*r10);
IkReal x1913=((4.0)*r11);
IkReal x1914=((4.0)*sj0*sj1);
IkReal x1915=(cj5*px*r02);
IkReal x1916=((4.0)*cj5*pz*r22);
CheckValue<IkReal> x1917=IKPowWithIntegerCheck(IKsign(((((-1.0)*npx*sj5*x1913))+((npy*sj5*x1912)))),-1);
if(!x1917.valid){
continue;
}
CheckValue<IkReal> x1918 = IKatan2WithCheck(IkReal((((x1912*x1915))+((npx*x1910))+((cj5*pz*r22*x1912))+(((-1.0)*r10*x1911))+(((-1.0)*npx*x1914)))),IkReal((((npy*x1910))+((x1913*x1915))+((cj5*pz*r22*x1913))+(((-1.0)*r11*x1911))+(((-1.0)*npy*x1914)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1918.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1917.value)))+(x1918.value));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[6];
IkReal x1919=IKcos(j6);
IkReal x1920=IKsin(j6);
IkReal x1921=(cj1*r20);
IkReal x1922=(cj0*sj1);
IkReal x1923=((0.8)*sj5);
IkReal x1924=((1.0)*npx);
IkReal x1925=((0.4)*cj1);
IkReal x1926=(cj5*r22);
IkReal x1927=(sj0*sj1);
IkReal x1928=(cj5*r02);
IkReal x1929=((0.4)*sj5);
IkReal x1930=(npy*x1920);
IkReal x1931=((0.4)*x1919);
IkReal x1932=(r21*x1920);
IkReal x1933=((0.4)*x1920);
IkReal x1934=(x1927*x1933);
evalcond[0]=((((-1.0)*r11*x1920*x1929))+(((0.4)*x1927))+(((-1.0)*py))+((r10*x1919*x1929)));
evalcond[1]=(((r20*x1919*x1929))+(((0.4)*x1926))+(((-1.0)*pz))+x1925+(((-1.0)*x1929*x1932)));
evalcond[2]=(((r00*x1919*x1929))+(((0.4)*x1928))+(((0.4)*x1922))+(((-1.0)*px))+(((-1.0)*r01*x1920*x1929)));
evalcond[3]=((((0.8)*px*x1928))+(((0.8)*pz*x1926))+(((-1.0)*x1923*x1930))+(((-1.0)*pp))+((npx*x1919*x1923)));
evalcond[4]=(((r11*x1927*x1931))+((x1921*x1933))+(((-1.0)*npy*x1919))+((r00*x1922*x1933))+((r21*x1919*x1925))+((r10*x1934))+((r01*x1922*x1931))+(((-1.0)*x1920*x1924)));
evalcond[5]=(((x1921*x1931))+((r10*x1927*x1931))+(((-1.0)*x1925*x1932))+x1929+x1930+(((-1.0)*r11*x1934))+((r00*x1922*x1931))+(((-1.0)*x1919*x1924))+(((-1.0)*r01*x1922*x1933)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x1935=((2.0)*r10);
IkReal x1936=(cj5*r02);
IkReal x1937=(cj0*sj1);
IkReal x1938=((2.0)*r11);
IkReal x1939=((2.0)*sj0*sj1);
CheckValue<IkReal> x1940=IKPowWithIntegerCheck(IKsign((r22*sj5)),-1);
if(!x1940.valid){
continue;
}
CheckValue<IkReal> x1941 = IKatan2WithCheck(IkReal((((r00*x1939))+(((-5.0)*rxp0_2))+(((-1.0)*x1935*x1936))+(((-1.0)*x1935*x1937)))),IkReal(((((-5.0)*rxp1_2))+(((-1.0)*x1937*x1938))+((r01*x1939))+(((-1.0)*x1936*x1938)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1941.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1940.value)))+(x1941.value));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[6];
IkReal x1942=IKcos(j6);
IkReal x1943=IKsin(j6);
IkReal x1944=(cj1*r20);
IkReal x1945=(cj0*sj1);
IkReal x1946=((0.8)*sj5);
IkReal x1947=((1.0)*npx);
IkReal x1948=((0.4)*cj1);
IkReal x1949=(cj5*r22);
IkReal x1950=(sj0*sj1);
IkReal x1951=(cj5*r02);
IkReal x1952=((0.4)*sj5);
IkReal x1953=(npy*x1943);
IkReal x1954=((0.4)*x1942);
IkReal x1955=(r21*x1943);
IkReal x1956=((0.4)*x1943);
IkReal x1957=(x1950*x1956);
evalcond[0]=(((r10*x1942*x1952))+(((-1.0)*py))+(((0.4)*x1950))+(((-1.0)*r11*x1943*x1952)));
evalcond[1]=((((-1.0)*x1952*x1955))+((r20*x1942*x1952))+(((-1.0)*pz))+x1948+(((0.4)*x1949)));
evalcond[2]=((((-1.0)*r01*x1943*x1952))+(((-1.0)*px))+(((0.4)*x1951))+(((0.4)*x1945))+((r00*x1942*x1952)));
evalcond[3]=((((0.8)*px*x1951))+(((0.8)*pz*x1949))+(((-1.0)*pp))+((npx*x1942*x1946))+(((-1.0)*x1946*x1953)));
evalcond[4]=(((r11*x1950*x1954))+((x1944*x1956))+(((-1.0)*x1943*x1947))+(((-1.0)*npy*x1942))+((r21*x1942*x1948))+((r10*x1957))+((r00*x1945*x1956))+((r01*x1945*x1954)));
evalcond[5]=((((-1.0)*x1948*x1955))+((x1944*x1954))+(((-1.0)*x1942*x1947))+x1953+x1952+((r00*x1945*x1954))+((r10*x1950*x1954))+(((-1.0)*r11*x1957))+(((-1.0)*r01*x1945*x1956)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x1958=((2.0)*cj1);
IkReal x1959=((2.0)*sj0*sj1);
IkReal x1960=((2.0)*cj5*r22);
CheckValue<IkReal> x1961=IKPowWithIntegerCheck(IKsign((r02*sj5)),-1);
if(!x1961.valid){
continue;
}
CheckValue<IkReal> x1962 = IKatan2WithCheck(IkReal((((r10*x1960))+((r10*x1958))+(((-5.0)*rxp0_0))+(((-1.0)*r20*x1959)))),IkReal(((((-5.0)*rxp1_0))+((r11*x1958))+((r11*x1960))+(((-1.0)*r21*x1959)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1962.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1961.value)))+(x1962.value));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[6];
IkReal x1963=IKcos(j6);
IkReal x1964=IKsin(j6);
IkReal x1965=(cj1*r20);
IkReal x1966=(cj0*sj1);
IkReal x1967=((0.8)*sj5);
IkReal x1968=((1.0)*npx);
IkReal x1969=((0.4)*cj1);
IkReal x1970=(cj5*r22);
IkReal x1971=(sj0*sj1);
IkReal x1972=(cj5*r02);
IkReal x1973=((0.4)*sj5);
IkReal x1974=(npy*x1964);
IkReal x1975=((0.4)*x1963);
IkReal x1976=(r21*x1964);
IkReal x1977=((0.4)*x1964);
IkReal x1978=(x1971*x1977);
evalcond[0]=((((-1.0)*r11*x1964*x1973))+(((-1.0)*py))+((r10*x1963*x1973))+(((0.4)*x1971)));
evalcond[1]=(((r20*x1963*x1973))+(((-1.0)*x1973*x1976))+(((-1.0)*pz))+x1969+(((0.4)*x1970)));
evalcond[2]=((((-1.0)*px))+((r00*x1963*x1973))+(((-1.0)*r01*x1964*x1973))+(((0.4)*x1966))+(((0.4)*x1972)));
evalcond[3]=((((0.8)*px*x1972))+(((0.8)*pz*x1970))+(((-1.0)*pp))+(((-1.0)*x1967*x1974))+((npx*x1963*x1967)));
evalcond[4]=(((r00*x1966*x1977))+(((-1.0)*npy*x1963))+(((-1.0)*x1964*x1968))+((r01*x1966*x1975))+((r10*x1978))+((r21*x1963*x1969))+((x1965*x1977))+((r11*x1971*x1975)));
evalcond[5]=(((r00*x1966*x1975))+(((-1.0)*r01*x1966*x1977))+x1974+x1973+((x1965*x1975))+(((-1.0)*x1963*x1968))+((r10*x1971*x1975))+(((-1.0)*x1969*x1976))+(((-1.0)*r11*x1978)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j6]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x1979=((4.0)*npx);
IkReal x1980=(cj0*sj1);
IkReal x1981=(cj5*r02);
IkReal x1982=((4.0)*npy);
IkReal x1983=((5.0)*pp);
IkReal x1984=((10.0)*px);
IkReal x1985=((4.0)*cj5*npz);
CheckValue<IkReal> x1986 = IKatan2WithCheck(IkReal((((npx*x1984))+(((-1.0)*x1979*x1981))+(((-1.0)*x1979*x1980))+((r00*x1985))+(((-1.0)*r00*x1983)))),IkReal(((((-1.0)*x1981*x1982))+(((-1.0)*x1980*x1982))+((r01*x1985))+((npy*x1984))+(((-1.0)*r01*x1983)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1986.valid){
continue;
}
CheckValue<IkReal> x1987=IKPowWithIntegerCheck(IKsign((((r00*sj5*x1982))+(((-1.0)*r01*sj5*x1979)))),-1);
if(!x1987.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(x1986.value)+(((1.5707963267949)*(x1987.value))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[6];
IkReal x1988=IKcos(j6);
IkReal x1989=IKsin(j6);
IkReal x1990=(sj0*sj1);
IkReal x1991=(cj1*r20);
IkReal x1992=(cj0*sj1);
IkReal x1993=((0.8)*sj5);
IkReal x1994=((1.0)*npx);
IkReal x1995=(cj1*r21);
IkReal x1996=((0.4)*cj5);
IkReal x1997=(npy*x1989);
IkReal x1998=((0.4)*x1989);
IkReal x1999=((0.4)*x1988);
evalcond[0]=((((-1.0)*x1993*x1997))+((npx*x1988*x1993))+(((-1.0)*pp))+(((0.8)*cj5*npz)));
evalcond[1]=((((-1.0)*r21*sj5*x1998))+((r20*sj5*x1999))+(((0.4)*cj1))+(((-1.0)*pz))+((r22*x1996)));
evalcond[2]=(((r00*sj5*x1999))+(((-1.0)*r01*sj5*x1998))+((r02*x1996))+(((-1.0)*px))+(((0.4)*x1992)));
evalcond[3]=(((r12*x1996))+((r10*sj5*x1999))+(((-1.0)*py))+(((0.4)*x1990))+(((-1.0)*r11*sj5*x1998)));
evalcond[4]=(((r10*x1990*x1998))+(((-1.0)*npy*x1988))+((x1991*x1998))+((r11*x1990*x1999))+((x1995*x1999))+(((-1.0)*x1989*x1994))+((r00*x1992*x1998))+((r01*x1992*x1999)));
evalcond[5]=((((-1.0)*r01*x1992*x1998))+((r10*x1990*x1999))+((x1991*x1999))+((r00*x1992*x1999))+x1997+(((0.4)*sj5))+(((-1.0)*x1995*x1998))+(((-1.0)*r11*x1990*x1998))+(((-1.0)*x1988*x1994)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x2000=((5.0)*pp);
IkReal x2001=((4.0)*npy);
IkReal x2002=(cj5*r22);
IkReal x2003=((4.0)*npx);
IkReal x2004=((10.0)*pz);
IkReal x2005=((4.0)*cj5*npz);
CheckValue<IkReal> x2006 = IKatan2WithCheck(IkReal(((((-1.0)*x2002*x2003))+(((-1.0)*cj1*x2003))+((r20*x2005))+((npx*x2004))+(((-1.0)*r20*x2000)))),IkReal((((r21*x2005))+((npy*x2004))+(((-1.0)*x2001*x2002))+(((-1.0)*cj1*x2001))+(((-1.0)*r21*x2000)))),IKFAST_ATAN2_MAGTHRESH);
if(!x2006.valid){
continue;
}
CheckValue<IkReal> x2007=IKPowWithIntegerCheck(IKsign((((r20*sj5*x2001))+(((-1.0)*r21*sj5*x2003)))),-1);
if(!x2007.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(x2006.value)+(((1.5707963267949)*(x2007.value))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[6];
IkReal x2008=IKcos(j6);
IkReal x2009=IKsin(j6);
IkReal x2010=(sj0*sj1);
IkReal x2011=(cj1*r20);
IkReal x2012=(cj0*sj1);
IkReal x2013=((0.8)*sj5);
IkReal x2014=((1.0)*npx);
IkReal x2015=(cj1*r21);
IkReal x2016=((0.4)*cj5);
IkReal x2017=(npy*x2009);
IkReal x2018=((0.4)*x2009);
IkReal x2019=((0.4)*x2008);
evalcond[0]=((((-1.0)*x2013*x2017))+(((-1.0)*pp))+((npx*x2008*x2013))+(((0.8)*cj5*npz)));
evalcond[1]=(((r20*sj5*x2019))+(((0.4)*cj1))+((r22*x2016))+(((-1.0)*r21*sj5*x2018))+(((-1.0)*pz)));
evalcond[2]=(((r00*sj5*x2019))+(((0.4)*x2012))+(((-1.0)*px))+(((-1.0)*r01*sj5*x2018))+((r02*x2016)));
evalcond[3]=(((r10*sj5*x2019))+(((-1.0)*r11*sj5*x2018))+(((0.4)*x2010))+(((-1.0)*py))+((r12*x2016)));
evalcond[4]=(((r11*x2010*x2019))+(((-1.0)*x2009*x2014))+((x2015*x2019))+(((-1.0)*npy*x2008))+((x2011*x2018))+((r01*x2012*x2019))+((r10*x2010*x2018))+((r00*x2012*x2018)));
evalcond[5]=((((-1.0)*x2008*x2014))+x2017+(((-1.0)*x2015*x2018))+((x2011*x2019))+(((-1.0)*r01*x2012*x2018))+(((0.4)*sj5))+((r10*x2010*x2019))+(((-1.0)*r11*x2010*x2018))+((r00*x2012*x2019)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x2020=((2.0)*cj5);
IkReal x2021=((2.0)*cj1);
IkReal x2022=((2.0)*cj0*sj1);
CheckValue<IkReal> x2023=IKPowWithIntegerCheck(IKsign((r12*sj5)),-1);
if(!x2023.valid){
continue;
}
CheckValue<IkReal> x2024 = IKatan2WithCheck(IkReal((((r00*x2021))+((r11*x2020))+(((5.0)*rxp0_1))+(((-1.0)*r20*x2022)))),IkReal((((r01*x2021))+(((-1.0)*r10*x2020))+(((5.0)*rxp1_1))+(((-1.0)*r21*x2022)))),IKFAST_ATAN2_MAGTHRESH);
if(!x2024.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(((-1.5707963267949)*(x2023.value)))+(x2024.value));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[6];
IkReal x2025=IKcos(j6);
IkReal x2026=IKsin(j6);
IkReal x2027=(sj0*sj1);
IkReal x2028=(cj1*r20);
IkReal x2029=(cj0*sj1);
IkReal x2030=((0.8)*sj5);
IkReal x2031=((1.0)*npx);
IkReal x2032=(cj1*r21);
IkReal x2033=((0.4)*cj5);
IkReal x2034=(npy*x2026);
IkReal x2035=((0.4)*x2026);
IkReal x2036=((0.4)*x2025);
evalcond[0]=(((npx*x2025*x2030))+(((-1.0)*pp))+(((-1.0)*x2030*x2034))+(((0.8)*cj5*npz)));
evalcond[1]=(((r22*x2033))+(((0.4)*cj1))+((r20*sj5*x2036))+(((-1.0)*pz))+(((-1.0)*r21*sj5*x2035)));
evalcond[2]=(((r02*x2033))+(((-1.0)*px))+((r00*sj5*x2036))+(((0.4)*x2029))+(((-1.0)*r01*sj5*x2035)));
evalcond[3]=(((r12*x2033))+((r10*sj5*x2036))+(((-1.0)*r11*sj5*x2035))+(((-1.0)*py))+(((0.4)*x2027)));
evalcond[4]=(((r11*x2027*x2036))+((r10*x2027*x2035))+(((-1.0)*npy*x2025))+((x2032*x2036))+((r01*x2029*x2036))+((x2028*x2035))+(((-1.0)*x2026*x2031))+((r00*x2029*x2035)));
evalcond[5]=(((r10*x2027*x2036))+x2034+(((-1.0)*r01*x2029*x2035))+((x2028*x2036))+(((-1.0)*r11*x2027*x2035))+(((0.4)*sj5))+(((-1.0)*x2025*x2031))+(((-1.0)*x2032*x2035))+((r00*x2029*x2036)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
}
}
}
}
}
}
return solutions.GetNumSolutions()>0;
}
inline void rotationfunction0(IkSolutionListBase<IkReal>& solutions) {
for(int rotationiter = 0; rotationiter < 1; ++rotationiter) {
IkReal x243=((1.0)*cj0);
IkReal x244=((1.0)*sj6);
IkReal x245=((1.0)*cj5);
IkReal x246=(cj0*sj1);
IkReal x247=((1.0)*cj6);
IkReal x248=(r10*sj0);
IkReal x249=((1.0)*cj1);
IkReal x250=(r12*sj0);
IkReal x251=(r11*sj0);
IkReal x252=(((r00*sj0))+(((-1.0)*r10*x243)));
IkReal x253=(((r01*sj0))+(((-1.0)*r11*x243)));
IkReal x254=((((-1.0)*r12*x243))+((r02*sj0)));
IkReal x255=((1.0)*x253);
IkReal x256=(((sj1*x251))+((cj1*r21))+((r01*x246)));
IkReal x257=(((cj1*r20))+((r00*x246))+((sj1*x248)));
IkReal x258=(((r02*x246))+((sj1*x250))+((cj1*r22)));
IkReal x259=(((r21*sj1))+(((-1.0)*cj1*r01*x243))+(((-1.0)*x249*x251)));
IkReal x260=((((-1.0)*x248*x249))+((r20*sj1))+(((-1.0)*cj1*r00*x243)));
IkReal x261=(((r22*sj1))+(((-1.0)*x249*x250))+(((-1.0)*cj1*r02*x243)));
IkReal x262=(((cj6*x252))+(((-1.0)*x244*x253)));
IkReal x263=(((cj6*x257))+(((-1.0)*x244*x256)));
IkReal x264=((((-1.0)*x244*x259))+((cj6*x260)));
new_r00=(((sj5*x261))+(((-1.0)*x245*x264)));
new_r01=((((-1.0)*x247*x259))+(((-1.0)*x244*x260)));
new_r02=(((cj5*x261))+((sj5*x264)));
new_r10=(((sj5*x254))+(((-1.0)*x245*x262)));
new_r11=((((-1.0)*x244*x252))+(((-1.0)*x247*x253)));
new_r12=(((sj5*x262))+((cj5*x254)));
new_r20=(((sj5*x258))+(((-1.0)*x245*x263)));
new_r21=((((-1.0)*x244*x257))+(((-1.0)*x247*x256)));
new_r22=(((sj5*x263))+((cj5*x258)));
{
IkReal j3array[2], cj3array[2], sj3array[2];
bool j3valid[2]={false};
_nj3 = 2;
cj3array[0]=new_r22;
if( cj3array[0] >= -1-IKFAST_SINCOS_THRESH && cj3array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j3valid[0] = j3valid[1] = true;
j3array[0] = IKacos(cj3array[0]);
sj3array[0] = IKsin(j3array[0]);
cj3array[1] = cj3array[0];
j3array[1] = -j3array[0];
sj3array[1] = -sj3array[0];
}
else if( isnan(cj3array[0]) )
{
// probably any value will work
j3valid[0] = true;
cj3array[0] = 1; sj3array[0] = 0; j3array[0] = 0;
}
for(int ij3 = 0; ij3 < 2; ++ij3)
{
if( !j3valid[ij3] )
{
continue;
}
_ij3[0] = ij3; _ij3[1] = -1;
for(int iij3 = ij3+1; iij3 < 2; ++iij3)
{
if( j3valid[iij3] && IKabs(cj3array[ij3]-cj3array[iij3]) < IKFAST_SOLUTION_THRESH && IKabs(sj3array[ij3]-sj3array[iij3]) < IKFAST_SOLUTION_THRESH )
{
j3valid[iij3]=false; _ij3[1] = iij3; break;
}
}
j3 = j3array[ij3]; cj3 = cj3array[ij3]; sj3 = sj3array[ij3];
{
IkReal j2eval[3];
j2eval[0]=sj3;
j2eval[1]=((IKabs(new_r12))+(IKabs(new_r02)));
j2eval[2]=IKsign(sj3);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j4eval[3];
j4eval[0]=sj3;
j4eval[1]=IKsign(sj3);
j4eval[2]=((IKabs(new_r20))+(IKabs(new_r21)));
if( IKabs(j4eval[0]) < 0.0000010000000000 || IKabs(j4eval[1]) < 0.0000010000000000 || IKabs(j4eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[2];
j2eval[0]=new_r12;
j2eval[1]=sj3;
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[5];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=new_r21;
evalcond[2]=new_r02;
evalcond[3]=new_r12;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
IkReal j4mul = 1;
j4=0;
j2mul=-1.0;
if( IKabs(((-1.0)*new_r10)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r00)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r10))+IKsqr(((-1.0)*new_r00))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2=IKatan2(((-1.0)*new_r10), ((-1.0)*new_r00));
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].fmul = j2mul;
vinfos[2].freeind = 0;
vinfos[2].maxsolutions = 0;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].fmul = j4mul;
vinfos[4].freeind = 0;
vinfos[4].maxsolutions = 0;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(1);
vfree[0] = 4;
solutions.AddSolution(vinfos,vfree);
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j3)))), 6.28318530717959)));
evalcond[1]=new_r21;
evalcond[2]=new_r02;
evalcond[3]=new_r12;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
IkReal j4mul = 1;
j4=0;
j2mul=1.0;
if( IKabs(new_r10) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r11)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r10)+IKsqr(((-1.0)*new_r11))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2=IKatan2(new_r10, ((-1.0)*new_r11));
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].fmul = j2mul;
vinfos[2].freeind = 0;
vinfos[2].maxsolutions = 0;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].fmul = j4mul;
vinfos[4].freeind = 0;
vinfos[4].maxsolutions = 0;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(1);
vfree[0] = 4;
solutions.AddSolution(vinfos,vfree);
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r12))+(IKabs(new_r02)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
IkReal x265=new_r22*new_r22;
IkReal x266=((16.0)*new_r10);
IkReal x267=((16.0)*new_r01);
IkReal x268=((16.0)*new_r22);
IkReal x269=((8.0)*new_r11);
IkReal x270=((8.0)*new_r00);
IkReal x271=(x265*x266);
IkReal x272=(x265*x267);
j2eval[0]=((IKabs((((new_r22*x269))+(((-1.0)*x270)))))+(IKabs(((((-1.0)*new_r22*x270))+((x265*x269)))))+(IKabs((x267+(((-1.0)*x272)))))+(IKabs((x271+(((-1.0)*x266)))))+(IKabs((x272+(((-1.0)*x267)))))+(IKabs((x266+(((-1.0)*x271)))))+(IKabs(((((32.0)*new_r11))+(((-1.0)*new_r00*x268))+(((-16.0)*new_r11*x265)))))+(IKabs(((((-32.0)*new_r00*x265))+(((16.0)*new_r00))+((new_r11*x268))))));
if( IKabs(j2eval[0]) < 0.0000000010000000 )
{
continue; // no branches [j2, j4]
} else
{
IkReal op[4+1], zeror[4];
int numroots;
IkReal j2evalpoly[1];
IkReal x273=new_r22*new_r22;
IkReal x274=((16.0)*new_r10);
IkReal x275=(new_r11*new_r22);
IkReal x276=(x273*x274);
IkReal x277=((((8.0)*x275))+(((-8.0)*new_r00)));
op[0]=x277;
op[1]=(x274+(((-1.0)*x276)));
op[2]=((((-32.0)*new_r00*x273))+(((16.0)*new_r00))+(((16.0)*x275)));
op[3]=(x276+(((-1.0)*x274)));
op[4]=x277;
polyroots4(op,zeror,numroots);
IkReal j2array[4], cj2array[4], sj2array[4], tempj2array[1];
int numsolutions = 0;
for(int ij2 = 0; ij2 < numroots; ++ij2)
{
IkReal htj2 = zeror[ij2];
tempj2array[0]=((2.0)*(atan(htj2)));
for(int kj2 = 0; kj2 < 1; ++kj2)
{
j2array[numsolutions] = tempj2array[kj2];
if( j2array[numsolutions] > IKPI )
{
j2array[numsolutions]-=IK2PI;
}
else if( j2array[numsolutions] < -IKPI )
{
j2array[numsolutions]+=IK2PI;
}
sj2array[numsolutions] = IKsin(j2array[numsolutions]);
cj2array[numsolutions] = IKcos(j2array[numsolutions]);
numsolutions++;
}
}
bool j2valid[4]={true,true,true,true};
_nj2 = 4;
for(int ij2 = 0; ij2 < numsolutions; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
htj2 = IKtan(j2/2);
IkReal x278=((16.0)*new_r01);
IkReal x279=new_r22*new_r22;
IkReal x280=(new_r00*new_r22);
IkReal x281=((8.0)*x280);
IkReal x282=(new_r11*x279);
IkReal x283=(x278*x279);
IkReal x284=((8.0)*x282);
j2evalpoly[0]=((((htj2*htj2)*(((((32.0)*new_r11))+(((-16.0)*x282))+(((-16.0)*x280))))))+(((htj2*htj2*htj2)*((x283+(((-1.0)*x278))))))+x284+((htj2*((x278+(((-1.0)*x283))))))+(((-1.0)*x281))+(((htj2*htj2*htj2*htj2)*((x284+(((-1.0)*x281)))))));
if( IKabs(j2evalpoly[0]) > 0.0000000010000000 )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < numsolutions; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
{
IkReal j4eval[3];
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
IkReal x285=cj2*cj2;
IkReal x286=new_r22*new_r22;
IkReal x287=(new_r22*sj2);
IkReal x288=((1.0)*new_r10);
IkReal x289=((((-1.0)*x285*x286))+x286+x285);
j4eval[0]=x289;
j4eval[1]=((IKabs(((((-1.0)*x287*x288))+(((-1.0)*cj2*new_r11)))))+(IKabs(((((-1.0)*cj2*x288))+((new_r11*x287))))));
j4eval[2]=IKsign(x289);
if( IKabs(j4eval[0]) < 0.0000010000000000 || IKabs(j4eval[1]) < 0.0000010000000000 || IKabs(j4eval[2]) < 0.0000010000000000 )
{
{
IkReal j4eval[1];
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
j4eval[0]=new_r22;
if( IKabs(j4eval[0]) < 0.0000010000000000 )
{
{
IkReal j4eval[1];
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
j4eval[0]=cj2;
if( IKabs(j4eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j2)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(new_r00) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r01) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r00)+IKsqr(new_r01)-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(new_r00, new_r01);
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[4];
IkReal x290=IKsin(j4);
IkReal x291=IKcos(j4);
evalcond[0]=x290;
evalcond[1]=((-1.0)*x291);
evalcond[2]=(x290+(((-1.0)*new_r00)));
evalcond[3]=(x291+(((-1.0)*new_r01)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j2)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(((-1.0)*new_r00)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r01)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r00))+IKsqr(((-1.0)*new_r01))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r00), ((-1.0)*new_r01));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[4];
IkReal x292=IKsin(j4);
IkReal x293=IKcos(j4);
evalcond[0]=x292;
evalcond[1]=(x292+new_r00);
evalcond[2]=(x293+new_r01);
evalcond[3]=((-1.0)*x293);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x294=new_r22*new_r22;
CheckValue<IkReal> x295=IKPowWithIntegerCheck(((1.0)+(((-1.0)*x294))),-1);
if(!x295.valid){
continue;
}
if((((-1.0)*x294*(x295.value))) < -0.00001)
continue;
IkReal gconst62=IKsqrt(((-1.0)*x294*(x295.value)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs((cj2+(((-1.0)*gconst62)))))+(IKabs(((-1.0)+(IKsign(sj2)))))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4eval[1];
IkReal x296=new_r22*new_r22;
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
if((((1.0)+(((-1.0)*(gconst62*gconst62))))) < -0.00001)
continue;
sj2=IKsqrt(((1.0)+(((-1.0)*(gconst62*gconst62)))));
cj2=gconst62;
if( (gconst62) < -1-IKFAST_SINCOS_THRESH || (gconst62) > 1+IKFAST_SINCOS_THRESH )
continue;
j2=IKacos(gconst62);
CheckValue<IkReal> x297=IKPowWithIntegerCheck(((1.0)+(((-1.0)*x296))),-1);
if(!x297.valid){
continue;
}
if((((-1.0)*x296*(x297.value))) < -0.00001)
continue;
IkReal gconst62=IKsqrt(((-1.0)*x296*(x297.value)));
j4eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j4eval[0]) < 0.0000010000000000 )
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x298=IKPowWithIntegerCheck(gconst62,-1);
if(!x298.valid){
continue;
}
if((((1.0)+(((-1.0)*(gconst62*gconst62))))) < -0.00001)
continue;
if( IKabs(((-1.0)*new_r10*(x298.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*gconst62*new_r11))+((new_r01*(IKsqrt(((1.0)+(((-1.0)*(gconst62*gconst62)))))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r10*(x298.value)))+IKsqr(((((-1.0)*gconst62*new_r11))+((new_r01*(IKsqrt(((1.0)+(((-1.0)*(gconst62*gconst62))))))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r10*(x298.value)), ((((-1.0)*gconst62*new_r11))+((new_r01*(IKsqrt(((1.0)+(((-1.0)*(gconst62*gconst62))))))))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x299=IKsin(j4);
IkReal x300=IKcos(j4);
if((((1.0)+(((-1.0)*(gconst62*gconst62))))) < -0.00001)
continue;
IkReal x301=IKsqrt(((1.0)+(((-1.0)*(gconst62*gconst62)))));
IkReal x302=((1.0)*x301);
evalcond[0]=x299;
evalcond[1]=((-1.0)*x300);
evalcond[2]=(((gconst62*x299))+new_r10);
evalcond[3]=(((gconst62*x300))+new_r11);
evalcond[4]=((((-1.0)*x299*x302))+new_r00);
evalcond[5]=(new_r01+(((-1.0)*x300*x302)));
evalcond[6]=(((gconst62*new_r10))+x299+(((-1.0)*new_r00*x302)));
evalcond[7]=(((gconst62*new_r11))+x300+(((-1.0)*new_r01*x302)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x303 = IKatan2WithCheck(IkReal(((-1.0)*new_r10)),IkReal(((-1.0)*new_r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x303.valid){
continue;
}
CheckValue<IkReal> x304=IKPowWithIntegerCheck(IKsign(gconst62),-1);
if(!x304.valid){
continue;
}
j4array[0]=((-1.5707963267949)+(x303.value)+(((1.5707963267949)*(x304.value))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x305=IKsin(j4);
IkReal x306=IKcos(j4);
if((((1.0)+(((-1.0)*(gconst62*gconst62))))) < -0.00001)
continue;
IkReal x307=IKsqrt(((1.0)+(((-1.0)*(gconst62*gconst62)))));
IkReal x308=((1.0)*x307);
evalcond[0]=x305;
evalcond[1]=((-1.0)*x306);
evalcond[2]=(((gconst62*x305))+new_r10);
evalcond[3]=(((gconst62*x306))+new_r11);
evalcond[4]=((((-1.0)*x305*x308))+new_r00);
evalcond[5]=((((-1.0)*x306*x308))+new_r01);
evalcond[6]=(((gconst62*new_r10))+x305+(((-1.0)*new_r00*x308)));
evalcond[7]=(((gconst62*new_r11))+x306+(((-1.0)*new_r01*x308)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x309=new_r22*new_r22;
CheckValue<IkReal> x310=IKPowWithIntegerCheck(((1.0)+(((-1.0)*x309))),-1);
if(!x310.valid){
continue;
}
if((((-1.0)*x309*(x310.value))) < -0.00001)
continue;
IkReal gconst62=IKsqrt(((-1.0)*x309*(x310.value)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs((cj2+(((-1.0)*gconst62)))))+(IKabs(((1.0)+(IKsign(sj2)))))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4eval[1];
IkReal x311=new_r22*new_r22;
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
if((((1.0)+(((-1.0)*(gconst62*gconst62))))) < -0.00001)
continue;
sj2=((-1.0)*(IKsqrt(((1.0)+(((-1.0)*(gconst62*gconst62)))))));
cj2=gconst62;
if( (gconst62) < -1-IKFAST_SINCOS_THRESH || (gconst62) > 1+IKFAST_SINCOS_THRESH )
continue;
j2=((-1.0)*(IKacos(gconst62)));
CheckValue<IkReal> x312=IKPowWithIntegerCheck(((1.0)+(((-1.0)*x311))),-1);
if(!x312.valid){
continue;
}
if((((-1.0)*x311*(x312.value))) < -0.00001)
continue;
IkReal gconst62=IKsqrt(((-1.0)*x311*(x312.value)));
j4eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j4eval[0]) < 0.0000010000000000 )
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x313=IKPowWithIntegerCheck(gconst62,-1);
if(!x313.valid){
continue;
}
if((((1.0)+(((-1.0)*(gconst62*gconst62))))) < -0.00001)
continue;
if( IKabs(((-1.0)*new_r10*(x313.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*gconst62*new_r11))+(((-1.0)*new_r01*(IKsqrt(((1.0)+(((-1.0)*(gconst62*gconst62)))))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r10*(x313.value)))+IKsqr(((((-1.0)*gconst62*new_r11))+(((-1.0)*new_r01*(IKsqrt(((1.0)+(((-1.0)*(gconst62*gconst62))))))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r10*(x313.value)), ((((-1.0)*gconst62*new_r11))+(((-1.0)*new_r01*(IKsqrt(((1.0)+(((-1.0)*(gconst62*gconst62))))))))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x314=IKsin(j4);
IkReal x315=IKcos(j4);
if((((1.0)+(((-1.0)*(gconst62*gconst62))))) < -0.00001)
continue;
IkReal x316=IKsqrt(((1.0)+(((-1.0)*(gconst62*gconst62)))));
evalcond[0]=x314;
evalcond[1]=((-1.0)*x315);
evalcond[2]=(((gconst62*x314))+new_r10);
evalcond[3]=(((gconst62*x315))+new_r11);
evalcond[4]=(new_r00+((x314*x316)));
evalcond[5]=(((x315*x316))+new_r01);
evalcond[6]=(((gconst62*new_r10))+((new_r00*x316))+x314);
evalcond[7]=(((gconst62*new_r11))+((new_r01*x316))+x315);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x317 = IKatan2WithCheck(IkReal(((-1.0)*new_r10)),IkReal(((-1.0)*new_r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x317.valid){
continue;
}
CheckValue<IkReal> x318=IKPowWithIntegerCheck(IKsign(gconst62),-1);
if(!x318.valid){
continue;
}
j4array[0]=((-1.5707963267949)+(x317.value)+(((1.5707963267949)*(x318.value))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x319=IKsin(j4);
IkReal x320=IKcos(j4);
if((((1.0)+(((-1.0)*(gconst62*gconst62))))) < -0.00001)
continue;
IkReal x321=IKsqrt(((1.0)+(((-1.0)*(gconst62*gconst62)))));
evalcond[0]=x319;
evalcond[1]=((-1.0)*x320);
evalcond[2]=(((gconst62*x319))+new_r10);
evalcond[3]=(((gconst62*x320))+new_r11);
evalcond[4]=(new_r00+((x319*x321)));
evalcond[5]=(((x320*x321))+new_r01);
evalcond[6]=(((new_r00*x321))+((gconst62*new_r10))+x319);
evalcond[7]=(((new_r01*x321))+((gconst62*new_r11))+x320);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x322=new_r22*new_r22;
CheckValue<IkReal> x323=IKPowWithIntegerCheck(((1.0)+(((-1.0)*x322))),-1);
if(!x323.valid){
continue;
}
if((((-1.0)*x322*(x323.value))) < -0.00001)
continue;
IkReal gconst63=((-1.0)*(IKsqrt(((-1.0)*x322*(x323.value)))));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs((cj2+(((-1.0)*gconst63)))))+(IKabs(((-1.0)+(IKsign(sj2)))))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4eval[1];
IkReal x324=new_r22*new_r22;
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
if((((1.0)+(((-1.0)*(gconst63*gconst63))))) < -0.00001)
continue;
sj2=IKsqrt(((1.0)+(((-1.0)*(gconst63*gconst63)))));
cj2=gconst63;
if( (gconst63) < -1-IKFAST_SINCOS_THRESH || (gconst63) > 1+IKFAST_SINCOS_THRESH )
continue;
j2=IKacos(gconst63);
CheckValue<IkReal> x325=IKPowWithIntegerCheck(((1.0)+(((-1.0)*x324))),-1);
if(!x325.valid){
continue;
}
if((((-1.0)*x324*(x325.value))) < -0.00001)
continue;
IkReal gconst63=((-1.0)*(IKsqrt(((-1.0)*x324*(x325.value)))));
j4eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j4eval[0]) < 0.0000010000000000 )
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x326=IKPowWithIntegerCheck(gconst63,-1);
if(!x326.valid){
continue;
}
if((((1.0)+(((-1.0)*(gconst63*gconst63))))) < -0.00001)
continue;
if( IKabs(((-1.0)*new_r10*(x326.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs((((new_r01*(IKsqrt(((1.0)+(((-1.0)*(gconst63*gconst63))))))))+(((-1.0)*gconst63*new_r11)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r10*(x326.value)))+IKsqr((((new_r01*(IKsqrt(((1.0)+(((-1.0)*(gconst63*gconst63))))))))+(((-1.0)*gconst63*new_r11))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r10*(x326.value)), (((new_r01*(IKsqrt(((1.0)+(((-1.0)*(gconst63*gconst63))))))))+(((-1.0)*gconst63*new_r11))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x327=IKsin(j4);
IkReal x328=IKcos(j4);
if((((1.0)+(((-1.0)*(gconst63*gconst63))))) < -0.00001)
continue;
IkReal x329=IKsqrt(((1.0)+(((-1.0)*(gconst63*gconst63)))));
IkReal x330=((1.0)*x329);
evalcond[0]=x327;
evalcond[1]=((-1.0)*x328);
evalcond[2]=(((gconst63*x327))+new_r10);
evalcond[3]=(((gconst63*x328))+new_r11);
evalcond[4]=(new_r00+(((-1.0)*x327*x330)));
evalcond[5]=((((-1.0)*x328*x330))+new_r01);
evalcond[6]=(((gconst63*new_r10))+x327+(((-1.0)*new_r00*x330)));
evalcond[7]=(((gconst63*new_r11))+x328+(((-1.0)*new_r01*x330)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x331=IKPowWithIntegerCheck(IKsign(gconst63),-1);
if(!x331.valid){
continue;
}
CheckValue<IkReal> x332 = IKatan2WithCheck(IkReal(((-1.0)*new_r10)),IkReal(((-1.0)*new_r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x332.valid){
continue;
}
j4array[0]=((-1.5707963267949)+(((1.5707963267949)*(x331.value)))+(x332.value));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x333=IKsin(j4);
IkReal x334=IKcos(j4);
if((((1.0)+(((-1.0)*(gconst63*gconst63))))) < -0.00001)
continue;
IkReal x335=IKsqrt(((1.0)+(((-1.0)*(gconst63*gconst63)))));
IkReal x336=((1.0)*x335);
evalcond[0]=x333;
evalcond[1]=((-1.0)*x334);
evalcond[2]=(((gconst63*x333))+new_r10);
evalcond[3]=(((gconst63*x334))+new_r11);
evalcond[4]=((((-1.0)*x333*x336))+new_r00);
evalcond[5]=(new_r01+(((-1.0)*x334*x336)));
evalcond[6]=(((gconst63*new_r10))+x333+(((-1.0)*new_r00*x336)));
evalcond[7]=(((gconst63*new_r11))+x334+(((-1.0)*new_r01*x336)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x337=new_r22*new_r22;
CheckValue<IkReal> x338=IKPowWithIntegerCheck(((1.0)+(((-1.0)*x337))),-1);
if(!x338.valid){
continue;
}
if((((-1.0)*x337*(x338.value))) < -0.00001)
continue;
IkReal gconst63=((-1.0)*(IKsqrt(((-1.0)*x337*(x338.value)))));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs((cj2+(((-1.0)*gconst63)))))+(IKabs(((1.0)+(IKsign(sj2)))))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4eval[1];
IkReal x339=new_r22*new_r22;
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
if((((1.0)+(((-1.0)*(gconst63*gconst63))))) < -0.00001)
continue;
sj2=((-1.0)*(IKsqrt(((1.0)+(((-1.0)*(gconst63*gconst63)))))));
cj2=gconst63;
if( (gconst63) < -1-IKFAST_SINCOS_THRESH || (gconst63) > 1+IKFAST_SINCOS_THRESH )
continue;
j2=((-1.0)*(IKacos(gconst63)));
CheckValue<IkReal> x340=IKPowWithIntegerCheck(((1.0)+(((-1.0)*x339))),-1);
if(!x340.valid){
continue;
}
if((((-1.0)*x339*(x340.value))) < -0.00001)
continue;
IkReal gconst63=((-1.0)*(IKsqrt(((-1.0)*x339*(x340.value)))));
j4eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j4eval[0]) < 0.0000010000000000 )
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x341=IKPowWithIntegerCheck(gconst63,-1);
if(!x341.valid){
continue;
}
if((((1.0)+(((-1.0)*(gconst63*gconst63))))) < -0.00001)
continue;
if( IKabs(((-1.0)*new_r10*(x341.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*gconst63*new_r11))+(((-1.0)*new_r01*(IKsqrt(((1.0)+(((-1.0)*(gconst63*gconst63)))))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r10*(x341.value)))+IKsqr(((((-1.0)*gconst63*new_r11))+(((-1.0)*new_r01*(IKsqrt(((1.0)+(((-1.0)*(gconst63*gconst63))))))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r10*(x341.value)), ((((-1.0)*gconst63*new_r11))+(((-1.0)*new_r01*(IKsqrt(((1.0)+(((-1.0)*(gconst63*gconst63))))))))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x342=IKsin(j4);
IkReal x343=IKcos(j4);
if((((1.0)+(((-1.0)*(gconst63*gconst63))))) < -0.00001)
continue;
IkReal x344=IKsqrt(((1.0)+(((-1.0)*(gconst63*gconst63)))));
evalcond[0]=x342;
evalcond[1]=((-1.0)*x343);
evalcond[2]=(((gconst63*x342))+new_r10);
evalcond[3]=(((gconst63*x343))+new_r11);
evalcond[4]=(new_r00+((x342*x344)));
evalcond[5]=(new_r01+((x343*x344)));
evalcond[6]=(((new_r00*x344))+((gconst63*new_r10))+x342);
evalcond[7]=(((gconst63*new_r11))+((new_r01*x344))+x343);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x345=IKPowWithIntegerCheck(IKsign(gconst63),-1);
if(!x345.valid){
continue;
}
CheckValue<IkReal> x346 = IKatan2WithCheck(IkReal(((-1.0)*new_r10)),IkReal(((-1.0)*new_r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x346.valid){
continue;
}
j4array[0]=((-1.5707963267949)+(((1.5707963267949)*(x345.value)))+(x346.value));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x347=IKsin(j4);
IkReal x348=IKcos(j4);
if((((1.0)+(((-1.0)*(gconst63*gconst63))))) < -0.00001)
continue;
IkReal x349=IKsqrt(((1.0)+(((-1.0)*(gconst63*gconst63)))));
evalcond[0]=x347;
evalcond[1]=((-1.0)*x348);
evalcond[2]=(((gconst63*x347))+new_r10);
evalcond[3]=(((gconst63*x348))+new_r11);
evalcond[4]=(((x347*x349))+new_r00);
evalcond[5]=(((x348*x349))+new_r01);
evalcond[6]=(((new_r00*x349))+((gconst63*new_r10))+x347);
evalcond[7]=(((gconst63*new_r11))+((new_r01*x349))+x348);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j4]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
IkReal x350=(new_r01*new_r22);
IkReal x351=(cj2*new_r11);
CheckValue<IkReal> x352=IKPowWithIntegerCheck(cj2,-1);
if(!x352.valid){
continue;
}
if( IKabs(((x352.value)*((((new_r22*sj2*x351))+(((-1.0)*x350))+(((-1.0)*new_r10))+((x350*(cj2*cj2))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs((((new_r01*sj2))+(((-1.0)*x351)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((x352.value)*((((new_r22*sj2*x351))+(((-1.0)*x350))+(((-1.0)*new_r10))+((x350*(cj2*cj2)))))))+IKsqr((((new_r01*sj2))+(((-1.0)*x351))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((x352.value)*((((new_r22*sj2*x351))+(((-1.0)*x350))+(((-1.0)*new_r10))+((x350*(cj2*cj2)))))), (((new_r01*sj2))+(((-1.0)*x351))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[10];
IkReal x353=IKcos(j4);
IkReal x354=IKsin(j4);
IkReal x355=(cj2*new_r01);
IkReal x356=(new_r10*sj2);
IkReal x357=((1.0)*new_r22);
IkReal x358=((1.0)*sj2);
IkReal x359=(new_r11*sj2);
IkReal x360=(cj2*new_r00);
IkReal x361=(cj2*x354);
IkReal x362=(new_r22*x353);
evalcond[0]=(x354+((cj2*new_r10))+(((-1.0)*new_r00*x358)));
evalcond[1]=(x353+(((-1.0)*new_r01*x358))+((cj2*new_r11)));
evalcond[2]=(x356+x360+x362);
evalcond[3]=(x361+((sj2*x362))+new_r10);
evalcond[4]=(x355+x359+(((-1.0)*x354*x357)));
evalcond[5]=(((cj2*x362))+new_r00+(((-1.0)*x354*x358)));
evalcond[6]=((((-1.0)*sj2*x354*x357))+new_r11+((cj2*x353)));
evalcond[7]=((((-1.0)*x357*x359))+x354+(((-1.0)*x355*x357)));
evalcond[8]=((((-1.0)*x353*x358))+new_r01+(((-1.0)*x357*x361)));
evalcond[9]=((((-1.0)*x356*x357))+(((-1.0)*x353))+(((-1.0)*x357*x360)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
IkReal x363=((1.0)*cj2);
CheckValue<IkReal> x364=IKPowWithIntegerCheck(new_r22,-1);
if(!x364.valid){
continue;
}
if( IKabs((((new_r00*sj2))+(((-1.0)*new_r10*x363)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((x364.value)*(((((-1.0)*new_r00*x363))+(((-1.0)*new_r10*sj2)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((((new_r00*sj2))+(((-1.0)*new_r10*x363))))+IKsqr(((x364.value)*(((((-1.0)*new_r00*x363))+(((-1.0)*new_r10*sj2))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2((((new_r00*sj2))+(((-1.0)*new_r10*x363))), ((x364.value)*(((((-1.0)*new_r00*x363))+(((-1.0)*new_r10*sj2))))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[10];
IkReal x365=IKcos(j4);
IkReal x366=IKsin(j4);
IkReal x367=(cj2*new_r01);
IkReal x368=(new_r10*sj2);
IkReal x369=((1.0)*new_r22);
IkReal x370=((1.0)*sj2);
IkReal x371=(new_r11*sj2);
IkReal x372=(cj2*new_r00);
IkReal x373=(cj2*x366);
IkReal x374=(new_r22*x365);
evalcond[0]=((((-1.0)*new_r00*x370))+x366+((cj2*new_r10)));
evalcond[1]=(x365+((cj2*new_r11))+(((-1.0)*new_r01*x370)));
evalcond[2]=(x374+x372+x368);
evalcond[3]=(x373+((sj2*x374))+new_r10);
evalcond[4]=(x371+x367+(((-1.0)*x366*x369)));
evalcond[5]=((((-1.0)*x366*x370))+new_r00+((cj2*x374)));
evalcond[6]=((((-1.0)*sj2*x366*x369))+((cj2*x365))+new_r11);
evalcond[7]=((((-1.0)*x367*x369))+x366+(((-1.0)*x369*x371)));
evalcond[8]=((((-1.0)*x369*x373))+new_r01+(((-1.0)*x365*x370)));
evalcond[9]=((((-1.0)*x365))+(((-1.0)*x369*x372))+(((-1.0)*x368*x369)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
IkReal x375=cj2*cj2;
IkReal x376=new_r22*new_r22;
IkReal x377=(new_r22*sj2);
IkReal x378=((1.0)*cj2);
CheckValue<IkReal> x379=IKPowWithIntegerCheck(IKsign((x376+x375+(((-1.0)*x375*x376)))),-1);
if(!x379.valid){
continue;
}
CheckValue<IkReal> x380 = IKatan2WithCheck(IkReal(((((-1.0)*new_r10*x378))+((new_r11*x377)))),IkReal(((((-1.0)*new_r10*x377))+(((-1.0)*new_r11*x378)))),IKFAST_ATAN2_MAGTHRESH);
if(!x380.valid){
continue;
}
j4array[0]=((-1.5707963267949)+(((1.5707963267949)*(x379.value)))+(x380.value));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[10];
IkReal x381=IKcos(j4);
IkReal x382=IKsin(j4);
IkReal x383=(cj2*new_r01);
IkReal x384=(new_r10*sj2);
IkReal x385=((1.0)*new_r22);
IkReal x386=((1.0)*sj2);
IkReal x387=(new_r11*sj2);
IkReal x388=(cj2*new_r00);
IkReal x389=(cj2*x382);
IkReal x390=(new_r22*x381);
evalcond[0]=((((-1.0)*new_r00*x386))+x382+((cj2*new_r10)));
evalcond[1]=((((-1.0)*new_r01*x386))+x381+((cj2*new_r11)));
evalcond[2]=(x384+x388+x390);
evalcond[3]=(x389+((sj2*x390))+new_r10);
evalcond[4]=(x387+x383+(((-1.0)*x382*x385)));
evalcond[5]=(((cj2*x390))+new_r00+(((-1.0)*x382*x386)));
evalcond[6]=(((cj2*x381))+new_r11+(((-1.0)*sj2*x382*x385)));
evalcond[7]=(x382+(((-1.0)*x385*x387))+(((-1.0)*x383*x385)));
evalcond[8]=((((-1.0)*x381*x386))+new_r01+(((-1.0)*x385*x389)));
evalcond[9]=((((-1.0)*x384*x385))+(((-1.0)*x381))+(((-1.0)*x385*x388)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j2, j4]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x392=IKPowWithIntegerCheck(sj3,-1);
if(!x392.valid){
continue;
}
IkReal x391=x392.value;
CheckValue<IkReal> x393=IKPowWithIntegerCheck(new_r12,-1);
if(!x393.valid){
continue;
}
if( IKabs((x391*(x393.value)*(((1.0)+(((-1.0)*(new_r02*new_r02)))+(((-1.0)*(cj3*cj3))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r02*x391)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((x391*(x393.value)*(((1.0)+(((-1.0)*(new_r02*new_r02)))+(((-1.0)*(cj3*cj3)))))))+IKsqr((new_r02*x391))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2((x391*(x393.value)*(((1.0)+(((-1.0)*(new_r02*new_r02)))+(((-1.0)*(cj3*cj3)))))), (new_r02*x391));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x394=IKcos(j2);
IkReal x395=IKsin(j2);
IkReal x396=((1.0)*new_r02);
IkReal x397=(sj3*x395);
IkReal x398=(sj3*x394);
IkReal x399=(new_r12*x395);
evalcond[0]=((((-1.0)*x398))+new_r02);
evalcond[1]=((((-1.0)*x397))+new_r12);
evalcond[2]=((((-1.0)*x395*x396))+((new_r12*x394)));
evalcond[3]=((((-1.0)*sj3))+x399+((new_r02*x394)));
evalcond[4]=(((new_r00*x398))+((cj3*new_r20))+((new_r10*x397)));
evalcond[5]=(((new_r11*x397))+((new_r01*x398))+((cj3*new_r21)));
evalcond[6]=((-1.0)+((new_r02*x398))+((cj3*new_r22))+((new_r12*x397)));
evalcond[7]=((((-1.0)*cj3*x399))+((new_r22*sj3))+(((-1.0)*cj3*x394*x396)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j4eval[3];
j4eval[0]=sj3;
j4eval[1]=IKsign(sj3);
j4eval[2]=((IKabs(new_r20))+(IKabs(new_r21)));
if( IKabs(j4eval[0]) < 0.0000010000000000 || IKabs(j4eval[1]) < 0.0000010000000000 || IKabs(j4eval[2]) < 0.0000010000000000 )
{
{
IkReal j4eval[2];
j4eval[0]=sj3;
j4eval[1]=cj2;
if( IKabs(j4eval[0]) < 0.0000010000000000 || IKabs(j4eval[1]) < 0.0000010000000000 )
{
{
IkReal j4eval[3];
j4eval[0]=sj3;
j4eval[1]=cj3;
j4eval[2]=sj2;
if( IKabs(j4eval[0]) < 0.0000010000000000 || IKabs(j4eval[1]) < 0.0000010000000000 || IKabs(j4eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[5];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=new_r21;
evalcond[2]=new_r02;
evalcond[3]=new_r12;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
IkReal x400=((1.0)*cj2);
if( IKabs((((new_r00*sj2))+(((-1.0)*new_r10*x400)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*new_r00*x400))+(((-1.0)*new_r10*sj2)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((((new_r00*sj2))+(((-1.0)*new_r10*x400))))+IKsqr(((((-1.0)*new_r00*x400))+(((-1.0)*new_r10*sj2))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2((((new_r00*sj2))+(((-1.0)*new_r10*x400))), ((((-1.0)*new_r00*x400))+(((-1.0)*new_r10*sj2))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x401=IKcos(j4);
IkReal x402=IKsin(j4);
IkReal x403=((1.0)*sj2);
IkReal x404=(cj2*x401);
IkReal x405=((1.0)*x402);
IkReal x406=(x402*x403);
evalcond[0]=(((new_r10*sj2))+x401+((cj2*new_r00)));
evalcond[1]=(x402+((cj2*new_r10))+(((-1.0)*new_r00*x403)));
evalcond[2]=(x401+((cj2*new_r11))+(((-1.0)*new_r01*x403)));
evalcond[3]=(((sj2*x401))+new_r10+((cj2*x402)));
evalcond[4]=(((new_r11*sj2))+((cj2*new_r01))+(((-1.0)*x405)));
evalcond[5]=(x404+new_r00+(((-1.0)*x406)));
evalcond[6]=(x404+new_r11+(((-1.0)*x406)));
evalcond[7]=((((-1.0)*cj2*x405))+(((-1.0)*x401*x403))+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j3)))), 6.28318530717959)));
evalcond[1]=new_r21;
evalcond[2]=new_r02;
evalcond[3]=new_r12;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
IkReal x407=((1.0)*cj2);
if( IKabs(((((-1.0)*new_r11*sj2))+(((-1.0)*new_r10*x407)))) < IKFAST_ATAN2_MAGTHRESH && IKabs((((new_r10*sj2))+(((-1.0)*new_r11*x407)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((-1.0)*new_r11*sj2))+(((-1.0)*new_r10*x407))))+IKsqr((((new_r10*sj2))+(((-1.0)*new_r11*x407))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((((-1.0)*new_r11*sj2))+(((-1.0)*new_r10*x407))), (((new_r10*sj2))+(((-1.0)*new_r11*x407))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x408=IKsin(j4);
IkReal x409=IKcos(j4);
IkReal x410=((1.0)*sj2);
IkReal x411=(cj2*x408);
IkReal x412=(cj2*x409);
IkReal x413=(x409*x410);
evalcond[0]=(((new_r11*sj2))+x408+((cj2*new_r01)));
evalcond[1]=(x408+((cj2*new_r10))+(((-1.0)*new_r00*x410)));
evalcond[2]=(x409+((cj2*new_r11))+(((-1.0)*new_r01*x410)));
evalcond[3]=(((new_r10*sj2))+((cj2*new_r00))+(((-1.0)*x409)));
evalcond[4]=(((sj2*x408))+x412+new_r11);
evalcond[5]=(x411+new_r10+(((-1.0)*x413)));
evalcond[6]=(x411+new_r01+(((-1.0)*x413)));
evalcond[7]=(new_r00+(((-1.0)*x408*x410))+(((-1.0)*x412)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j3)))), 6.28318530717959)));
evalcond[1]=new_r22;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(((-1.0)*new_r21)) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r20) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r21))+IKsqr(new_r20)-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r21), new_r20);
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x414=IKsin(j4);
IkReal x415=IKcos(j4);
IkReal x416=((1.0)*sj2);
evalcond[0]=(x414+new_r21);
evalcond[1]=(new_r20+(((-1.0)*x415)));
evalcond[2]=(new_r10+((cj2*x414)));
evalcond[3]=(new_r11+((cj2*x415)));
evalcond[4]=(new_r00+(((-1.0)*x414*x416)));
evalcond[5]=((((-1.0)*x415*x416))+new_r01);
evalcond[6]=(x414+((cj2*new_r10))+(((-1.0)*new_r00*x416)));
evalcond[7]=(x415+((cj2*new_r11))+(((-1.0)*new_r01*x416)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j3)))), 6.28318530717959)));
evalcond[1]=new_r22;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(new_r21) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r20)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r21)+IKsqr(((-1.0)*new_r20))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(new_r21, ((-1.0)*new_r20));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x417=IKsin(j4);
IkReal x418=IKcos(j4);
IkReal x419=((1.0)*sj2);
evalcond[0]=(x418+new_r20);
evalcond[1]=(new_r21+(((-1.0)*x417)));
evalcond[2]=(new_r10+((cj2*x417)));
evalcond[3]=(new_r11+((cj2*x418)));
evalcond[4]=((((-1.0)*x417*x419))+new_r00);
evalcond[5]=((((-1.0)*x418*x419))+new_r01);
evalcond[6]=(x417+((cj2*new_r10))+(((-1.0)*new_r00*x419)));
evalcond[7]=(x418+((cj2*new_r11))+(((-1.0)*new_r01*x419)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j2))), 6.28318530717959)));
evalcond[1]=new_r12;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(((-1.0)*new_r10)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r11)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r10))+IKsqr(((-1.0)*new_r11))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r10), ((-1.0)*new_r11));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x420=IKsin(j4);
IkReal x421=IKcos(j4);
IkReal x422=((1.0)*cj3);
IkReal x423=((1.0)*x421);
evalcond[0]=(x420+new_r10);
evalcond[1]=(x421+new_r11);
evalcond[2]=(((sj3*x420))+new_r21);
evalcond[3]=(((cj3*x421))+new_r00);
evalcond[4]=((((-1.0)*sj3*x423))+new_r20);
evalcond[5]=((((-1.0)*x420*x422))+new_r01);
evalcond[6]=(x420+((new_r21*sj3))+(((-1.0)*new_r01*x422)));
evalcond[7]=(((new_r20*sj3))+(((-1.0)*new_r00*x422))+(((-1.0)*x423)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j2)))), 6.28318530717959)));
evalcond[1]=new_r12;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(new_r10) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r11) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r10)+IKsqr(new_r11)-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(new_r10, new_r11);
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x424=IKsin(j4);
IkReal x425=IKcos(j4);
IkReal x426=((1.0)*x425);
evalcond[0]=(((sj3*x424))+new_r21);
evalcond[1]=(x424+(((-1.0)*new_r10)));
evalcond[2]=(x425+(((-1.0)*new_r11)));
evalcond[3]=((((-1.0)*sj3*x426))+new_r20);
evalcond[4]=(((cj3*x425))+(((-1.0)*new_r00)));
evalcond[5]=((((-1.0)*cj3*x424))+(((-1.0)*new_r01)));
evalcond[6]=(x424+((cj3*new_r01))+((new_r21*sj3)));
evalcond[7]=(((new_r20*sj3))+(((-1.0)*x426))+((cj3*new_r00)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j2)))), 6.28318530717959)));
evalcond[1]=new_r02;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(new_r00) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r01) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r00)+IKsqr(new_r01)-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(new_r00, new_r01);
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x427=IKsin(j4);
IkReal x428=IKcos(j4);
IkReal x429=((1.0)*cj3);
IkReal x430=((1.0)*x428);
evalcond[0]=(((sj3*x427))+new_r21);
evalcond[1]=(x427+(((-1.0)*new_r00)));
evalcond[2]=(x428+(((-1.0)*new_r01)));
evalcond[3]=(((cj3*x428))+new_r10);
evalcond[4]=((((-1.0)*sj3*x430))+new_r20);
evalcond[5]=((((-1.0)*x427*x429))+new_r11);
evalcond[6]=(x427+(((-1.0)*new_r11*x429))+((new_r21*sj3)));
evalcond[7]=((((-1.0)*x430))+((new_r20*sj3))+(((-1.0)*new_r10*x429)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j2)))), 6.28318530717959)));
evalcond[1]=new_r02;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(((-1.0)*new_r00)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r01)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r00))+IKsqr(((-1.0)*new_r01))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r00), ((-1.0)*new_r01));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x431=IKsin(j4);
IkReal x432=IKcos(j4);
IkReal x433=((1.0)*x432);
evalcond[0]=(x431+new_r00);
evalcond[1]=(x432+new_r01);
evalcond[2]=(((sj3*x431))+new_r21);
evalcond[3]=((((-1.0)*sj3*x433))+new_r20);
evalcond[4]=(((cj3*x432))+(((-1.0)*new_r10)));
evalcond[5]=((((-1.0)*cj3*x431))+(((-1.0)*new_r11)));
evalcond[6]=(x431+((cj3*new_r11))+((new_r21*sj3)));
evalcond[7]=((((-1.0)*x433))+((new_r20*sj3))+((cj3*new_r10)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r20))+(IKabs(new_r21)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4eval[1];
new_r21=0;
new_r20=0;
new_r02=0;
new_r12=0;
j4eval[0]=IKabs(new_r22);
if( IKabs(j4eval[0]) < 0.0000000100000000 )
{
continue; // no branches [j4]
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=((-1.0)*new_r22);
op[1]=0;
op[2]=new_r22;
polyroots2(op,zeror,numroots);
IkReal j4array[2], cj4array[2], sj4array[2], tempj4array[1];
int numsolutions = 0;
for(int ij4 = 0; ij4 < numroots; ++ij4)
{
IkReal htj4 = zeror[ij4];
tempj4array[0]=((2.0)*(atan(htj4)));
for(int kj4 = 0; kj4 < 1; ++kj4)
{
j4array[numsolutions] = tempj4array[kj4];
if( j4array[numsolutions] > IKPI )
{
j4array[numsolutions]-=IK2PI;
}
else if( j4array[numsolutions] < -IKPI )
{
j4array[numsolutions]+=IK2PI;
}
sj4array[numsolutions] = IKsin(j4array[numsolutions]);
cj4array[numsolutions] = IKcos(j4array[numsolutions]);
numsolutions++;
}
}
bool j4valid[2]={true,true};
_nj4 = 2;
for(int ij4 = 0; ij4 < numsolutions; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
htj4 = IKtan(j4/2);
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < numsolutions; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j4]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x435=IKPowWithIntegerCheck(sj3,-1);
if(!x435.valid){
continue;
}
IkReal x434=x435.value;
CheckValue<IkReal> x436=IKPowWithIntegerCheck(cj3,-1);
if(!x436.valid){
continue;
}
CheckValue<IkReal> x437=IKPowWithIntegerCheck(sj2,-1);
if(!x437.valid){
continue;
}
if( IKabs(((-1.0)*new_r21*x434)) < IKFAST_ATAN2_MAGTHRESH && IKabs((x434*(x436.value)*(x437.value)*(((((-1.0)*new_r10*sj3))+((cj2*new_r21)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r21*x434))+IKsqr((x434*(x436.value)*(x437.value)*(((((-1.0)*new_r10*sj3))+((cj2*new_r21))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r21*x434), (x434*(x436.value)*(x437.value)*(((((-1.0)*new_r10*sj3))+((cj2*new_r21))))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[12];
IkReal x438=IKsin(j4);
IkReal x439=IKcos(j4);
IkReal x440=(cj2*new_r01);
IkReal x441=((1.0)*cj3);
IkReal x442=(new_r10*sj2);
IkReal x443=(new_r11*sj2);
IkReal x444=(cj2*new_r00);
IkReal x445=((1.0)*sj2);
IkReal x446=(cj2*x438);
IkReal x447=(cj2*x439);
IkReal x448=((1.0)*x439);
IkReal x449=(cj3*x439);
evalcond[0]=(((sj3*x438))+new_r21);
evalcond[1]=((((-1.0)*sj3*x448))+new_r20);
evalcond[2]=((((-1.0)*new_r00*x445))+x438+((cj2*new_r10)));
evalcond[3]=((((-1.0)*new_r01*x445))+x439+((cj2*new_r11)));
evalcond[4]=(x449+x444+x442);
evalcond[5]=(x446+((sj2*x449))+new_r10);
evalcond[6]=((((-1.0)*x438*x441))+x440+x443);
evalcond[7]=((((-1.0)*x438*x445))+((cj3*x447))+new_r00);
evalcond[8]=((((-1.0)*sj2*x438*x441))+x447+new_r11);
evalcond[9]=((((-1.0)*x439*x445))+new_r01+(((-1.0)*x441*x446)));
evalcond[10]=(x438+((new_r21*sj3))+(((-1.0)*x440*x441))+(((-1.0)*x441*x443)));
evalcond[11]=((((-1.0)*x448))+((new_r20*sj3))+(((-1.0)*x441*x444))+(((-1.0)*x441*x442)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x451=IKPowWithIntegerCheck(sj3,-1);
if(!x451.valid){
continue;
}
IkReal x450=x451.value;
CheckValue<IkReal> x452=IKPowWithIntegerCheck(cj2,-1);
if(!x452.valid){
continue;
}
if( IKabs(((-1.0)*new_r21*x450)) < IKFAST_ATAN2_MAGTHRESH && IKabs((x450*(x452.value)*(((((-1.0)*cj3*new_r21*sj2))+(((-1.0)*new_r11*sj3)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r21*x450))+IKsqr((x450*(x452.value)*(((((-1.0)*cj3*new_r21*sj2))+(((-1.0)*new_r11*sj3))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r21*x450), (x450*(x452.value)*(((((-1.0)*cj3*new_r21*sj2))+(((-1.0)*new_r11*sj3))))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[12];
IkReal x453=IKsin(j4);
IkReal x454=IKcos(j4);
IkReal x455=(cj2*new_r01);
IkReal x456=((1.0)*cj3);
IkReal x457=(new_r10*sj2);
IkReal x458=(new_r11*sj2);
IkReal x459=(cj2*new_r00);
IkReal x460=((1.0)*sj2);
IkReal x461=(cj2*x453);
IkReal x462=(cj2*x454);
IkReal x463=((1.0)*x454);
IkReal x464=(cj3*x454);
evalcond[0]=(((sj3*x453))+new_r21);
evalcond[1]=((((-1.0)*sj3*x463))+new_r20);
evalcond[2]=((((-1.0)*new_r00*x460))+x453+((cj2*new_r10)));
evalcond[3]=((((-1.0)*new_r01*x460))+x454+((cj2*new_r11)));
evalcond[4]=(x459+x457+x464);
evalcond[5]=(x461+new_r10+((sj2*x464)));
evalcond[6]=(x458+x455+(((-1.0)*x453*x456)));
evalcond[7]=(((cj3*x462))+(((-1.0)*x453*x460))+new_r00);
evalcond[8]=((((-1.0)*sj2*x453*x456))+x462+new_r11);
evalcond[9]=((((-1.0)*x456*x461))+(((-1.0)*x454*x460))+new_r01);
evalcond[10]=((((-1.0)*x456*x458))+x453+(((-1.0)*x455*x456))+((new_r21*sj3)));
evalcond[11]=(((new_r20*sj3))+(((-1.0)*x456*x457))+(((-1.0)*x456*x459))+(((-1.0)*x463)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x465=IKPowWithIntegerCheck(IKsign(sj3),-1);
if(!x465.valid){
continue;
}
CheckValue<IkReal> x466 = IKatan2WithCheck(IkReal(((-1.0)*new_r21)),IkReal(new_r20),IKFAST_ATAN2_MAGTHRESH);
if(!x466.valid){
continue;
}
j4array[0]=((-1.5707963267949)+(((1.5707963267949)*(x465.value)))+(x466.value));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[12];
IkReal x467=IKsin(j4);
IkReal x468=IKcos(j4);
IkReal x469=(cj2*new_r01);
IkReal x470=((1.0)*cj3);
IkReal x471=(new_r10*sj2);
IkReal x472=(new_r11*sj2);
IkReal x473=(cj2*new_r00);
IkReal x474=((1.0)*sj2);
IkReal x475=(cj2*x467);
IkReal x476=(cj2*x468);
IkReal x477=((1.0)*x468);
IkReal x478=(cj3*x468);
evalcond[0]=(((sj3*x467))+new_r21);
evalcond[1]=((((-1.0)*sj3*x477))+new_r20);
evalcond[2]=((((-1.0)*new_r00*x474))+x467+((cj2*new_r10)));
evalcond[3]=((((-1.0)*new_r01*x474))+x468+((cj2*new_r11)));
evalcond[4]=(x471+x473+x478);
evalcond[5]=(x475+new_r10+((sj2*x478)));
evalcond[6]=((((-1.0)*x467*x470))+x469+x472);
evalcond[7]=((((-1.0)*x467*x474))+((cj3*x476))+new_r00);
evalcond[8]=(x476+new_r11+(((-1.0)*sj2*x467*x470)));
evalcond[9]=((((-1.0)*x468*x474))+new_r01+(((-1.0)*x470*x475)));
evalcond[10]=((((-1.0)*x469*x470))+x467+((new_r21*sj3))+(((-1.0)*x470*x472)));
evalcond[11]=(((new_r20*sj3))+(((-1.0)*x477))+(((-1.0)*x470*x471))+(((-1.0)*x470*x473)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x479=IKPowWithIntegerCheck(IKsign(sj3),-1);
if(!x479.valid){
continue;
}
CheckValue<IkReal> x480 = IKatan2WithCheck(IkReal(((-1.0)*new_r21)),IkReal(new_r20),IKFAST_ATAN2_MAGTHRESH);
if(!x480.valid){
continue;
}
j4array[0]=((-1.5707963267949)+(((1.5707963267949)*(x479.value)))+(x480.value));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[2];
evalcond[0]=(new_r21+((sj3*(IKsin(j4)))));
evalcond[1]=((((-1.0)*sj3*(IKcos(j4))))+new_r20);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j2eval[3];
j2eval[0]=sj3;
j2eval[1]=((IKabs(new_r12))+(IKabs(new_r02)));
j2eval[2]=IKsign(sj3);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[2];
j2eval[0]=new_r00;
j2eval[1]=sj3;
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[5];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=new_r21;
evalcond[2]=new_r02;
evalcond[3]=new_r12;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[3];
sj3=0;
cj3=1.0;
j3=0;
IkReal x481=((1.0)*new_r10);
IkReal x482=((new_r10*new_r10)+(new_r00*new_r00));
j2eval[0]=x482;
j2eval[1]=IKsign(x482);
j2eval[2]=((IKabs((((new_r00*sj4))+(((-1.0)*cj4*x481)))))+(IKabs(((((-1.0)*cj4*new_r00))+(((-1.0)*sj4*x481))))));
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[3];
sj3=0;
cj3=1.0;
j3=0;
IkReal x483=((1.0)*cj4);
IkReal x484=(((new_r10*new_r11))+((new_r00*new_r01)));
j2eval[0]=x484;
j2eval[1]=((IKabs(((((-1.0)*new_r11*x483))+((cj4*new_r00)))))+(IKabs(((((-1.0)*new_r01*x483))+(((-1.0)*new_r10*x483))))));
j2eval[2]=IKsign(x484);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[3];
sj3=0;
cj3=1.0;
j3=0;
IkReal x485=((1.0)*new_r10);
IkReal x486=(((cj4*new_r00))+(((-1.0)*sj4*x485)));
j2eval[0]=x486;
j2eval[1]=IKsign(x486);
j2eval[2]=((IKabs(((((-1.0)*(cj4*cj4)))+(new_r10*new_r10))))+(IKabs(((((-1.0)*new_r00*x485))+((cj4*sj4))))));
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
IkReal x489 = ((new_r10*new_r10)+(new_r00*new_r00));
if(IKabs(x489)==0){
continue;
}
IkReal x487=pow(x489,-0.5);
IkReal x488=((-1.0)*x487);
CheckValue<IkReal> x490 = IKatan2WithCheck(IkReal(new_r00),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x490.valid){
continue;
}
IkReal gconst50=((-1.0)*(x490.value));
IkReal gconst51=(new_r00*x488);
IkReal gconst52=(new_r10*x488);
CheckValue<IkReal> x491 = IKatan2WithCheck(IkReal(new_r00),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x491.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((x491.value)+j4)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[2];
CheckValue<IkReal> x495 = IKatan2WithCheck(IkReal(new_r00),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x495.valid){
continue;
}
IkReal x492=((-1.0)*(x495.value));
IkReal x493=x487;
IkReal x494=((-1.0)*x493);
sj3=0;
cj3=1.0;
j3=0;
sj4=gconst51;
cj4=gconst52;
j4=x492;
IkReal gconst50=x492;
IkReal gconst51=(new_r00*x494);
IkReal gconst52=(new_r10*x494);
IkReal x496=((new_r10*new_r10)+(new_r00*new_r00));
j2eval[0]=x496;
j2eval[1]=IKsign(x496);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 )
{
{
IkReal j2eval[3];
CheckValue<IkReal> x500 = IKatan2WithCheck(IkReal(new_r00),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x500.valid){
continue;
}
IkReal x497=((-1.0)*(x500.value));
IkReal x498=x487;
IkReal x499=((-1.0)*x498);
sj3=0;
cj3=1.0;
j3=0;
sj4=gconst51;
cj4=gconst52;
j4=x497;
IkReal gconst50=x497;
IkReal gconst51=(new_r00*x499);
IkReal gconst52=(new_r10*x499);
IkReal x501=new_r10*new_r10;
IkReal x502=(((new_r10*new_r11))+((new_r00*new_r01)));
IkReal x503=x487;
IkReal x504=(new_r10*x503);
j2eval[0]=x502;
j2eval[1]=((IKabs((((new_r11*x504))+(((-1.0)*new_r00*x504)))))+(IKabs((((x501*x503))+((new_r01*x504))))));
j2eval[2]=IKsign(x502);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[1];
CheckValue<IkReal> x508 = IKatan2WithCheck(IkReal(new_r00),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x508.valid){
continue;
}
IkReal x505=((-1.0)*(x508.value));
IkReal x506=x487;
IkReal x507=((-1.0)*x506);
sj3=0;
cj3=1.0;
j3=0;
sj4=gconst51;
cj4=gconst52;
j4=x505;
IkReal gconst50=x505;
IkReal gconst51=(new_r00*x507);
IkReal gconst52=(new_r10*x507);
IkReal x509=new_r10*new_r10;
IkReal x510=new_r00*new_r00;
CheckValue<IkReal> x517=IKPowWithIntegerCheck((x509+x510),-1);
if(!x517.valid){
continue;
}
IkReal x511=x517.value;
IkReal x512=(x509*x511);
CheckValue<IkReal> x518=IKPowWithIntegerCheck(((((-1.0)*x510))+(((-1.0)*x509))),-1);
if(!x518.valid){
continue;
}
IkReal x513=x518.value;
IkReal x514=((1.0)*x513);
IkReal x515=(new_r00*x514);
IkReal x516=(new_r10*x514);
j2eval[0]=((IKabs(((((-1.0)*new_r10*x515))+(((-1.0)*new_r10*x515*(new_r00*new_r00)))+(((-1.0)*x515*(new_r10*new_r10*new_r10))))))+(IKabs((((x510*x512))+(((-1.0)*x512))+((x511*(x510*x510)))))));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j2]
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x519 = IKatan2WithCheck(IkReal(((new_r00*new_r00)+(((-1.0)*(gconst52*gconst52))))),IkReal(((((-1.0)*gconst51*gconst52))+(((-1.0)*new_r00*new_r10)))),IKFAST_ATAN2_MAGTHRESH);
if(!x519.valid){
continue;
}
CheckValue<IkReal> x520=IKPowWithIntegerCheck(IKsign((((gconst51*new_r00))+((gconst52*new_r10)))),-1);
if(!x520.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x519.value)+(((1.5707963267949)*(x520.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x521=IKcos(j2);
IkReal x522=IKsin(j2);
IkReal x523=(gconst52*x521);
IkReal x524=((1.0)*x522);
IkReal x525=(gconst51*x521);
IkReal x526=(gconst51*x524);
evalcond[0]=(gconst52+((new_r10*x522))+((new_r00*x521)));
evalcond[1]=(((gconst52*x522))+x525+new_r10);
evalcond[2]=(gconst51+(((-1.0)*new_r00*x524))+((new_r10*x521)));
evalcond[3]=(gconst52+((new_r11*x521))+(((-1.0)*new_r01*x524)));
evalcond[4]=((((-1.0)*x526))+x523+new_r00);
evalcond[5]=((((-1.0)*x526))+x523+new_r11);
evalcond[6]=(((new_r01*x521))+(((-1.0)*gconst51))+((new_r11*x522)));
evalcond[7]=((((-1.0)*x525))+(((-1.0)*gconst52*x524))+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x527=((1.0)*gconst52);
CheckValue<IkReal> x528 = IKatan2WithCheck(IkReal((((gconst52*new_r00))+(((-1.0)*new_r11*x527)))),IkReal(((((-1.0)*new_r01*x527))+(((-1.0)*new_r10*x527)))),IKFAST_ATAN2_MAGTHRESH);
if(!x528.valid){
continue;
}
CheckValue<IkReal> x529=IKPowWithIntegerCheck(IKsign((((new_r10*new_r11))+((new_r00*new_r01)))),-1);
if(!x529.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x528.value)+(((1.5707963267949)*(x529.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x530=IKcos(j2);
IkReal x531=IKsin(j2);
IkReal x532=(gconst52*x530);
IkReal x533=((1.0)*x531);
IkReal x534=(gconst51*x530);
IkReal x535=(gconst51*x533);
evalcond[0]=(gconst52+((new_r10*x531))+((new_r00*x530)));
evalcond[1]=(((gconst52*x531))+x534+new_r10);
evalcond[2]=(gconst51+(((-1.0)*new_r00*x533))+((new_r10*x530)));
evalcond[3]=(gconst52+((new_r11*x530))+(((-1.0)*new_r01*x533)));
evalcond[4]=((((-1.0)*x535))+x532+new_r00);
evalcond[5]=((((-1.0)*x535))+x532+new_r11);
evalcond[6]=(((new_r01*x530))+(((-1.0)*gconst51))+((new_r11*x531)));
evalcond[7]=((((-1.0)*x534))+(((-1.0)*gconst52*x533))+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x536=((1.0)*new_r10);
CheckValue<IkReal> x537=IKPowWithIntegerCheck(IKsign(((new_r10*new_r10)+(new_r00*new_r00))),-1);
if(!x537.valid){
continue;
}
CheckValue<IkReal> x538 = IKatan2WithCheck(IkReal((((gconst51*new_r00))+(((-1.0)*gconst52*x536)))),IkReal(((((-1.0)*gconst51*x536))+(((-1.0)*gconst52*new_r00)))),IKFAST_ATAN2_MAGTHRESH);
if(!x538.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x537.value)))+(x538.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x539=IKcos(j2);
IkReal x540=IKsin(j2);
IkReal x541=(gconst52*x539);
IkReal x542=((1.0)*x540);
IkReal x543=(gconst51*x539);
IkReal x544=(gconst51*x542);
evalcond[0]=(((new_r10*x540))+gconst52+((new_r00*x539)));
evalcond[1]=(((gconst52*x540))+x543+new_r10);
evalcond[2]=((((-1.0)*new_r00*x542))+gconst51+((new_r10*x539)));
evalcond[3]=(gconst52+((new_r11*x539))+(((-1.0)*new_r01*x542)));
evalcond[4]=((((-1.0)*x544))+x541+new_r00);
evalcond[5]=((((-1.0)*x544))+x541+new_r11);
evalcond[6]=(((new_r01*x539))+(((-1.0)*gconst51))+((new_r11*x540)));
evalcond[7]=((((-1.0)*x543))+(((-1.0)*gconst52*x542))+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x547 = ((new_r10*new_r10)+(new_r00*new_r00));
if(IKabs(x547)==0){
continue;
}
IkReal x545=pow(x547,-0.5);
IkReal x546=((1.0)*x545);
CheckValue<IkReal> x548 = IKatan2WithCheck(IkReal(new_r00),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x548.valid){
continue;
}
IkReal gconst53=((3.14159265358979)+(((-1.0)*(x548.value))));
IkReal gconst54=(new_r00*x546);
IkReal gconst55=(new_r10*x546);
CheckValue<IkReal> x549 = IKatan2WithCheck(IkReal(new_r00),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x549.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+(x549.value)+j4)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[2];
CheckValue<IkReal> x553 = IKatan2WithCheck(IkReal(new_r00),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x553.valid){
continue;
}
IkReal x550=((1.0)*(x553.value));
IkReal x551=x545;
IkReal x552=((1.0)*x551);
sj3=0;
cj3=1.0;
j3=0;
sj4=gconst54;
cj4=gconst55;
j4=((3.14159265)+(((-1.0)*x550)));
IkReal gconst53=((3.14159265358979)+(((-1.0)*x550)));
IkReal gconst54=(new_r00*x552);
IkReal gconst55=(new_r10*x552);
IkReal x554=((new_r10*new_r10)+(new_r00*new_r00));
j2eval[0]=x554;
j2eval[1]=IKsign(x554);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 )
{
{
IkReal j2eval[3];
CheckValue<IkReal> x558 = IKatan2WithCheck(IkReal(new_r00),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x558.valid){
continue;
}
IkReal x555=((1.0)*(x558.value));
IkReal x556=x545;
IkReal x557=((1.0)*x556);
sj3=0;
cj3=1.0;
j3=0;
sj4=gconst54;
cj4=gconst55;
j4=((3.14159265)+(((-1.0)*x555)));
IkReal gconst53=((3.14159265358979)+(((-1.0)*x555)));
IkReal gconst54=(new_r00*x557);
IkReal gconst55=(new_r10*x557);
IkReal x559=new_r10*new_r10;
IkReal x560=(new_r10*new_r11);
IkReal x561=(((new_r00*new_r01))+x560);
IkReal x562=x545;
IkReal x563=((1.0)*x562);
j2eval[0]=x561;
j2eval[1]=((IKabs((((new_r00*new_r10*x562))+(((-1.0)*x560*x563)))))+(IKabs(((((-1.0)*new_r01*new_r10*x563))+(((-1.0)*x559*x563))))));
j2eval[2]=IKsign(x561);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[1];
CheckValue<IkReal> x567 = IKatan2WithCheck(IkReal(new_r00),IkReal(((-1.0)*new_r10)),IKFAST_ATAN2_MAGTHRESH);
if(!x567.valid){
continue;
}
IkReal x564=((1.0)*(x567.value));
IkReal x565=x545;
IkReal x566=((1.0)*x565);
sj3=0;
cj3=1.0;
j3=0;
sj4=gconst54;
cj4=gconst55;
j4=((3.14159265)+(((-1.0)*x564)));
IkReal gconst53=((3.14159265358979)+(((-1.0)*x564)));
IkReal gconst54=(new_r00*x566);
IkReal gconst55=(new_r10*x566);
IkReal x568=new_r10*new_r10;
IkReal x569=new_r00*new_r00;
CheckValue<IkReal> x576=IKPowWithIntegerCheck((x568+x569),-1);
if(!x576.valid){
continue;
}
IkReal x570=x576.value;
IkReal x571=(x568*x570);
CheckValue<IkReal> x577=IKPowWithIntegerCheck(((((-1.0)*x568))+(((-1.0)*x569))),-1);
if(!x577.valid){
continue;
}
IkReal x572=x577.value;
IkReal x573=((1.0)*x572);
IkReal x574=(new_r00*x573);
IkReal x575=(new_r10*x573);
j2eval[0]=((IKabs(((((-1.0)*x571))+((x570*(x569*x569)))+((x569*x571)))))+(IKabs(((((-1.0)*new_r10*x574))+(((-1.0)*x574*(new_r10*new_r10*new_r10)))+(((-1.0)*new_r10*x574*(new_r00*new_r00)))))));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j2]
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x578 = IKatan2WithCheck(IkReal(((((-1.0)*(gconst55*gconst55)))+(new_r00*new_r00))),IkReal(((((-1.0)*new_r00*new_r10))+(((-1.0)*gconst54*gconst55)))),IKFAST_ATAN2_MAGTHRESH);
if(!x578.valid){
continue;
}
CheckValue<IkReal> x579=IKPowWithIntegerCheck(IKsign((((gconst54*new_r00))+((gconst55*new_r10)))),-1);
if(!x579.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x578.value)+(((1.5707963267949)*(x579.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x580=IKsin(j2);
IkReal x581=IKcos(j2);
IkReal x582=((1.0)*gconst54);
IkReal x583=(gconst55*x581);
IkReal x584=((1.0)*x580);
IkReal x585=(x580*x582);
evalcond[0]=(gconst55+((new_r00*x581))+((new_r10*x580)));
evalcond[1]=(((gconst55*x580))+new_r10+((gconst54*x581)));
evalcond[2]=(gconst54+(((-1.0)*new_r00*x584))+((new_r10*x581)));
evalcond[3]=((((-1.0)*new_r01*x584))+gconst55+((new_r11*x581)));
evalcond[4]=(x583+new_r00+(((-1.0)*x585)));
evalcond[5]=(x583+new_r11+(((-1.0)*x585)));
evalcond[6]=(((new_r01*x581))+(((-1.0)*x582))+((new_r11*x580)));
evalcond[7]=((((-1.0)*gconst55*x584))+new_r01+(((-1.0)*x581*x582)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x586=((1.0)*gconst55);
CheckValue<IkReal> x587 = IKatan2WithCheck(IkReal(((((-1.0)*new_r11*x586))+((gconst55*new_r00)))),IkReal(((((-1.0)*new_r01*x586))+(((-1.0)*new_r10*x586)))),IKFAST_ATAN2_MAGTHRESH);
if(!x587.valid){
continue;
}
CheckValue<IkReal> x588=IKPowWithIntegerCheck(IKsign((((new_r10*new_r11))+((new_r00*new_r01)))),-1);
if(!x588.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x587.value)+(((1.5707963267949)*(x588.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x589=IKsin(j2);
IkReal x590=IKcos(j2);
IkReal x591=((1.0)*gconst54);
IkReal x592=(gconst55*x590);
IkReal x593=((1.0)*x589);
IkReal x594=(x589*x591);
evalcond[0]=(gconst55+((new_r00*x590))+((new_r10*x589)));
evalcond[1]=(((gconst55*x589))+((gconst54*x590))+new_r10);
evalcond[2]=((((-1.0)*new_r00*x593))+((new_r10*x590))+gconst54);
evalcond[3]=(((new_r11*x590))+(((-1.0)*new_r01*x593))+gconst55);
evalcond[4]=((((-1.0)*x594))+x592+new_r00);
evalcond[5]=((((-1.0)*x594))+x592+new_r11);
evalcond[6]=(((new_r01*x590))+(((-1.0)*x591))+((new_r11*x589)));
evalcond[7]=((((-1.0)*gconst55*x593))+(((-1.0)*x590*x591))+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x595=((1.0)*new_r10);
CheckValue<IkReal> x596=IKPowWithIntegerCheck(IKsign(((new_r10*new_r10)+(new_r00*new_r00))),-1);
if(!x596.valid){
continue;
}
CheckValue<IkReal> x597 = IKatan2WithCheck(IkReal(((((-1.0)*gconst55*x595))+((gconst54*new_r00)))),IkReal(((((-1.0)*gconst55*new_r00))+(((-1.0)*gconst54*x595)))),IKFAST_ATAN2_MAGTHRESH);
if(!x597.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x596.value)))+(x597.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x598=IKsin(j2);
IkReal x599=IKcos(j2);
IkReal x600=((1.0)*gconst54);
IkReal x601=(gconst55*x599);
IkReal x602=((1.0)*x598);
IkReal x603=(x598*x600);
evalcond[0]=(((new_r10*x598))+gconst55+((new_r00*x599)));
evalcond[1]=(((gconst54*x599))+new_r10+((gconst55*x598)));
evalcond[2]=(((new_r10*x599))+gconst54+(((-1.0)*new_r00*x602)));
evalcond[3]=(((new_r11*x599))+gconst55+(((-1.0)*new_r01*x602)));
evalcond[4]=(x601+(((-1.0)*x603))+new_r00);
evalcond[5]=(x601+(((-1.0)*x603))+new_r11);
evalcond[6]=(((new_r11*x598))+((new_r01*x599))+(((-1.0)*x600)));
evalcond[7]=((((-1.0)*x599*x600))+(((-1.0)*gconst55*x602))+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j4)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
if( IKabs(new_r00) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r10)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r00)+IKsqr(((-1.0)*new_r10))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2(new_r00, ((-1.0)*new_r10));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x604=IKcos(j2);
IkReal x605=IKsin(j2);
IkReal x606=((1.0)*x605);
evalcond[0]=(x604+new_r10);
evalcond[1]=((((-1.0)*x606))+new_r00);
evalcond[2]=((((-1.0)*x606))+new_r11);
evalcond[3]=((((-1.0)*x604))+new_r01);
evalcond[4]=(((new_r10*x605))+((new_r00*x604)));
evalcond[5]=(((new_r11*x604))+(((-1.0)*new_r01*x606)));
evalcond[6]=((-1.0)+((new_r11*x605))+((new_r01*x604)));
evalcond[7]=((1.0)+((new_r10*x604))+(((-1.0)*new_r00*x606)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j4)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
if( IKabs(((-1.0)*new_r00)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r01)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r00))+IKsqr(((-1.0)*new_r01))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2(((-1.0)*new_r00), ((-1.0)*new_r01));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x607=IKsin(j2);
IkReal x608=IKcos(j2);
IkReal x609=((1.0)*x607);
evalcond[0]=(x607+new_r00);
evalcond[1]=(x607+new_r11);
evalcond[2]=(x608+new_r01);
evalcond[3]=((((-1.0)*x608))+new_r10);
evalcond[4]=(((new_r10*x607))+((new_r00*x608)));
evalcond[5]=(((new_r11*x608))+(((-1.0)*new_r01*x609)));
evalcond[6]=((1.0)+((new_r11*x607))+((new_r01*x608)));
evalcond[7]=((-1.0)+((new_r10*x608))+(((-1.0)*new_r00*x609)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((new_r10*new_r10)+(new_r00*new_r00));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
sj3=0;
cj3=1.0;
j3=0;
new_r10=0;
new_r00=0;
j2eval[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x611 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x611.valid){
continue;
}
IkReal x610=x611.value;
j2array[0]=((-1.0)*x610);
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
j2array[1]=((3.14159265358979)+(((-1.0)*x610)));
sj2array[1]=IKsin(j2array[1]);
cj2array[1]=IKcos(j2array[1]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
if( j2array[1] > IKPI )
{
j2array[1]-=IK2PI;
}
else if( j2array[1] < -IKPI )
{ j2array[1]+=IK2PI;
}
j2valid[1] = true;
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[1];
evalcond[0]=((((-1.0)*new_r01*(IKsin(j2))))+((new_r11*(IKcos(j2)))));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
sj3=0;
cj3=1.0;
j3=0;
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
j2eval[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j2]
} else
{
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x613 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x613.valid){
continue;
}
IkReal x612=x613.value;
j2array[0]=((-1.0)*x612);
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
j2array[1]=((3.14159265358979)+(((-1.0)*x612)));
sj2array[1]=IKsin(j2array[1]);
cj2array[1]=IKcos(j2array[1]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
if( j2array[1] > IKPI )
{
j2array[1]-=IK2PI;
}
else if( j2array[1] < -IKPI )
{ j2array[1]+=IK2PI;
}
j2valid[1] = true;
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[1];
evalcond[0]=((((-1.0)*new_r01*(IKsin(j2))))+((new_r11*(IKcos(j2)))));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j2]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x614=((1.0)*new_r10);
CheckValue<IkReal> x615 = IKatan2WithCheck(IkReal((((cj4*sj4))+(((-1.0)*new_r00*x614)))),IkReal(((((-1.0)*(cj4*cj4)))+(new_r10*new_r10))),IKFAST_ATAN2_MAGTHRESH);
if(!x615.valid){
continue;
}
CheckValue<IkReal> x616=IKPowWithIntegerCheck(IKsign((((cj4*new_r00))+(((-1.0)*sj4*x614)))),-1);
if(!x616.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x615.value)+(((1.5707963267949)*(x616.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x617=IKsin(j2);
IkReal x618=IKcos(j2);
IkReal x619=((1.0)*sj4);
IkReal x620=(cj4*x618);
IkReal x621=((1.0)*x617);
IkReal x622=(x617*x619);
evalcond[0]=(cj4+((new_r10*x617))+((new_r00*x618)));
evalcond[1]=(((sj4*x618))+new_r10+((cj4*x617)));
evalcond[2]=(sj4+(((-1.0)*new_r00*x621))+((new_r10*x618)));
evalcond[3]=((((-1.0)*new_r01*x621))+cj4+((new_r11*x618)));
evalcond[4]=((((-1.0)*x622))+x620+new_r00);
evalcond[5]=((((-1.0)*x622))+x620+new_r11);
evalcond[6]=(((new_r11*x617))+(((-1.0)*x619))+((new_r01*x618)));
evalcond[7]=((((-1.0)*x618*x619))+(((-1.0)*cj4*x621))+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x623=((1.0)*cj4);
CheckValue<IkReal> x624 = IKatan2WithCheck(IkReal((((cj4*new_r00))+(((-1.0)*new_r11*x623)))),IkReal(((((-1.0)*new_r01*x623))+(((-1.0)*new_r10*x623)))),IKFAST_ATAN2_MAGTHRESH);
if(!x624.valid){
continue;
}
CheckValue<IkReal> x625=IKPowWithIntegerCheck(IKsign((((new_r10*new_r11))+((new_r00*new_r01)))),-1);
if(!x625.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x624.value)+(((1.5707963267949)*(x625.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x626=IKsin(j2);
IkReal x627=IKcos(j2);
IkReal x628=((1.0)*sj4);
IkReal x629=(cj4*x627);
IkReal x630=((1.0)*x626);
IkReal x631=(x626*x628);
evalcond[0]=(cj4+((new_r00*x627))+((new_r10*x626)));
evalcond[1]=(((sj4*x627))+((cj4*x626))+new_r10);
evalcond[2]=(sj4+(((-1.0)*new_r00*x630))+((new_r10*x627)));
evalcond[3]=((((-1.0)*new_r01*x630))+cj4+((new_r11*x627)));
evalcond[4]=((((-1.0)*x631))+x629+new_r00);
evalcond[5]=((((-1.0)*x631))+x629+new_r11);
evalcond[6]=((((-1.0)*x628))+((new_r01*x627))+((new_r11*x626)));
evalcond[7]=((((-1.0)*cj4*x630))+(((-1.0)*x627*x628))+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x632=((1.0)*new_r10);
CheckValue<IkReal> x633=IKPowWithIntegerCheck(IKsign(((new_r10*new_r10)+(new_r00*new_r00))),-1);
if(!x633.valid){
continue;
}
CheckValue<IkReal> x634 = IKatan2WithCheck(IkReal((((new_r00*sj4))+(((-1.0)*cj4*x632)))),IkReal(((((-1.0)*sj4*x632))+(((-1.0)*cj4*new_r00)))),IKFAST_ATAN2_MAGTHRESH);
if(!x634.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x633.value)))+(x634.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x635=IKsin(j2);
IkReal x636=IKcos(j2);
IkReal x637=((1.0)*sj4);
IkReal x638=(cj4*x636);
IkReal x639=((1.0)*x635);
IkReal x640=(x635*x637);
evalcond[0]=(cj4+((new_r00*x636))+((new_r10*x635)));
evalcond[1]=(((sj4*x636))+((cj4*x635))+new_r10);
evalcond[2]=(sj4+(((-1.0)*new_r00*x639))+((new_r10*x636)));
evalcond[3]=((((-1.0)*new_r01*x639))+cj4+((new_r11*x636)));
evalcond[4]=((((-1.0)*x640))+x638+new_r00);
evalcond[5]=((((-1.0)*x640))+x638+new_r11);
evalcond[6]=((((-1.0)*x637))+((new_r01*x636))+((new_r11*x635)));
evalcond[7]=((((-1.0)*cj4*x639))+(((-1.0)*x636*x637))+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j3)))), 6.28318530717959)));
evalcond[1]=new_r21;
evalcond[2]=new_r02;
evalcond[3]=new_r12;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[3];
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
IkReal x641=((1.0)*sj4);
IkReal x642=(((new_r10*new_r11))+((new_r00*new_r01)));
j2eval[0]=x642;
j2eval[1]=((IKabs((((new_r01*sj4))+(((-1.0)*new_r10*x641)))))+(IKabs(((((-1.0)*new_r11*x641))+(((-1.0)*new_r00*x641))))));
j2eval[2]=IKsign(x642);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[3];
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
IkReal x643=((1.0)*new_r11);
IkReal x644=((new_r01*new_r01)+(new_r11*new_r11));
j2eval[0]=x644;
j2eval[1]=((IKabs(((((-1.0)*sj4*x643))+((cj4*new_r01)))))+(IKabs(((((-1.0)*new_r01*sj4))+(((-1.0)*cj4*x643))))));
j2eval[2]=IKsign(x644);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[3];
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
IkReal x645=(((cj4*new_r01))+((new_r11*sj4)));
j2eval[0]=x645;
j2eval[1]=((IKabs(((-1.0)+((new_r01*new_r10))+(cj4*cj4))))+(IKabs(((((-1.0)*cj4*sj4))+(((-1.0)*new_r10*new_r11))))));
j2eval[2]=IKsign(x645);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[1];
bool bgotonextstatement = true;
do
{
IkReal x647 = ((new_r01*new_r01)+(new_r11*new_r11));
if(IKabs(x647)==0){
continue;
}
IkReal x646=pow(x647,-0.5);
CheckValue<IkReal> x648 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x648.valid){
continue;
}
IkReal gconst56=((-1.0)*(x648.value));
IkReal gconst57=((-1.0)*new_r01*x646);
IkReal gconst58=(new_r11*x646);
CheckValue<IkReal> x649 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x649.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((x649.value)+j4)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[3];
CheckValue<IkReal> x652 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x652.valid){
continue;
}
IkReal x650=((-1.0)*(x652.value));
IkReal x651=x646;
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x650;
IkReal gconst56=x650;
IkReal gconst57=((-1.0)*new_r01*x651);
IkReal gconst58=(new_r11*x651);
IkReal x653=new_r01*new_r01;
IkReal x654=(new_r00*new_r01);
IkReal x655=(((new_r10*new_r11))+x654);
IkReal x656=x646;
IkReal x657=(new_r01*x656);
j2eval[0]=x655;
j2eval[1]=((IKabs((((x654*x656))+((new_r11*x657)))))+(IKabs(((((-1.0)*x653*x656))+((new_r10*x657))))));
j2eval[2]=IKsign(x655);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[2];
CheckValue<IkReal> x660 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x660.valid){
continue;
}
IkReal x658=((-1.0)*(x660.value));
IkReal x659=x646;
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x658;
IkReal gconst56=x658;
IkReal gconst57=((-1.0)*new_r01*x659);
IkReal gconst58=(new_r11*x659);
IkReal x661=((new_r01*new_r01)+(new_r11*new_r11));
j2eval[0]=x661;
j2eval[1]=IKsign(x661);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 )
{
{
IkReal j2eval[1];
CheckValue<IkReal> x664 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x664.valid){
continue;
}
IkReal x662=((-1.0)*(x664.value));
IkReal x663=x646;
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x662;
IkReal gconst56=x662;
IkReal gconst57=((-1.0)*new_r01*x663);
IkReal gconst58=(new_r11*x663);
IkReal x665=new_r01*new_r01;
IkReal x666=new_r11*new_r11;
IkReal x667=((1.0)*x665);
CheckValue<IkReal> x673=IKPowWithIntegerCheck((x665+x666),-1);
if(!x673.valid){
continue;
}
IkReal x668=x673.value;
CheckValue<IkReal> x674=IKPowWithIntegerCheck(((((-1.0)*x666))+(((-1.0)*x667))),-1);
if(!x674.valid){
continue;
}
IkReal x669=x674.value;
IkReal x670=((1.0)*x669);
IkReal x671=(new_r11*x670);
IkReal x672=(new_r01*x670);
j2eval[0]=((IKabs(((((-1.0)*new_r01*x671))+(((-1.0)*new_r01*x671*(new_r11*new_r11)))+(((-1.0)*x671*(new_r01*new_r01*new_r01))))))+(IKabs((((x668*(x666*x666)))+((x665*x666*x668))+(((-1.0)*x667*x668))))));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[2];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
CheckValue<IkReal> x676 = IKatan2WithCheck(IkReal(new_r01),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x676.valid){
continue;
}
IkReal x675=((-1.0)*(x676.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x675;
new_r11=0;
new_r00=0;
IkReal gconst56=x675;
IkReal x677 = new_r01*new_r01;
if(IKabs(x677)==0){
continue;
}
IkReal gconst57=((-1.0)*new_r01*(pow(x677,-0.5)));
IkReal gconst58=0;
j2eval[0]=new_r10;
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x678=IKPowWithIntegerCheck(gconst57,-1);
if(!x678.valid){
continue;
}
cj2array[0]=((-1.0)*new_r10*(x678.value));
if( cj2array[0] >= -1-IKFAST_SINCOS_THRESH && cj2array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j2valid[0] = j2valid[1] = true;
j2array[0] = IKacos(cj2array[0]);
sj2array[0] = IKsin(j2array[0]);
cj2array[1] = cj2array[0];
j2array[1] = -j2array[0];
sj2array[1] = -sj2array[0];
}
else if( isnan(cj2array[0]) )
{
// probably any value will work
j2valid[0] = true;
cj2array[0] = 1; sj2array[0] = 0; j2array[0] = 0;
}
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[6];
IkReal x679=IKsin(j2);
IkReal x680=IKcos(j2);
IkReal x681=((-1.0)*x679);
evalcond[0]=(new_r10*x679);
evalcond[1]=(new_r01*x681);
evalcond[2]=(gconst57*x681);
evalcond[3]=(gconst57+((new_r10*x680)));
evalcond[4]=(gconst57+((new_r01*x680)));
evalcond[5]=(((gconst57*x680))+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x682=IKPowWithIntegerCheck(new_r10,-1);
if(!x682.valid){
continue;
}
cj2array[0]=((-1.0)*gconst57*(x682.value));
if( cj2array[0] >= -1-IKFAST_SINCOS_THRESH && cj2array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j2valid[0] = j2valid[1] = true;
j2array[0] = IKacos(cj2array[0]);
sj2array[0] = IKsin(j2array[0]);
cj2array[1] = cj2array[0];
j2array[1] = -j2array[0];
sj2array[1] = -sj2array[0];
}
else if( isnan(cj2array[0]) )
{
// probably any value will work
j2valid[0] = true;
cj2array[0] = 1; sj2array[0] = 0; j2array[0] = 0;
}
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[6];
IkReal x683=IKsin(j2);
IkReal x684=IKcos(j2);
IkReal x685=(gconst57*x684);
IkReal x686=((-1.0)*x683);
evalcond[0]=(new_r10*x683);
evalcond[1]=(new_r01*x686);
evalcond[2]=(gconst57*x686);
evalcond[3]=(x685+new_r10);
evalcond[4]=(gconst57+((new_r01*x684)));
evalcond[5]=(x685+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r00)));
evalcond[1]=gconst57;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[3];
CheckValue<IkReal> x688 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x688.valid){
continue;
}
IkReal x687=((-1.0)*(x688.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x687;
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
IkReal gconst56=x687;
IkReal gconst57=((-1.0)*new_r01);
IkReal gconst58=new_r11;
j2eval[0]=-1.0;
j2eval[1]=((IKabs((new_r01*new_r11)))+(IKabs(((1.0)+(((-1.0)*(new_r01*new_r01)))))));
j2eval[2]=-1.0;
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[3];
CheckValue<IkReal> x690 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x690.valid){
continue;
}
IkReal x689=((-1.0)*(x690.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x689;
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
IkReal gconst56=x689;
IkReal gconst57=((-1.0)*new_r01);
IkReal gconst58=new_r11;
j2eval[0]=-1.0;
j2eval[1]=-1.0;
j2eval[2]=((IKabs((new_r01*new_r11)))+(IKabs(((1.0)+(((-1.0)*(new_r01*new_r01)))))));
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[3];
CheckValue<IkReal> x692 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x692.valid){
continue;
}
IkReal x691=((-1.0)*(x692.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x691;
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
IkReal gconst56=x691;
IkReal gconst57=((-1.0)*new_r01);
IkReal gconst58=new_r11;
j2eval[0]=1.0;
j2eval[1]=((((0.5)*(IKabs(((-1.0)+(((2.0)*(new_r01*new_r01))))))))+(IKabs((new_r01*new_r11))));
j2eval[2]=1.0;
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x693=((1.0)*new_r11);
CheckValue<IkReal> x694=IKPowWithIntegerCheck(IKsign(((new_r01*new_r01)+(new_r11*new_r11))),-1);
if(!x694.valid){
continue;
}
CheckValue<IkReal> x695 = IKatan2WithCheck(IkReal(((((-1.0)*gconst57*x693))+((gconst58*new_r01)))),IkReal(((((-1.0)*gconst57*new_r01))+(((-1.0)*gconst58*x693)))),IKFAST_ATAN2_MAGTHRESH);
if(!x695.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x694.value)))+(x695.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[6];
IkReal x696=IKcos(j2);
IkReal x697=IKsin(j2);
IkReal x698=(gconst57*x696);
IkReal x699=(gconst58*x696);
IkReal x700=((1.0)*x697);
IkReal x701=(gconst58*x700);
evalcond[0]=((((-1.0)*x701))+x698);
evalcond[1]=(gconst57+((new_r11*x697))+((new_r01*x696)));
evalcond[2]=(x699+((gconst57*x697))+new_r11);
evalcond[3]=(gconst58+((new_r11*x696))+(((-1.0)*new_r01*x700)));
evalcond[4]=((((-1.0)*gconst57*x700))+(((-1.0)*x699)));
evalcond[5]=((((-1.0)*x701))+x698+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x702 = IKatan2WithCheck(IkReal((gconst57*new_r11)),IkReal((gconst58*new_r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x702.valid){
continue;
}
CheckValue<IkReal> x703=IKPowWithIntegerCheck(IKsign(((((-1.0)*(gconst57*gconst57)))+(((-1.0)*(gconst58*gconst58))))),-1);
if(!x703.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x702.value)+(((1.5707963267949)*(x703.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[6];
IkReal x704=IKcos(j2);
IkReal x705=IKsin(j2);
IkReal x706=(gconst57*x704);
IkReal x707=(gconst58*x704);
IkReal x708=((1.0)*x705);
IkReal x709=(gconst58*x708);
evalcond[0]=((((-1.0)*x709))+x706);
evalcond[1]=(((new_r01*x704))+gconst57+((new_r11*x705)));
evalcond[2]=(((gconst57*x705))+x707+new_r11);
evalcond[3]=(gconst58+((new_r11*x704))+(((-1.0)*new_r01*x708)));
evalcond[4]=((((-1.0)*gconst57*x708))+(((-1.0)*x707)));
evalcond[5]=((((-1.0)*x709))+x706+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x710 = IKatan2WithCheck(IkReal((gconst57*gconst58)),IkReal(gconst58*gconst58),IKFAST_ATAN2_MAGTHRESH);
if(!x710.valid){
continue;
}
CheckValue<IkReal> x711=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst58*new_r11))+((gconst57*new_r01)))),-1);
if(!x711.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x710.value)+(((1.5707963267949)*(x711.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[6];
IkReal x712=IKcos(j2);
IkReal x713=IKsin(j2);
IkReal x714=(gconst57*x712);
IkReal x715=(gconst58*x712);
IkReal x716=((1.0)*x713);
IkReal x717=(gconst58*x716);
evalcond[0]=((((-1.0)*x717))+x714);
evalcond[1]=(((new_r01*x712))+gconst57+((new_r11*x713)));
evalcond[2]=(((gconst57*x713))+x715+new_r11);
evalcond[3]=(gconst58+((new_r11*x712))+(((-1.0)*new_r01*x716)));
evalcond[4]=((((-1.0)*gconst57*x716))+(((-1.0)*x715)));
evalcond[5]=((((-1.0)*x717))+x714+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x718=IKPowWithIntegerCheck(gconst58,-1);
if(!x718.valid){
continue;
}
cj2array[0]=(new_r00*(x718.value));
if( cj2array[0] >= -1-IKFAST_SINCOS_THRESH && cj2array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j2valid[0] = j2valid[1] = true;
j2array[0] = IKacos(cj2array[0]);
sj2array[0] = IKsin(j2array[0]);
cj2array[1] = cj2array[0];
j2array[1] = -j2array[0];
sj2array[1] = -sj2array[0];
}
else if( isnan(cj2array[0]) )
{
// probably any value will work
j2valid[0] = true;
cj2array[0] = 1; sj2array[0] = 0; j2array[0] = 0;
}
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[6];
IkReal x719=IKsin(j2);
IkReal x720=IKcos(j2);
IkReal x721=((-1.0)*x719);
evalcond[0]=(new_r11*x719);
evalcond[1]=(new_r00*x721);
evalcond[2]=(gconst58*x721);
evalcond[3]=(gconst58+((new_r11*x720)));
evalcond[4]=(((gconst58*x720))+new_r11);
evalcond[5]=((((-1.0)*gconst58))+((new_r00*x720)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r00))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
CheckValue<IkReal> x723 = IKatan2WithCheck(IkReal(0),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x723.valid){
continue;
}
IkReal x722=((-1.0)*(x723.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x722;
new_r00=0;
new_r01=0;
new_r12=0;
new_r22=0;
IkReal gconst56=x722;
IkReal gconst57=0;
IkReal x724 = ((1.0)+(((-1.0)*(new_r10*new_r10))));
if(IKabs(x724)==0){
continue;
}
IkReal gconst58=(new_r11*(pow(x724,-0.5)));
j2eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal j2eval[1];
CheckValue<IkReal> x726 = IKatan2WithCheck(IkReal(0),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x726.valid){
continue;
}
IkReal x725=((-1.0)*(x726.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x725;
new_r00=0;
new_r01=0;
new_r12=0;
new_r22=0;
IkReal gconst56=x725;
IkReal gconst57=0;
IkReal x727 = ((1.0)+(((-1.0)*(new_r10*new_r10))));
if(IKabs(x727)==0){
continue;
}
IkReal gconst58=(new_r11*(pow(x727,-0.5)));
j2eval[0]=new_r11;
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal j2eval[2];
CheckValue<IkReal> x729 = IKatan2WithCheck(IkReal(0),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x729.valid){
continue;
}
IkReal x728=((-1.0)*(x729.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x728;
new_r00=0;
new_r01=0;
new_r12=0;
new_r22=0;
IkReal gconst56=x728;
IkReal gconst57=0;
IkReal x730 = ((1.0)+(((-1.0)*(new_r10*new_r10))));
if(IKabs(x730)==0){
continue;
}
IkReal gconst58=(new_r11*(pow(x730,-0.5)));
j2eval[0]=new_r10;
j2eval[1]=new_r11;
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x731=IKPowWithIntegerCheck(new_r10,-1);
if(!x731.valid){
continue;
}
CheckValue<IkReal> x732=IKPowWithIntegerCheck(new_r11,-1);
if(!x732.valid){
continue;
}
if( IKabs((gconst58*(x731.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*gconst58*(x732.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((gconst58*(x731.value)))+IKsqr(((-1.0)*gconst58*(x732.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2((gconst58*(x731.value)), ((-1.0)*gconst58*(x732.value)));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x733=IKcos(j2);
IkReal x734=IKsin(j2);
IkReal x735=((1.0)*gconst58);
IkReal x736=((-1.0)*gconst58);
evalcond[0]=(new_r10*x733);
evalcond[1]=(new_r11*x734);
evalcond[2]=(x733*x736);
evalcond[3]=(x734*x736);
evalcond[4]=(gconst58+((new_r11*x733)));
evalcond[5]=(new_r11+((gconst58*x733)));
evalcond[6]=((((-1.0)*x734*x735))+new_r10);
evalcond[7]=((((-1.0)*x735))+((new_r10*x734)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x737=IKPowWithIntegerCheck(gconst58,-1);
if(!x737.valid){
continue;
}
CheckValue<IkReal> x738=IKPowWithIntegerCheck(new_r11,-1);
if(!x738.valid){
continue;
}
if( IKabs((new_r10*(x737.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*gconst58*(x738.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((new_r10*(x737.value)))+IKsqr(((-1.0)*gconst58*(x738.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2((new_r10*(x737.value)), ((-1.0)*gconst58*(x738.value)));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x739=IKcos(j2);
IkReal x740=IKsin(j2);
IkReal x741=((1.0)*gconst58);
IkReal x742=((-1.0)*gconst58);
evalcond[0]=(new_r10*x739);
evalcond[1]=(new_r11*x740);
evalcond[2]=(x739*x742);
evalcond[3]=(x740*x742);
evalcond[4]=(gconst58+((new_r11*x739)));
evalcond[5]=(new_r11+((gconst58*x739)));
evalcond[6]=((((-1.0)*x740*x741))+new_r10);
evalcond[7]=(((new_r10*x740))+(((-1.0)*x741)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x743 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x743.valid){
continue;
}
CheckValue<IkReal> x744=IKPowWithIntegerCheck(IKsign(gconst58),-1);
if(!x744.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x743.value)+(((1.5707963267949)*(x744.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x745=IKcos(j2);
IkReal x746=IKsin(j2);
IkReal x747=((1.0)*gconst58);
IkReal x748=((-1.0)*gconst58);
evalcond[0]=(new_r10*x745);
evalcond[1]=(new_r11*x746);
evalcond[2]=(x745*x748);
evalcond[3]=(x746*x748);
evalcond[4]=(gconst58+((new_r11*x745)));
evalcond[5]=(((gconst58*x745))+new_r11);
evalcond[6]=((((-1.0)*x746*x747))+new_r10);
evalcond[7]=(((new_r10*x746))+(((-1.0)*x747)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=IKabs(new_r01);
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
CheckValue<IkReal> x750 = IKatan2WithCheck(IkReal(0),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x750.valid){
continue;
}
IkReal x749=((-1.0)*(x750.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x749;
new_r01=0;
IkReal gconst56=x749;
IkReal gconst57=0;
IkReal x751 = new_r11*new_r11;
if(IKabs(x751)==0){
continue;
}
IkReal gconst58=(new_r11*(pow(x751,-0.5)));
j2eval[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal j2eval[1];
CheckValue<IkReal> x753 = IKatan2WithCheck(IkReal(0),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x753.valid){
continue;
}
IkReal x752=((-1.0)*(x753.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x752;
new_r01=0;
IkReal gconst56=x752;
IkReal gconst57=0;
IkReal x754 = new_r11*new_r11;
if(IKabs(x754)==0){
continue;
}
IkReal gconst58=(new_r11*(pow(x754,-0.5)));
j2eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal j2eval[1];
CheckValue<IkReal> x756 = IKatan2WithCheck(IkReal(0),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x756.valid){
continue;
}
IkReal x755=((-1.0)*(x756.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst57;
cj4=gconst58;
j4=x755;
new_r01=0;
IkReal gconst56=x755;
IkReal gconst57=0;
IkReal x757 = new_r11*new_r11;
if(IKabs(x757)==0){
continue;
}
IkReal gconst58=(new_r11*(pow(x757,-0.5)));
j2eval[0]=new_r11;
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x758=IKPowWithIntegerCheck(gconst58,-1);
if(!x758.valid){
continue;
}
CheckValue<IkReal> x759=IKPowWithIntegerCheck(new_r11,-1);
if(!x759.valid){
continue;
}
if( IKabs((new_r10*(x758.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*gconst58*(x759.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((new_r10*(x758.value)))+IKsqr(((-1.0)*gconst58*(x759.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2((new_r10*(x758.value)), ((-1.0)*gconst58*(x759.value)));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x760=IKsin(j2);
IkReal x761=IKcos(j2);
IkReal x762=((1.0)*gconst58);
evalcond[0]=(new_r11*x760);
evalcond[1]=((-1.0)*gconst58*x760);
evalcond[2]=(((new_r11*x761))+gconst58);
evalcond[3]=(((gconst58*x761))+new_r11);
evalcond[4]=(new_r10+(((-1.0)*x760*x762)));
evalcond[5]=(new_r00+(((-1.0)*x761*x762)));
evalcond[6]=(((new_r10*x761))+(((-1.0)*new_r00*x760)));
evalcond[7]=(((new_r10*x760))+(((-1.0)*x762))+((new_r00*x761)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x763 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x763.valid){
continue;
}
CheckValue<IkReal> x764=IKPowWithIntegerCheck(IKsign(gconst58),-1);
if(!x764.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x763.value)+(((1.5707963267949)*(x764.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x765=IKsin(j2);
IkReal x766=IKcos(j2);
IkReal x767=((1.0)*gconst58);
evalcond[0]=(new_r11*x765);
evalcond[1]=((-1.0)*gconst58*x765);
evalcond[2]=(((new_r11*x766))+gconst58);
evalcond[3]=(((gconst58*x766))+new_r11);
evalcond[4]=((((-1.0)*x765*x767))+new_r10);
evalcond[5]=((((-1.0)*x766*x767))+new_r00);
evalcond[6]=(((new_r10*x766))+(((-1.0)*new_r00*x765)));
evalcond[7]=(((new_r10*x765))+(((-1.0)*x767))+((new_r00*x766)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x768 = IKatan2WithCheck(IkReal(new_r10),IkReal(new_r00),IKFAST_ATAN2_MAGTHRESH);
if(!x768.valid){
continue;
}
CheckValue<IkReal> x769=IKPowWithIntegerCheck(IKsign(gconst58),-1);
if(!x769.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x768.value)+(((1.5707963267949)*(x769.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x770=IKsin(j2);
IkReal x771=IKcos(j2);
IkReal x772=((1.0)*gconst58);
evalcond[0]=(new_r11*x770);
evalcond[1]=((-1.0)*gconst58*x770);
evalcond[2]=(gconst58+((new_r11*x771)));
evalcond[3]=(((gconst58*x771))+new_r11);
evalcond[4]=(new_r10+(((-1.0)*x770*x772)));
evalcond[5]=((((-1.0)*x771*x772))+new_r00);
evalcond[6]=((((-1.0)*new_r00*x770))+((new_r10*x771)));
evalcond[7]=(((new_r00*x771))+((new_r10*x770))+(((-1.0)*x772)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j2]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x773=((1.0)*new_r11);
CheckValue<IkReal> x774 = IKatan2WithCheck(IkReal(((((-1.0)*new_r01*x773))+((gconst57*gconst58)))),IkReal(((((-1.0)*(gconst57*gconst57)))+(new_r11*new_r11))),IKFAST_ATAN2_MAGTHRESH);
if(!x774.valid){
continue;
}
CheckValue<IkReal> x775=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst58*x773))+((gconst57*new_r01)))),-1);
if(!x775.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x774.value)+(((1.5707963267949)*(x775.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x776=IKsin(j2);
IkReal x777=IKcos(j2);
IkReal x778=((1.0)*gconst58);
IkReal x779=(gconst57*x777);
IkReal x780=((1.0)*x776);
IkReal x781=(x776*x778);
evalcond[0]=(gconst57+((new_r11*x776))+((new_r01*x777)));
evalcond[1]=(((gconst57*x776))+((gconst58*x777))+new_r11);
evalcond[2]=(gconst57+((new_r10*x777))+(((-1.0)*new_r00*x780)));
evalcond[3]=((((-1.0)*new_r01*x780))+gconst58+((new_r11*x777)));
evalcond[4]=((((-1.0)*x781))+x779+new_r10);
evalcond[5]=((((-1.0)*x781))+x779+new_r01);
evalcond[6]=(((new_r00*x777))+((new_r10*x776))+(((-1.0)*x778)));
evalcond[7]=((((-1.0)*gconst57*x780))+new_r00+(((-1.0)*x777*x778)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x782=((1.0)*new_r11);
CheckValue<IkReal> x783=IKPowWithIntegerCheck(IKsign(((new_r01*new_r01)+(new_r11*new_r11))),-1);
if(!x783.valid){
continue;
}
CheckValue<IkReal> x784 = IKatan2WithCheck(IkReal(((((-1.0)*gconst57*x782))+((gconst58*new_r01)))),IkReal(((((-1.0)*gconst58*x782))+(((-1.0)*gconst57*new_r01)))),IKFAST_ATAN2_MAGTHRESH);
if(!x784.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x783.value)))+(x784.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x785=IKsin(j2);
IkReal x786=IKcos(j2);
IkReal x787=((1.0)*gconst58);
IkReal x788=(gconst57*x786);
IkReal x789=((1.0)*x785);
IkReal x790=(x785*x787);
evalcond[0]=(((new_r11*x785))+gconst57+((new_r01*x786)));
evalcond[1]=(((gconst58*x786))+new_r11+((gconst57*x785)));
evalcond[2]=(((new_r10*x786))+gconst57+(((-1.0)*new_r00*x789)));
evalcond[3]=((((-1.0)*new_r01*x789))+((new_r11*x786))+gconst58);
evalcond[4]=((((-1.0)*x790))+x788+new_r10);
evalcond[5]=((((-1.0)*x790))+x788+new_r01);
evalcond[6]=(((new_r10*x785))+(((-1.0)*x787))+((new_r00*x786)));
evalcond[7]=((((-1.0)*gconst57*x789))+(((-1.0)*x786*x787))+new_r00);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x791=((1.0)*gconst57);
CheckValue<IkReal> x792 = IKatan2WithCheck(IkReal(((((-1.0)*new_r10*x791))+((gconst57*new_r01)))),IkReal(((((-1.0)*new_r11*x791))+(((-1.0)*new_r00*x791)))),IKFAST_ATAN2_MAGTHRESH);
if(!x792.valid){
continue;
}
CheckValue<IkReal> x793=IKPowWithIntegerCheck(IKsign((((new_r10*new_r11))+((new_r00*new_r01)))),-1);
if(!x793.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x792.value)+(((1.5707963267949)*(x793.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x794=IKsin(j2);
IkReal x795=IKcos(j2);
IkReal x796=((1.0)*gconst58);
IkReal x797=(gconst57*x795);
IkReal x798=((1.0)*x794);
IkReal x799=(x794*x796);
evalcond[0]=(((new_r11*x794))+gconst57+((new_r01*x795)));
evalcond[1]=(((gconst58*x795))+((gconst57*x794))+new_r11);
evalcond[2]=(((new_r10*x795))+gconst57+(((-1.0)*new_r00*x798)));
evalcond[3]=((((-1.0)*new_r01*x798))+((new_r11*x795))+gconst58);
evalcond[4]=((((-1.0)*x799))+x797+new_r10);
evalcond[5]=((((-1.0)*x799))+x797+new_r01);
evalcond[6]=((((-1.0)*x796))+((new_r10*x794))+((new_r00*x795)));
evalcond[7]=((((-1.0)*x795*x796))+(((-1.0)*gconst57*x798))+new_r00);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x801 = ((new_r01*new_r01)+(new_r11*new_r11));
if(IKabs(x801)==0){
continue;
}
IkReal x800=pow(x801,-0.5);
CheckValue<IkReal> x802 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x802.valid){
continue;
}
IkReal gconst59=((3.14159265358979)+(((-1.0)*(x802.value))));
IkReal gconst60=((1.0)*new_r01*x800);
IkReal gconst61=((-1.0)*new_r11*x800);
CheckValue<IkReal> x803 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x803.valid){
continue;
}
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+(x803.value)+j4)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[3];
CheckValue<IkReal> x806 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x806.valid){
continue;
}
IkReal x804=((1.0)*(x806.value));
IkReal x805=x800;
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x804)));
IkReal gconst59=((3.14159265358979)+(((-1.0)*x804)));
IkReal gconst60=((1.0)*new_r01*x805);
IkReal gconst61=((-1.0)*new_r11*x805);
IkReal x807=new_r01*new_r01;
IkReal x808=(((new_r10*new_r11))+((new_r00*new_r01)));
IkReal x809=x800;
IkReal x810=((1.0)*new_r01*x809);
j2eval[0]=x808;
j2eval[1]=((IKabs(((((-1.0)*new_r10*x810))+((x807*x809)))))+(IKabs(((((-1.0)*new_r11*x810))+(((-1.0)*new_r00*x810))))));
j2eval[2]=IKsign(x808);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[2];
CheckValue<IkReal> x813 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x813.valid){
continue;
}
IkReal x811=((1.0)*(x813.value));
IkReal x812=x800;
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x811)));
IkReal gconst59=((3.14159265358979)+(((-1.0)*x811)));
IkReal gconst60=((1.0)*new_r01*x812);
IkReal gconst61=((-1.0)*new_r11*x812);
IkReal x814=((new_r01*new_r01)+(new_r11*new_r11));
j2eval[0]=x814;
j2eval[1]=IKsign(x814);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 )
{
{
IkReal j2eval[1];
CheckValue<IkReal> x817 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x817.valid){
continue;
}
IkReal x815=((1.0)*(x817.value));
IkReal x816=x800;
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x815)));
IkReal gconst59=((3.14159265358979)+(((-1.0)*x815)));
IkReal gconst60=((1.0)*new_r01*x816);
IkReal gconst61=((-1.0)*new_r11*x816);
IkReal x818=new_r01*new_r01;
IkReal x819=new_r11*new_r11;
IkReal x820=((1.0)*x818);
CheckValue<IkReal> x826=IKPowWithIntegerCheck((x818+x819),-1);
if(!x826.valid){
continue;
}
IkReal x821=x826.value;
CheckValue<IkReal> x827=IKPowWithIntegerCheck(((((-1.0)*x820))+(((-1.0)*x819))),-1);
if(!x827.valid){
continue;
}
IkReal x822=x827.value;
IkReal x823=((1.0)*x822);
IkReal x824=(new_r11*x823);
IkReal x825=(new_r01*x823);
j2eval[0]=((IKabs((((x821*(x819*x819)))+((x818*x819*x821))+(((-1.0)*x820*x821)))))+(IKabs(((((-1.0)*new_r01*x824*(new_r11*new_r11)))+(((-1.0)*x824*(new_r01*new_r01*new_r01)))+(((-1.0)*new_r01*x824))))));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[2];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
CheckValue<IkReal> x829 = IKatan2WithCheck(IkReal(new_r01),IkReal(0),IKFAST_ATAN2_MAGTHRESH);
if(!x829.valid){
continue;
}
IkReal x828=((1.0)*(x829.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x828)));
new_r11=0;
new_r00=0;
IkReal gconst59=((3.14159265358979)+(((-1.0)*x828)));
IkReal x830 = new_r01*new_r01;
if(IKabs(x830)==0){
continue;
}
IkReal gconst60=((1.0)*new_r01*(pow(x830,-0.5)));
IkReal gconst61=0;
j2eval[0]=new_r10;
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x831=IKPowWithIntegerCheck(gconst60,-1);
if(!x831.valid){
continue;
}
cj2array[0]=((-1.0)*new_r10*(x831.value));
if( cj2array[0] >= -1-IKFAST_SINCOS_THRESH && cj2array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j2valid[0] = j2valid[1] = true;
j2array[0] = IKacos(cj2array[0]);
sj2array[0] = IKsin(j2array[0]);
cj2array[1] = cj2array[0];
j2array[1] = -j2array[0];
sj2array[1] = -sj2array[0];
}
else if( isnan(cj2array[0]) )
{
// probably any value will work
j2valid[0] = true;
cj2array[0] = 1; sj2array[0] = 0; j2array[0] = 0;
}
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[6];
IkReal x832=IKsin(j2);
IkReal x833=IKcos(j2);
IkReal x834=((-1.0)*x832);
evalcond[0]=(new_r10*x832);
evalcond[1]=(new_r01*x834);
evalcond[2]=(gconst60*x834);
evalcond[3]=(gconst60+((new_r10*x833)));
evalcond[4]=(((new_r01*x833))+gconst60);
evalcond[5]=(((gconst60*x833))+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
} else
{
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x835=IKPowWithIntegerCheck(new_r10,-1);
if(!x835.valid){
continue;
}
cj2array[0]=((-1.0)*gconst60*(x835.value));
if( cj2array[0] >= -1-IKFAST_SINCOS_THRESH && cj2array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j2valid[0] = j2valid[1] = true;
j2array[0] = IKacos(cj2array[0]);
sj2array[0] = IKsin(j2array[0]);
cj2array[1] = cj2array[0];
j2array[1] = -j2array[0];
sj2array[1] = -sj2array[0];
}
else if( isnan(cj2array[0]) )
{
// probably any value will work
j2valid[0] = true;
cj2array[0] = 1; sj2array[0] = 0; j2array[0] = 0;
}
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[6];
IkReal x836=IKsin(j2);
IkReal x837=IKcos(j2);
IkReal x838=(gconst60*x837);
IkReal x839=((-1.0)*x836);
evalcond[0]=(new_r10*x836);
evalcond[1]=(new_r01*x839);
evalcond[2]=(gconst60*x839);
evalcond[3]=(new_r10+x838);
evalcond[4]=(((new_r01*x837))+gconst60);
evalcond[5]=(new_r01+x838);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r00)));
evalcond[1]=gconst60;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[3];
CheckValue<IkReal> x841 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x841.valid){
continue;
}
IkReal x840=((1.0)*(x841.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x840)));
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
IkReal gconst59=((3.14159265358979)+(((-1.0)*x840)));
IkReal gconst60=((1.0)*new_r01);
IkReal gconst61=((-1.0)*new_r11);
j2eval[0]=1.0;
j2eval[1]=((IKabs(((1.0)+(((-1.0)*(new_r01*new_r01))))))+(IKabs(((1.0)*new_r01*new_r11))));
j2eval[2]=1.0;
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[3];
CheckValue<IkReal> x843 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x843.valid){
continue;
}
IkReal x842=((1.0)*(x843.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x842)));
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
IkReal gconst59=((3.14159265358979)+(((-1.0)*x842)));
IkReal gconst60=((1.0)*new_r01);
IkReal gconst61=((-1.0)*new_r11);
j2eval[0]=-1.0;
j2eval[1]=-1.0;
j2eval[2]=((IKabs(((-1.0)+(new_r01*new_r01))))+(IKabs(((1.0)*new_r01*new_r11))));
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[3];
CheckValue<IkReal> x845 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x845.valid){
continue;
}
IkReal x844=((1.0)*(x845.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x844)));
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
IkReal gconst59=((3.14159265358979)+(((-1.0)*x844)));
IkReal gconst60=((1.0)*new_r01);
IkReal gconst61=((-1.0)*new_r11);
j2eval[0]=1.0;
j2eval[1]=1.0;
j2eval[2]=((IKabs(((2.0)*new_r01*new_r11)))+(IKabs(((1.0)+(((-2.0)*(new_r01*new_r01)))))));
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x846=((1.0)*gconst60);
CheckValue<IkReal> x847=IKPowWithIntegerCheck(IKsign(((new_r01*new_r01)+(new_r11*new_r11))),-1);
if(!x847.valid){
continue;
}
CheckValue<IkReal> x848 = IKatan2WithCheck(IkReal(((((-1.0)*new_r11*x846))+((gconst61*new_r01)))),IkReal(((((-1.0)*gconst61*new_r11))+(((-1.0)*new_r01*x846)))),IKFAST_ATAN2_MAGTHRESH);
if(!x848.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x847.value)))+(x848.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[6];
IkReal x849=IKcos(j2);
IkReal x850=IKsin(j2);
IkReal x851=(gconst60*x849);
IkReal x852=((1.0)*x850);
IkReal x853=(gconst61*x849);
IkReal x854=(gconst61*x852);
evalcond[0]=((((-1.0)*x854))+x851);
evalcond[1]=(gconst60+((new_r01*x849))+((new_r11*x850)));
evalcond[2]=(new_r11+x853+((gconst60*x850)));
evalcond[3]=((((-1.0)*new_r01*x852))+gconst61+((new_r11*x849)));
evalcond[4]=((((-1.0)*gconst60*x852))+(((-1.0)*x853)));
evalcond[5]=((((-1.0)*x854))+new_r01+x851);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x855 = IKatan2WithCheck(IkReal((gconst60*new_r11)),IkReal((gconst61*new_r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x855.valid){
continue;
}
CheckValue<IkReal> x856=IKPowWithIntegerCheck(IKsign(((((-1.0)*(gconst60*gconst60)))+(((-1.0)*(gconst61*gconst61))))),-1);
if(!x856.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x855.value)+(((1.5707963267949)*(x856.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[6];
IkReal x857=IKcos(j2);
IkReal x858=IKsin(j2);
IkReal x859=(gconst60*x857);
IkReal x860=((1.0)*x858);
IkReal x861=(gconst61*x857);
IkReal x862=(gconst61*x860);
evalcond[0]=((((-1.0)*x862))+x859);
evalcond[1]=(gconst60+((new_r11*x858))+((new_r01*x857)));
evalcond[2]=(new_r11+x861+((gconst60*x858)));
evalcond[3]=((((-1.0)*new_r01*x860))+gconst61+((new_r11*x857)));
evalcond[4]=((((-1.0)*x861))+(((-1.0)*gconst60*x860)));
evalcond[5]=((((-1.0)*x862))+new_r01+x859);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x863=IKPowWithIntegerCheck(IKsign(((((-1.0)*gconst61*new_r11))+((gconst60*new_r01)))),-1);
if(!x863.valid){
continue;
}
CheckValue<IkReal> x864 = IKatan2WithCheck(IkReal((gconst60*gconst61)),IkReal(gconst61*gconst61),IKFAST_ATAN2_MAGTHRESH);
if(!x864.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x863.value)))+(x864.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[6];
IkReal x865=IKcos(j2);
IkReal x866=IKsin(j2);
IkReal x867=(gconst60*x865);
IkReal x868=((1.0)*x866);
IkReal x869=(gconst61*x865);
IkReal x870=(gconst61*x868);
evalcond[0]=(x867+(((-1.0)*x870)));
evalcond[1]=(((new_r01*x865))+gconst60+((new_r11*x866)));
evalcond[2]=(((gconst60*x866))+new_r11+x869);
evalcond[3]=((((-1.0)*new_r01*x868))+gconst61+((new_r11*x865)));
evalcond[4]=((((-1.0)*x869))+(((-1.0)*gconst60*x868)));
evalcond[5]=(new_r01+x867+(((-1.0)*x870)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x871=IKPowWithIntegerCheck(gconst61,-1);
if(!x871.valid){
continue;
}
cj2array[0]=(new_r00*(x871.value));
if( cj2array[0] >= -1-IKFAST_SINCOS_THRESH && cj2array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j2valid[0] = j2valid[1] = true;
j2array[0] = IKacos(cj2array[0]);
sj2array[0] = IKsin(j2array[0]);
cj2array[1] = cj2array[0];
j2array[1] = -j2array[0];
sj2array[1] = -sj2array[0];
}
else if( isnan(cj2array[0]) )
{
// probably any value will work
j2valid[0] = true;
cj2array[0] = 1; sj2array[0] = 0; j2array[0] = 0;
}
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[6];
IkReal x872=IKsin(j2);
IkReal x873=IKcos(j2);
IkReal x874=((-1.0)*x872);
evalcond[0]=(new_r11*x872);
evalcond[1]=(new_r00*x874);
evalcond[2]=(gconst61*x874);
evalcond[3]=(gconst61+((new_r11*x873)));
evalcond[4]=(new_r11+((gconst61*x873)));
evalcond[5]=(((new_r00*x873))+(((-1.0)*gconst61)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r00))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
CheckValue<IkReal> x876 = IKatan2WithCheck(IkReal(0),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x876.valid){
continue;
}
IkReal x875=((1.0)*(x876.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x875)));
new_r00=0;
new_r01=0;
new_r12=0;
new_r22=0;
IkReal gconst59=((3.14159265358979)+(((-1.0)*x875)));
IkReal gconst60=0;
IkReal x877 = ((1.0)+(((-1.0)*(new_r10*new_r10))));
if(IKabs(x877)==0){
continue;
}
IkReal gconst61=((-1.0)*new_r11*(pow(x877,-0.5)));
j2eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal j2eval[1];
CheckValue<IkReal> x879 = IKatan2WithCheck(IkReal(0),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x879.valid){
continue;
}
IkReal x878=((1.0)*(x879.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x878)));
new_r00=0;
new_r01=0;
new_r12=0;
new_r22=0;
IkReal gconst59=((3.14159265358979)+(((-1.0)*x878)));
IkReal gconst60=0;
IkReal x880 = ((1.0)+(((-1.0)*(new_r10*new_r10))));
if(IKabs(x880)==0){
continue;
}
IkReal gconst61=((-1.0)*new_r11*(pow(x880,-0.5)));
j2eval[0]=new_r11;
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal j2eval[2];
CheckValue<IkReal> x882 = IKatan2WithCheck(IkReal(0),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x882.valid){
continue;
}
IkReal x881=((1.0)*(x882.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x881)));
new_r00=0;
new_r01=0;
new_r12=0;
new_r22=0;
IkReal gconst59=((3.14159265358979)+(((-1.0)*x881)));
IkReal gconst60=0;
IkReal x883 = ((1.0)+(((-1.0)*(new_r10*new_r10))));
if(IKabs(x883)==0){
continue;
}
IkReal gconst61=((-1.0)*new_r11*(pow(x883,-0.5)));
j2eval[0]=new_r10;
j2eval[1]=new_r11;
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x884=IKPowWithIntegerCheck(new_r10,-1);
if(!x884.valid){
continue;
}
CheckValue<IkReal> x885=IKPowWithIntegerCheck(new_r11,-1);
if(!x885.valid){
continue;
}
if( IKabs((gconst61*(x884.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*gconst61*(x885.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((gconst61*(x884.value)))+IKsqr(((-1.0)*gconst61*(x885.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2((gconst61*(x884.value)), ((-1.0)*gconst61*(x885.value)));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x886=IKcos(j2);
IkReal x887=IKsin(j2);
IkReal x888=(gconst61*x887);
IkReal x889=(gconst61*x886);
evalcond[0]=(new_r10*x886);
evalcond[1]=(new_r11*x887);
evalcond[2]=((-1.0)*x889);
evalcond[3]=((-1.0)*x888);
evalcond[4]=(((new_r11*x886))+gconst61);
evalcond[5]=(new_r11+x889);
evalcond[6]=((((-1.0)*x888))+new_r10);
evalcond[7]=(((new_r10*x887))+(((-1.0)*gconst61)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x890=IKPowWithIntegerCheck(gconst61,-1);
if(!x890.valid){
continue;
}
CheckValue<IkReal> x891=IKPowWithIntegerCheck(new_r11,-1);
if(!x891.valid){
continue;
}
if( IKabs((new_r10*(x890.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*gconst61*(x891.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((new_r10*(x890.value)))+IKsqr(((-1.0)*gconst61*(x891.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2((new_r10*(x890.value)), ((-1.0)*gconst61*(x891.value)));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x892=IKcos(j2);
IkReal x893=IKsin(j2);
IkReal x894=(gconst61*x893);
IkReal x895=(gconst61*x892);
evalcond[0]=(new_r10*x892);
evalcond[1]=(new_r11*x893);
evalcond[2]=((-1.0)*x895);
evalcond[3]=((-1.0)*x894);
evalcond[4]=(((new_r11*x892))+gconst61);
evalcond[5]=(new_r11+x895);
evalcond[6]=((((-1.0)*x894))+new_r10);
evalcond[7]=((((-1.0)*gconst61))+((new_r10*x893)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x896 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x896.valid){
continue;
}
CheckValue<IkReal> x897=IKPowWithIntegerCheck(IKsign(gconst61),-1);
if(!x897.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x896.value)+(((1.5707963267949)*(x897.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x898=IKcos(j2);
IkReal x899=IKsin(j2);
IkReal x900=(gconst61*x899);
IkReal x901=(gconst61*x898);
evalcond[0]=(new_r10*x898);
evalcond[1]=(new_r11*x899);
evalcond[2]=((-1.0)*x901);
evalcond[3]=((-1.0)*x900);
evalcond[4]=(((new_r11*x898))+gconst61);
evalcond[5]=(new_r11+x901);
evalcond[6]=((((-1.0)*x900))+new_r10);
evalcond[7]=((((-1.0)*gconst61))+((new_r10*x899)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=IKabs(new_r01);
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
CheckValue<IkReal> x903 = IKatan2WithCheck(IkReal(0),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x903.valid){
continue;
}
IkReal x902=((1.0)*(x903.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x902)));
new_r01=0;
IkReal gconst59=((3.14159265358979)+(((-1.0)*x902)));
IkReal gconst60=0;
IkReal x904 = new_r11*new_r11;
if(IKabs(x904)==0){
continue;
}
IkReal gconst61=((-1.0)*new_r11*(pow(x904,-0.5)));
j2eval[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal j2eval[1];
CheckValue<IkReal> x906 = IKatan2WithCheck(IkReal(0),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x906.valid){
continue;
}
IkReal x905=((1.0)*(x906.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x905)));
new_r01=0;
IkReal gconst59=((3.14159265358979)+(((-1.0)*x905)));
IkReal gconst60=0;
IkReal x907 = new_r11*new_r11;
if(IKabs(x907)==0){
continue;
}
IkReal gconst61=((-1.0)*new_r11*(pow(x907,-0.5)));
j2eval[0]=((IKabs(new_r11))+(IKabs(new_r10)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal j2eval[1];
CheckValue<IkReal> x909 = IKatan2WithCheck(IkReal(0),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x909.valid){
continue;
}
IkReal x908=((1.0)*(x909.value));
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
sj4=gconst60;
cj4=gconst61;
j4=((3.14159265)+(((-1.0)*x908)));
new_r01=0;
IkReal gconst59=((3.14159265358979)+(((-1.0)*x908)));
IkReal gconst60=0;
IkReal x910 = new_r11*new_r11;
if(IKabs(x910)==0){
continue;
}
IkReal gconst61=((-1.0)*new_r11*(pow(x910,-0.5)));
j2eval[0]=new_r11;
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x911=IKPowWithIntegerCheck(gconst61,-1);
if(!x911.valid){
continue;
}
CheckValue<IkReal> x912=IKPowWithIntegerCheck(new_r11,-1);
if(!x912.valid){
continue;
}
if( IKabs((new_r10*(x911.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*gconst61*(x912.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((new_r10*(x911.value)))+IKsqr(((-1.0)*gconst61*(x912.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2((new_r10*(x911.value)), ((-1.0)*gconst61*(x912.value)));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x913=IKsin(j2);
IkReal x914=IKcos(j2);
IkReal x915=((1.0)*gconst61);
IkReal x916=(gconst61*x913);
evalcond[0]=(new_r11*x913);
evalcond[1]=((-1.0)*x916);
evalcond[2]=(gconst61+((new_r11*x914)));
evalcond[3]=(((gconst61*x914))+new_r11);
evalcond[4]=((((-1.0)*x913*x915))+new_r10);
evalcond[5]=((((-1.0)*x914*x915))+new_r00);
evalcond[6]=((((-1.0)*new_r00*x913))+((new_r10*x914)));
evalcond[7]=((((-1.0)*x915))+((new_r10*x913))+((new_r00*x914)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x917 = IKatan2WithCheck(IkReal(new_r10),IkReal(((-1.0)*new_r11)),IKFAST_ATAN2_MAGTHRESH);
if(!x917.valid){
continue;
}
CheckValue<IkReal> x918=IKPowWithIntegerCheck(IKsign(gconst61),-1);
if(!x918.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x917.value)+(((1.5707963267949)*(x918.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x919=IKsin(j2);
IkReal x920=IKcos(j2);
IkReal x921=((1.0)*gconst61);
IkReal x922=(gconst61*x919);
evalcond[0]=(new_r11*x919);
evalcond[1]=((-1.0)*x922);
evalcond[2]=(gconst61+((new_r11*x920)));
evalcond[3]=(((gconst61*x920))+new_r11);
evalcond[4]=((((-1.0)*x919*x921))+new_r10);
evalcond[5]=((((-1.0)*x920*x921))+new_r00);
evalcond[6]=((((-1.0)*new_r00*x919))+((new_r10*x920)));
evalcond[7]=((((-1.0)*x921))+((new_r10*x919))+((new_r00*x920)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x923=IKPowWithIntegerCheck(IKsign(gconst61),-1);
if(!x923.valid){
continue;
}
CheckValue<IkReal> x924 = IKatan2WithCheck(IkReal(new_r10),IkReal(new_r00),IKFAST_ATAN2_MAGTHRESH);
if(!x924.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x923.value)))+(x924.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x925=IKsin(j2);
IkReal x926=IKcos(j2);
IkReal x927=((1.0)*gconst61);
IkReal x928=(gconst61*x925);
evalcond[0]=(new_r11*x925);
evalcond[1]=((-1.0)*x928);
evalcond[2]=(gconst61+((new_r11*x926)));
evalcond[3]=(((gconst61*x926))+new_r11);
evalcond[4]=((((-1.0)*x925*x927))+new_r10);
evalcond[5]=((((-1.0)*x926*x927))+new_r00);
evalcond[6]=((((-1.0)*new_r00*x925))+((new_r10*x926)));
evalcond[7]=((((-1.0)*x927))+((new_r00*x926))+((new_r10*x925)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j2]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x929=((1.0)*new_r11);
CheckValue<IkReal> x930=IKPowWithIntegerCheck(IKsign((((gconst60*new_r01))+(((-1.0)*gconst61*x929)))),-1);
if(!x930.valid){
continue;
}
CheckValue<IkReal> x931 = IKatan2WithCheck(IkReal((((gconst60*gconst61))+(((-1.0)*new_r01*x929)))),IkReal(((((-1.0)*(gconst60*gconst60)))+(new_r11*new_r11))),IKFAST_ATAN2_MAGTHRESH);
if(!x931.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x930.value)))+(x931.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x932=IKsin(j2);
IkReal x933=IKcos(j2);
IkReal x934=((1.0)*gconst61);
IkReal x935=(gconst60*x933);
IkReal x936=((1.0)*x932);
IkReal x937=(x932*x934);
evalcond[0]=(gconst60+((new_r01*x933))+((new_r11*x932)));
evalcond[1]=(((gconst60*x932))+((gconst61*x933))+new_r11);
evalcond[2]=(gconst60+(((-1.0)*new_r00*x936))+((new_r10*x933)));
evalcond[3]=(gconst61+(((-1.0)*new_r01*x936))+((new_r11*x933)));
evalcond[4]=(new_r10+x935+(((-1.0)*x937)));
evalcond[5]=(new_r01+x935+(((-1.0)*x937)));
evalcond[6]=(((new_r00*x933))+((new_r10*x932))+(((-1.0)*x934)));
evalcond[7]=((((-1.0)*gconst60*x936))+new_r00+(((-1.0)*x933*x934)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x938=((1.0)*gconst60);
CheckValue<IkReal> x939 = IKatan2WithCheck(IkReal(((((-1.0)*new_r11*x938))+((gconst61*new_r01)))),IkReal(((((-1.0)*gconst61*new_r11))+(((-1.0)*new_r01*x938)))),IKFAST_ATAN2_MAGTHRESH);
if(!x939.valid){
continue;
}
CheckValue<IkReal> x940=IKPowWithIntegerCheck(IKsign(((new_r01*new_r01)+(new_r11*new_r11))),-1);
if(!x940.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x939.value)+(((1.5707963267949)*(x940.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x941=IKsin(j2);
IkReal x942=IKcos(j2);
IkReal x943=((1.0)*gconst61);
IkReal x944=(gconst60*x942);
IkReal x945=((1.0)*x941);
IkReal x946=(x941*x943);
evalcond[0]=(((new_r01*x942))+gconst60+((new_r11*x941)));
evalcond[1]=(((gconst61*x942))+((gconst60*x941))+new_r11);
evalcond[2]=(gconst60+((new_r10*x942))+(((-1.0)*new_r00*x945)));
evalcond[3]=(gconst61+((new_r11*x942))+(((-1.0)*new_r01*x945)));
evalcond[4]=((((-1.0)*x946))+new_r10+x944);
evalcond[5]=((((-1.0)*x946))+new_r01+x944);
evalcond[6]=((((-1.0)*x943))+((new_r00*x942))+((new_r10*x941)));
evalcond[7]=((((-1.0)*x942*x943))+(((-1.0)*gconst60*x945))+new_r00);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x947=((1.0)*gconst60);
CheckValue<IkReal> x948 = IKatan2WithCheck(IkReal(((((-1.0)*new_r10*x947))+((gconst60*new_r01)))),IkReal(((((-1.0)*new_r11*x947))+(((-1.0)*new_r00*x947)))),IKFAST_ATAN2_MAGTHRESH);
if(!x948.valid){
continue;
}
CheckValue<IkReal> x949=IKPowWithIntegerCheck(IKsign((((new_r10*new_r11))+((new_r00*new_r01)))),-1);
if(!x949.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x948.value)+(((1.5707963267949)*(x949.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x950=IKsin(j2);
IkReal x951=IKcos(j2);
IkReal x952=((1.0)*gconst61);
IkReal x953=(gconst60*x951);
IkReal x954=((1.0)*x950);
IkReal x955=(x950*x952);
evalcond[0]=(((new_r01*x951))+gconst60+((new_r11*x950)));
evalcond[1]=(((gconst60*x950))+((gconst61*x951))+new_r11);
evalcond[2]=(((new_r10*x951))+gconst60+(((-1.0)*new_r00*x954)));
evalcond[3]=(gconst61+(((-1.0)*new_r01*x954))+((new_r11*x951)));
evalcond[4]=(new_r10+(((-1.0)*x955))+x953);
evalcond[5]=(new_r01+(((-1.0)*x955))+x953);
evalcond[6]=(((new_r10*x950))+((new_r00*x951))+(((-1.0)*x952)));
evalcond[7]=((((-1.0)*gconst60*x954))+(((-1.0)*x951*x952))+new_r00);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((new_r01*new_r01)+(new_r11*new_r11));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
new_r01=0;
new_r11=0;
j2eval[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x957 = IKatan2WithCheck(IkReal(new_r00),IkReal(new_r10),IKFAST_ATAN2_MAGTHRESH);
if(!x957.valid){
continue;
}
IkReal x956=x957.value;
j2array[0]=((-1.0)*x956);
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
j2array[1]=((3.14159265358979)+(((-1.0)*x956)));
sj2array[1]=IKsin(j2array[1]);
cj2array[1]=IKcos(j2array[1]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
if( j2array[1] > IKPI )
{
j2array[1]-=IK2PI;
}
else if( j2array[1] < -IKPI )
{ j2array[1]+=IK2PI;
}
j2valid[1] = true;
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[1];
evalcond[0]=((((-1.0)*new_r00*(IKsin(j2))))+((new_r10*(IKcos(j2)))));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j4))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
if( IKabs(new_r10) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r11)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r10)+IKsqr(((-1.0)*new_r11))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2(new_r10, ((-1.0)*new_r11));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x958=IKcos(j2);
IkReal x959=IKsin(j2);
IkReal x960=((1.0)*x959);
evalcond[0]=(new_r11+x958);
evalcond[1]=(new_r10+(((-1.0)*x960)));
evalcond[2]=((((-1.0)*x958))+new_r00);
evalcond[3]=(new_r01+(((-1.0)*x960)));
evalcond[4]=(((new_r01*x958))+((new_r11*x959)));
evalcond[5]=(((new_r10*x958))+(((-1.0)*new_r00*x960)));
evalcond[6]=((-1.0)+((new_r10*x959))+((new_r00*x958)));
evalcond[7]=((1.0)+(((-1.0)*new_r01*x960))+((new_r11*x958)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j4)))), 6.28318530717959)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
if( IKabs(((-1.0)*new_r10)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r00)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r10))+IKsqr(((-1.0)*new_r00))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2(((-1.0)*new_r10), ((-1.0)*new_r00));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x961=IKsin(j2);
IkReal x962=IKcos(j2);
IkReal x963=((1.0)*x961);
evalcond[0]=(new_r10+x961);
evalcond[1]=(new_r00+x962);
evalcond[2]=(new_r01+x961);
evalcond[3]=((((-1.0)*x962))+new_r11);
evalcond[4]=(((new_r11*x961))+((new_r01*x962)));
evalcond[5]=((((-1.0)*new_r00*x963))+((new_r10*x962)));
evalcond[6]=((1.0)+((new_r00*x962))+((new_r10*x961)));
evalcond[7]=((-1.0)+((new_r11*x962))+(((-1.0)*new_r01*x963)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[3];
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
new_r11=0;
new_r00=0;
j2eval[0]=new_r01;
j2eval[1]=((IKabs(cj4))+(IKabs(sj4)));
j2eval[2]=IKsign(new_r01);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[3];
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
new_r11=0;
new_r00=0;
j2eval[0]=new_r10;
j2eval[1]=((IKabs(cj4))+(IKabs(sj4)));
j2eval[2]=IKsign(new_r10);
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[2];
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
new_r11=0;
new_r00=0;
j2eval[0]=new_r01;
j2eval[1]=new_r10;
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 )
{
continue; // no branches [j2]
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x964=IKPowWithIntegerCheck(new_r01,-1);
if(!x964.valid){
continue;
}
CheckValue<IkReal> x965=IKPowWithIntegerCheck(new_r10,-1);
if(!x965.valid){
continue;
}
if( IKabs((cj4*(x964.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*sj4*(x965.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((cj4*(x964.value)))+IKsqr(((-1.0)*sj4*(x965.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2((cj4*(x964.value)), ((-1.0)*sj4*(x965.value)));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[7];
IkReal x966=IKcos(j2);
IkReal x967=IKsin(j2);
IkReal x968=((1.0)*cj4);
IkReal x969=(sj4*x966);
IkReal x970=((1.0)*x967);
IkReal x971=(x967*x968);
evalcond[0]=(sj4+((new_r10*x966)));
evalcond[1]=(((new_r01*x966))+sj4);
evalcond[2]=(cj4+(((-1.0)*new_r01*x970)));
evalcond[3]=((((-1.0)*x968))+((new_r10*x967)));
evalcond[4]=(new_r10+x969+(((-1.0)*x971)));
evalcond[5]=((((-1.0)*x966*x968))+(((-1.0)*sj4*x970)));
evalcond[6]=(new_r01+x969+(((-1.0)*x971)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x972=IKPowWithIntegerCheck(IKsign(new_r10),-1);
if(!x972.valid){
continue;
}
CheckValue<IkReal> x973 = IKatan2WithCheck(IkReal(cj4),IkReal(((-1.0)*sj4)),IKFAST_ATAN2_MAGTHRESH);
if(!x973.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x972.value)))+(x973.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[7];
IkReal x974=IKcos(j2);
IkReal x975=IKsin(j2);
IkReal x976=((1.0)*cj4);
IkReal x977=(sj4*x974);
IkReal x978=((1.0)*x975);
IkReal x979=(x975*x976);
evalcond[0]=(sj4+((new_r10*x974)));
evalcond[1]=(((new_r01*x974))+sj4);
evalcond[2]=(cj4+(((-1.0)*new_r01*x978)));
evalcond[3]=(((new_r10*x975))+(((-1.0)*x976)));
evalcond[4]=(new_r10+x977+(((-1.0)*x979)));
evalcond[5]=((((-1.0)*x974*x976))+(((-1.0)*sj4*x978)));
evalcond[6]=(new_r01+x977+(((-1.0)*x979)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x980=IKPowWithIntegerCheck(IKsign(new_r01),-1);
if(!x980.valid){
continue;
}
CheckValue<IkReal> x981 = IKatan2WithCheck(IkReal(cj4),IkReal(((-1.0)*sj4)),IKFAST_ATAN2_MAGTHRESH);
if(!x981.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x980.value)))+(x981.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[7];
IkReal x982=IKcos(j2);
IkReal x983=IKsin(j2);
IkReal x984=((1.0)*cj4);
IkReal x985=(sj4*x982);
IkReal x986=((1.0)*x983);
IkReal x987=(x983*x984);
evalcond[0]=(sj4+((new_r10*x982)));
evalcond[1]=(sj4+((new_r01*x982)));
evalcond[2]=(cj4+(((-1.0)*new_r01*x986)));
evalcond[3]=((((-1.0)*x984))+((new_r10*x983)));
evalcond[4]=((((-1.0)*x987))+new_r10+x985);
evalcond[5]=((((-1.0)*sj4*x986))+(((-1.0)*x982*x984)));
evalcond[6]=((((-1.0)*x987))+new_r01+x985);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
new_r11=0;
new_r01=0;
new_r22=0;
new_r20=0;
j2eval[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j2]
} else
{
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x989 = IKatan2WithCheck(IkReal(new_r00),IkReal(new_r10),IKFAST_ATAN2_MAGTHRESH);
if(!x989.valid){
continue;
}
IkReal x988=x989.value;
j2array[0]=((-1.0)*x988);
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
j2array[1]=((3.14159265358979)+(((-1.0)*x988)));
sj2array[1]=IKsin(j2array[1]);
cj2array[1]=IKcos(j2array[1]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
if( j2array[1] > IKPI )
{
j2array[1]-=IK2PI;
}
else if( j2array[1] < -IKPI )
{ j2array[1]+=IK2PI;
}
j2valid[1] = true;
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[1];
evalcond[0]=((((-1.0)*new_r00*(IKsin(j2))))+((new_r10*(IKcos(j2)))));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
new_r00=0;
new_r10=0;
new_r21=0;
new_r22=0;
j2eval[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j2]
} else
{
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x991 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x991.valid){
continue;
}
IkReal x990=x991.value;
j2array[0]=((-1.0)*x990);
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
j2array[1]=((3.14159265358979)+(((-1.0)*x990)));
sj2array[1]=IKsin(j2array[1]);
cj2array[1]=IKcos(j2array[1]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
if( j2array[1] > IKPI )
{
j2array[1]-=IK2PI;
}
else if( j2array[1] < -IKPI )
{ j2array[1]+=IK2PI;
}
j2valid[1] = true;
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[1];
evalcond[0]=((((-1.0)*new_r01*(IKsin(j2))))+((new_r11*(IKcos(j2)))));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r10))+(IKabs(new_r01)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[3];
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
new_r01=0;
new_r10=0;
j2eval[0]=new_r11;
j2eval[1]=IKsign(new_r11);
j2eval[2]=((IKabs(cj4))+(IKabs(sj4)));
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 || IKabs(j2eval[2]) < 0.0000010000000000 )
{
{
IkReal j2eval[2];
sj3=0;
cj3=-1.0;
j3=3.14159265358979;
new_r01=0;
new_r10=0;
j2eval[0]=new_r00;
j2eval[1]=new_r11;
if( IKabs(j2eval[0]) < 0.0000010000000000 || IKabs(j2eval[1]) < 0.0000010000000000 )
{
continue; // no branches [j2]
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x992=IKPowWithIntegerCheck(new_r00,-1);
if(!x992.valid){
continue;
}
CheckValue<IkReal> x993=IKPowWithIntegerCheck(new_r11,-1);
if(!x993.valid){
continue;
}
if( IKabs((sj4*(x992.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*cj4*(x993.value))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((sj4*(x992.value)))+IKsqr(((-1.0)*cj4*(x993.value)))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2((sj4*(x992.value)), ((-1.0)*cj4*(x993.value)));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[7];
IkReal x994=IKsin(j2);
IkReal x995=IKcos(j2);
IkReal x996=((1.0)*cj4);
IkReal x997=((1.0)*x994);
evalcond[0]=(cj4+((new_r11*x995)));
evalcond[1]=(sj4+((new_r11*x994)));
evalcond[2]=(sj4+(((-1.0)*new_r00*x997)));
evalcond[3]=((((-1.0)*x996))+((new_r00*x995)));
evalcond[4]=(((sj4*x995))+(((-1.0)*x994*x996)));
evalcond[5]=(((sj4*x994))+((cj4*x995))+new_r11);
evalcond[6]=((((-1.0)*x995*x996))+(((-1.0)*sj4*x997))+new_r00);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x998=IKPowWithIntegerCheck(IKsign(new_r11),-1);
if(!x998.valid){
continue;
}
CheckValue<IkReal> x999 = IKatan2WithCheck(IkReal(((-1.0)*sj4)),IkReal(((-1.0)*cj4)),IKFAST_ATAN2_MAGTHRESH);
if(!x999.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x998.value)))+(x999.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[7];
IkReal x1000=IKsin(j2);
IkReal x1001=IKcos(j2);
IkReal x1002=((1.0)*cj4);
IkReal x1003=((1.0)*x1000);
evalcond[0]=(cj4+((new_r11*x1001)));
evalcond[1]=(sj4+((new_r11*x1000)));
evalcond[2]=(sj4+(((-1.0)*new_r00*x1003)));
evalcond[3]=((((-1.0)*x1002))+((new_r00*x1001)));
evalcond[4]=(((sj4*x1001))+(((-1.0)*x1000*x1002)));
evalcond[5]=(((sj4*x1000))+((cj4*x1001))+new_r11);
evalcond[6]=((((-1.0)*x1001*x1002))+new_r00+(((-1.0)*sj4*x1003)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j2]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x1004=IKPowWithIntegerCheck(IKsign((((cj4*new_r01))+((new_r11*sj4)))),-1);
if(!x1004.valid){
continue;
}
CheckValue<IkReal> x1005 = IKatan2WithCheck(IkReal(((-1.0)+((new_r01*new_r10))+(cj4*cj4))),IkReal(((((-1.0)*cj4*sj4))+(((-1.0)*new_r10*new_r11)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1005.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1004.value)))+(x1005.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x1006=IKsin(j2);
IkReal x1007=IKcos(j2);
IkReal x1008=((1.0)*cj4);
IkReal x1009=(sj4*x1007);
IkReal x1010=((1.0)*x1006);
IkReal x1011=(x1006*x1008);
evalcond[0]=(sj4+((new_r11*x1006))+((new_r01*x1007)));
evalcond[1]=(((sj4*x1006))+((cj4*x1007))+new_r11);
evalcond[2]=(sj4+((new_r10*x1007))+(((-1.0)*new_r00*x1010)));
evalcond[3]=(cj4+((new_r11*x1007))+(((-1.0)*new_r01*x1010)));
evalcond[4]=(x1009+(((-1.0)*x1011))+new_r10);
evalcond[5]=(x1009+(((-1.0)*x1011))+new_r01);
evalcond[6]=((((-1.0)*x1008))+((new_r10*x1006))+((new_r00*x1007)));
evalcond[7]=((((-1.0)*x1007*x1008))+new_r00+(((-1.0)*sj4*x1010)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x1012=((1.0)*new_r11);
CheckValue<IkReal> x1013 = IKatan2WithCheck(IkReal((((cj4*new_r01))+(((-1.0)*sj4*x1012)))),IkReal(((((-1.0)*new_r01*sj4))+(((-1.0)*cj4*x1012)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1013.valid){
continue;
}
CheckValue<IkReal> x1014=IKPowWithIntegerCheck(IKsign(((new_r01*new_r01)+(new_r11*new_r11))),-1);
if(!x1014.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(x1013.value)+(((1.5707963267949)*(x1014.value))));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x1015=IKsin(j2);
IkReal x1016=IKcos(j2);
IkReal x1017=((1.0)*cj4);
IkReal x1018=(sj4*x1016);
IkReal x1019=((1.0)*x1015);
IkReal x1020=(x1015*x1017);
evalcond[0]=(sj4+((new_r11*x1015))+((new_r01*x1016)));
evalcond[1]=(((sj4*x1015))+((cj4*x1016))+new_r11);
evalcond[2]=(sj4+((new_r10*x1016))+(((-1.0)*new_r00*x1019)));
evalcond[3]=(cj4+((new_r11*x1016))+(((-1.0)*new_r01*x1019)));
evalcond[4]=(x1018+(((-1.0)*x1020))+new_r10);
evalcond[5]=(x1018+(((-1.0)*x1020))+new_r01);
evalcond[6]=((((-1.0)*x1017))+((new_r10*x1015))+((new_r00*x1016)));
evalcond[7]=((((-1.0)*x1016*x1017))+new_r00+(((-1.0)*sj4*x1019)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
IkReal x1021=((1.0)*sj4);
CheckValue<IkReal> x1022=IKPowWithIntegerCheck(IKsign((((new_r10*new_r11))+((new_r00*new_r01)))),-1);
if(!x1022.valid){
continue;
}
CheckValue<IkReal> x1023 = IKatan2WithCheck(IkReal((((new_r01*sj4))+(((-1.0)*new_r10*x1021)))),IkReal(((((-1.0)*new_r00*x1021))+(((-1.0)*new_r11*x1021)))),IKFAST_ATAN2_MAGTHRESH);
if(!x1023.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1022.value)))+(x1023.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x1024=IKsin(j2);
IkReal x1025=IKcos(j2);
IkReal x1026=((1.0)*cj4);
IkReal x1027=(sj4*x1025);
IkReal x1028=((1.0)*x1024);
IkReal x1029=(x1024*x1026);
evalcond[0]=(sj4+((new_r11*x1024))+((new_r01*x1025)));
evalcond[1]=(((sj4*x1024))+((cj4*x1025))+new_r11);
evalcond[2]=((((-1.0)*new_r00*x1028))+((new_r10*x1025))+sj4);
evalcond[3]=(((new_r11*x1025))+cj4+(((-1.0)*new_r01*x1028)));
evalcond[4]=(x1027+(((-1.0)*x1029))+new_r10);
evalcond[5]=(x1027+(((-1.0)*x1029))+new_r01);
evalcond[6]=(((new_r10*x1024))+(((-1.0)*x1026))+((new_r00*x1025)));
evalcond[7]=((((-1.0)*sj4*x1028))+new_r00+(((-1.0)*x1025*x1026)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r12))+(IKabs(new_r02)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j2eval[1];
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
j2eval[0]=((IKabs(new_r10))+(IKabs(new_r00)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal j2eval[1];
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
j2eval[0]=((IKabs(new_r11))+(IKabs(new_r01)));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
{
IkReal j2eval[1];
new_r02=0;
new_r12=0;
new_r20=0;
new_r21=0;
j2eval[0]=((IKabs((new_r11*new_r22)))+(IKabs((new_r01*new_r22))));
if( IKabs(j2eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j2]
} else
{
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
IkReal x1030=((-1.0)*new_r22);
CheckValue<IkReal> x1032 = IKatan2WithCheck(IkReal((new_r01*x1030)),IkReal((new_r11*x1030)),IKFAST_ATAN2_MAGTHRESH);
if(!x1032.valid){
continue;
}
IkReal x1031=x1032.value;
j2array[0]=((-1.0)*x1031);
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
j2array[1]=((3.14159265358979)+(((-1.0)*x1031)));
sj2array[1]=IKsin(j2array[1]);
cj2array[1]=IKcos(j2array[1]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
if( j2array[1] > IKPI )
{
j2array[1]-=IK2PI;
}
else if( j2array[1] < -IKPI )
{ j2array[1]+=IK2PI;
}
j2valid[1] = true;
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[5];
IkReal x1033=IKcos(j2);
IkReal x1034=IKsin(j2);
IkReal x1035=((1.0)*new_r00);
IkReal x1036=(new_r10*x1034);
evalcond[0]=(x1036+((new_r00*x1033)));
evalcond[1]=(((new_r11*x1034))+((new_r01*x1033)));
evalcond[2]=((((-1.0)*x1034*x1035))+((new_r10*x1033)));
evalcond[3]=(((new_r11*x1033))+(((-1.0)*new_r01*x1034)));
evalcond[4]=((((-1.0)*new_r22*x1036))+(((-1.0)*new_r22*x1033*x1035)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x1038 = IKatan2WithCheck(IkReal(new_r01),IkReal(new_r11),IKFAST_ATAN2_MAGTHRESH);
if(!x1038.valid){
continue;
}
IkReal x1037=x1038.value;
j2array[0]=((-1.0)*x1037);
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
j2array[1]=((3.14159265358979)+(((-1.0)*x1037)));
sj2array[1]=IKsin(j2array[1]);
cj2array[1]=IKcos(j2array[1]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
if( j2array[1] > IKPI )
{
j2array[1]-=IK2PI;
}
else if( j2array[1] < -IKPI )
{ j2array[1]+=IK2PI;
}
j2valid[1] = true;
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[5];
IkReal x1039=IKcos(j2);
IkReal x1040=IKsin(j2);
IkReal x1041=((1.0)*new_r22);
IkReal x1042=(new_r00*x1039);
IkReal x1043=((1.0)*x1040);
IkReal x1044=(new_r10*x1040);
evalcond[0]=(x1042+x1044);
evalcond[1]=(((new_r10*x1039))+(((-1.0)*new_r00*x1043)));
evalcond[2]=(((new_r11*x1039))+(((-1.0)*new_r01*x1043)));
evalcond[3]=((((-1.0)*new_r01*x1039*x1041))+(((-1.0)*new_r11*x1040*x1041)));
evalcond[4]=((((-1.0)*x1041*x1044))+(((-1.0)*x1041*x1042)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[2], cj2array[2], sj2array[2];
bool j2valid[2]={false};
_nj2 = 2;
CheckValue<IkReal> x1046 = IKatan2WithCheck(IkReal(new_r00),IkReal(new_r10),IKFAST_ATAN2_MAGTHRESH);
if(!x1046.valid){
continue;
}
IkReal x1045=x1046.value;
j2array[0]=((-1.0)*x1045);
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
j2array[1]=((3.14159265358979)+(((-1.0)*x1045)));
sj2array[1]=IKsin(j2array[1]);
cj2array[1]=IKcos(j2array[1]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
if( j2array[1] > IKPI )
{
j2array[1]-=IK2PI;
}
else if( j2array[1] < -IKPI )
{ j2array[1]+=IK2PI;
}
j2valid[1] = true;
for(int ij2 = 0; ij2 < 2; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 2; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[5];
IkReal x1047=IKcos(j2);
IkReal x1048=IKsin(j2);
IkReal x1049=((1.0)*new_r22);
IkReal x1050=(new_r11*x1048);
IkReal x1051=((1.0)*x1048);
IkReal x1052=(new_r01*x1047);
evalcond[0]=(x1050+x1052);
evalcond[1]=((((-1.0)*new_r00*x1051))+((new_r10*x1047)));
evalcond[2]=((((-1.0)*new_r01*x1051))+((new_r11*x1047)));
evalcond[3]=((((-1.0)*x1049*x1050))+(((-1.0)*x1049*x1052)));
evalcond[4]=((((-1.0)*new_r00*x1047*x1049))+(((-1.0)*new_r10*x1048*x1049)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j2]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x1054=IKPowWithIntegerCheck(sj3,-1);
if(!x1054.valid){
continue;
}
IkReal x1053=x1054.value;
CheckValue<IkReal> x1055=IKPowWithIntegerCheck(new_r00,-1);
if(!x1055.valid){
continue;
}
if( IKabs((x1053*(x1055.value)*((((sj3*sj4))+((new_r02*new_r10)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r02*x1053)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((x1053*(x1055.value)*((((sj3*sj4))+((new_r02*new_r10))))))+IKsqr((new_r02*x1053))-1) <= IKFAST_SINCOS_THRESH )
continue;
j2array[0]=IKatan2((x1053*(x1055.value)*((((sj3*sj4))+((new_r02*new_r10))))), (new_r02*x1053));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[18];
IkReal x1056=IKcos(j2);
IkReal x1057=IKsin(j2);
IkReal x1058=(cj3*cj4);
IkReal x1059=((1.0)*sj4);
IkReal x1060=((1.0)*cj3);
IkReal x1061=(sj3*x1057);
IkReal x1062=(new_r01*x1056);
IkReal x1063=(cj3*x1056);
IkReal x1064=(new_r11*x1057);
IkReal x1065=((1.0)*x1057);
IkReal x1066=(sj3*x1056);
evalcond[0]=(new_r02+(((-1.0)*x1066)));
evalcond[1]=(new_r12+(((-1.0)*x1061)));
evalcond[2]=((((-1.0)*new_r02*x1065))+((new_r12*x1056)));
evalcond[3]=(sj4+(((-1.0)*new_r00*x1065))+((new_r10*x1056)));
evalcond[4]=(cj4+(((-1.0)*new_r01*x1065))+((new_r11*x1056)));
evalcond[5]=(((x1057*x1058))+new_r10+((sj4*x1056)));
evalcond[6]=((((-1.0)*sj3))+((new_r02*x1056))+((new_r12*x1057)));
evalcond[7]=(x1058+((new_r00*x1056))+((new_r10*x1057)));
evalcond[8]=(((x1056*x1058))+(((-1.0)*x1057*x1059))+new_r00);
evalcond[9]=((((-1.0)*cj3*x1057*x1059))+new_r11+((cj4*x1056)));
evalcond[10]=(x1062+x1064+(((-1.0)*cj3*x1059)));
evalcond[11]=((((-1.0)*x1059*x1063))+(((-1.0)*cj4*x1065))+new_r01);
evalcond[12]=(((new_r00*x1066))+((new_r10*x1061))+((cj3*new_r20)));
evalcond[13]=(((sj3*x1062))+((new_r11*x1061))+((cj3*new_r21)));
evalcond[14]=((-1.0)+((new_r02*x1066))+((new_r12*x1061))+((cj3*new_r22)));
evalcond[15]=((((-1.0)*new_r02*x1056*x1060))+((new_r22*sj3))+(((-1.0)*new_r12*x1057*x1060)));
evalcond[16]=((((-1.0)*x1060*x1064))+(((-1.0)*x1060*x1062))+sj4+((new_r21*sj3)));
evalcond[17]=(((new_r20*sj3))+(((-1.0)*new_r10*x1057*x1060))+(((-1.0)*new_r00*x1056*x1060))+(((-1.0)*cj4)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[12]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[13]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[14]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[15]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[16]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[17]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x1067=IKPowWithIntegerCheck(IKsign(sj3),-1);
if(!x1067.valid){
continue;
}
CheckValue<IkReal> x1068 = IKatan2WithCheck(IkReal(new_r12),IkReal(new_r02),IKFAST_ATAN2_MAGTHRESH);
if(!x1068.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1067.value)))+(x1068.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[18];
IkReal x1069=IKcos(j2);
IkReal x1070=IKsin(j2);
IkReal x1071=(cj3*cj4);
IkReal x1072=((1.0)*sj4);
IkReal x1073=((1.0)*cj3);
IkReal x1074=(sj3*x1070);
IkReal x1075=(new_r01*x1069);
IkReal x1076=(cj3*x1069);
IkReal x1077=(new_r11*x1070);
IkReal x1078=((1.0)*x1070);
IkReal x1079=(sj3*x1069);
evalcond[0]=((((-1.0)*x1079))+new_r02);
evalcond[1]=((((-1.0)*x1074))+new_r12);
evalcond[2]=(((new_r12*x1069))+(((-1.0)*new_r02*x1078)));
evalcond[3]=(sj4+(((-1.0)*new_r00*x1078))+((new_r10*x1069)));
evalcond[4]=(cj4+(((-1.0)*new_r01*x1078))+((new_r11*x1069)));
evalcond[5]=(((x1070*x1071))+new_r10+((sj4*x1069)));
evalcond[6]=(((new_r02*x1069))+(((-1.0)*sj3))+((new_r12*x1070)));
evalcond[7]=(x1071+((new_r00*x1069))+((new_r10*x1070)));
evalcond[8]=(((x1069*x1071))+(((-1.0)*x1070*x1072))+new_r00);
evalcond[9]=(((cj4*x1069))+(((-1.0)*cj3*x1070*x1072))+new_r11);
evalcond[10]=(x1077+x1075+(((-1.0)*cj3*x1072)));
evalcond[11]=((((-1.0)*cj4*x1078))+(((-1.0)*x1072*x1076))+new_r01);
evalcond[12]=(((new_r00*x1079))+((new_r10*x1074))+((cj3*new_r20)));
evalcond[13]=(((sj3*x1075))+((new_r11*x1074))+((cj3*new_r21)));
evalcond[14]=((-1.0)+((new_r02*x1079))+((new_r12*x1074))+((cj3*new_r22)));
evalcond[15]=((((-1.0)*new_r12*x1070*x1073))+((new_r22*sj3))+(((-1.0)*new_r02*x1069*x1073)));
evalcond[16]=(sj4+(((-1.0)*x1073*x1075))+(((-1.0)*x1073*x1077))+((new_r21*sj3)));
evalcond[17]=((((-1.0)*new_r10*x1070*x1073))+((new_r20*sj3))+(((-1.0)*new_r00*x1069*x1073))+(((-1.0)*cj4)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[12]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[13]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[14]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[15]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[16]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[17]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j2array[1], cj2array[1], sj2array[1];
bool j2valid[1]={false};
_nj2 = 1;
CheckValue<IkReal> x1080=IKPowWithIntegerCheck(IKsign(sj3),-1);
if(!x1080.valid){
continue;
}
CheckValue<IkReal> x1081 = IKatan2WithCheck(IkReal(new_r12),IkReal(new_r02),IKFAST_ATAN2_MAGTHRESH);
if(!x1081.valid){
continue;
}
j2array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1080.value)))+(x1081.value));
sj2array[0]=IKsin(j2array[0]);
cj2array[0]=IKcos(j2array[0]);
if( j2array[0] > IKPI )
{
j2array[0]-=IK2PI;
}
else if( j2array[0] < -IKPI )
{ j2array[0]+=IK2PI;
}
j2valid[0] = true;
for(int ij2 = 0; ij2 < 1; ++ij2)
{
if( !j2valid[ij2] )
{
continue;
}
_ij2[0] = ij2; _ij2[1] = -1;
for(int iij2 = ij2+1; iij2 < 1; ++iij2)
{
if( j2valid[iij2] && IKabs(cj2array[ij2]-cj2array[iij2]) < IKFAST_SOLUTION_THRESH && IKabs(sj2array[ij2]-sj2array[iij2]) < IKFAST_SOLUTION_THRESH )
{
j2valid[iij2]=false; _ij2[1] = iij2; break;
}
}
j2 = j2array[ij2]; cj2 = cj2array[ij2]; sj2 = sj2array[ij2];
{
IkReal evalcond[8];
IkReal x1082=IKcos(j2);
IkReal x1083=IKsin(j2);
IkReal x1084=((1.0)*new_r02);
IkReal x1085=(sj3*x1083);
IkReal x1086=(sj3*x1082);
IkReal x1087=(new_r12*x1083);
evalcond[0]=((((-1.0)*x1086))+new_r02);
evalcond[1]=((((-1.0)*x1085))+new_r12);
evalcond[2]=((((-1.0)*x1083*x1084))+((new_r12*x1082)));
evalcond[3]=((((-1.0)*sj3))+x1087+((new_r02*x1082)));
evalcond[4]=(((new_r00*x1086))+((new_r10*x1085))+((cj3*new_r20)));
evalcond[5]=(((new_r01*x1086))+((new_r11*x1085))+((cj3*new_r21)));
evalcond[6]=((-1.0)+((new_r02*x1086))+((cj3*new_r22))+((new_r12*x1085)));
evalcond[7]=((((-1.0)*cj3*x1087))+(((-1.0)*cj3*x1082*x1084))+((new_r22*sj3)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j4eval[3];
j4eval[0]=sj3;
j4eval[1]=IKsign(sj3);
j4eval[2]=((IKabs(new_r20))+(IKabs(new_r21)));
if( IKabs(j4eval[0]) < 0.0000010000000000 || IKabs(j4eval[1]) < 0.0000010000000000 || IKabs(j4eval[2]) < 0.0000010000000000 )
{
{
IkReal j4eval[2];
j4eval[0]=sj3;
j4eval[1]=cj2;
if( IKabs(j4eval[0]) < 0.0000010000000000 || IKabs(j4eval[1]) < 0.0000010000000000 )
{
{
IkReal j4eval[3];
j4eval[0]=sj3;
j4eval[1]=cj3;
j4eval[2]=sj2;
if( IKabs(j4eval[0]) < 0.0000010000000000 || IKabs(j4eval[1]) < 0.0000010000000000 || IKabs(j4eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[5];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=new_r21;
evalcond[2]=new_r02;
evalcond[3]=new_r12;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
IkReal x1088=((1.0)*cj2);
if( IKabs(((((-1.0)*new_r10*x1088))+((new_r00*sj2)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*new_r00*x1088))+(((-1.0)*new_r10*sj2)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((-1.0)*new_r10*x1088))+((new_r00*sj2))))+IKsqr(((((-1.0)*new_r00*x1088))+(((-1.0)*new_r10*sj2))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((((-1.0)*new_r10*x1088))+((new_r00*sj2))), ((((-1.0)*new_r00*x1088))+(((-1.0)*new_r10*sj2))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x1089=IKcos(j4);
IkReal x1090=IKsin(j4);
IkReal x1091=((1.0)*sj2);
IkReal x1092=(cj2*x1089);
IkReal x1093=((1.0)*x1090);
IkReal x1094=(x1090*x1091);
evalcond[0]=(x1089+((new_r10*sj2))+((cj2*new_r00)));
evalcond[1]=((((-1.0)*new_r00*x1091))+x1090+((cj2*new_r10)));
evalcond[2]=(x1089+(((-1.0)*new_r01*x1091))+((cj2*new_r11)));
evalcond[3]=(((sj2*x1089))+new_r10+((cj2*x1090)));
evalcond[4]=(((new_r11*sj2))+(((-1.0)*x1093))+((cj2*new_r01)));
evalcond[5]=(x1092+(((-1.0)*x1094))+new_r00);
evalcond[6]=(x1092+(((-1.0)*x1094))+new_r11);
evalcond[7]=((((-1.0)*cj2*x1093))+(((-1.0)*x1089*x1091))+new_r01);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j3)))), 6.28318530717959)));
evalcond[1]=new_r21;
evalcond[2]=new_r02;
evalcond[3]=new_r12;
evalcond[4]=new_r20;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 && IKabs(evalcond[2]) < 0.0000050000000000 && IKabs(evalcond[3]) < 0.0000050000000000 && IKabs(evalcond[4]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
IkReal x1095=((1.0)*cj2);
if( IKabs(((((-1.0)*new_r11*sj2))+(((-1.0)*new_r10*x1095)))) < IKFAST_ATAN2_MAGTHRESH && IKabs((((new_r10*sj2))+(((-1.0)*new_r11*x1095)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((-1.0)*new_r11*sj2))+(((-1.0)*new_r10*x1095))))+IKsqr((((new_r10*sj2))+(((-1.0)*new_r11*x1095))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((((-1.0)*new_r11*sj2))+(((-1.0)*new_r10*x1095))), (((new_r10*sj2))+(((-1.0)*new_r11*x1095))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x1096=IKsin(j4);
IkReal x1097=IKcos(j4);
IkReal x1098=((1.0)*sj2);
IkReal x1099=(cj2*x1096);
IkReal x1100=(cj2*x1097);
IkReal x1101=(x1097*x1098);
evalcond[0]=(x1096+((new_r11*sj2))+((cj2*new_r01)));
evalcond[1]=((((-1.0)*new_r00*x1098))+x1096+((cj2*new_r10)));
evalcond[2]=(x1097+(((-1.0)*new_r01*x1098))+((cj2*new_r11)));
evalcond[3]=(((new_r10*sj2))+(((-1.0)*x1097))+((cj2*new_r00)));
evalcond[4]=(x1100+((sj2*x1096))+new_r11);
evalcond[5]=(x1099+new_r10+(((-1.0)*x1101)));
evalcond[6]=(x1099+new_r01+(((-1.0)*x1101)));
evalcond[7]=((((-1.0)*x1096*x1098))+(((-1.0)*x1100))+new_r00);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j3)))), 6.28318530717959)));
evalcond[1]=new_r22;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(((-1.0)*new_r21)) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r20) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r21))+IKsqr(new_r20)-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r21), new_r20);
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x1102=IKsin(j4);
IkReal x1103=IKcos(j4);
IkReal x1104=((1.0)*sj2);
evalcond[0]=(x1102+new_r21);
evalcond[1]=((((-1.0)*x1103))+new_r20);
evalcond[2]=(new_r10+((cj2*x1102)));
evalcond[3]=(new_r11+((cj2*x1103)));
evalcond[4]=(new_r00+(((-1.0)*x1102*x1104)));
evalcond[5]=((((-1.0)*x1103*x1104))+new_r01);
evalcond[6]=(x1102+((cj2*new_r10))+(((-1.0)*new_r00*x1104)));
evalcond[7]=(x1103+((cj2*new_r11))+(((-1.0)*new_r01*x1104)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j3)))), 6.28318530717959)));
evalcond[1]=new_r22;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(new_r21) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r20)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r21)+IKsqr(((-1.0)*new_r20))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(new_r21, ((-1.0)*new_r20));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x1105=IKsin(j4);
IkReal x1106=IKcos(j4);
IkReal x1107=((1.0)*sj2);
evalcond[0]=(x1106+new_r20);
evalcond[1]=((((-1.0)*x1105))+new_r21);
evalcond[2]=(new_r10+((cj2*x1105)));
evalcond[3]=(new_r11+((cj2*x1106)));
evalcond[4]=(new_r00+(((-1.0)*x1105*x1107)));
evalcond[5]=((((-1.0)*x1106*x1107))+new_r01);
evalcond[6]=(x1105+((cj2*new_r10))+(((-1.0)*new_r00*x1107)));
evalcond[7]=(x1106+((cj2*new_r11))+(((-1.0)*new_r01*x1107)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j2))), 6.28318530717959)));
evalcond[1]=new_r12;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(((-1.0)*new_r10)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r11)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r10))+IKsqr(((-1.0)*new_r11))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r10), ((-1.0)*new_r11));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x1108=IKsin(j4);
IkReal x1109=IKcos(j4);
IkReal x1110=((1.0)*cj3);
IkReal x1111=((1.0)*x1109);
evalcond[0]=(x1108+new_r10);
evalcond[1]=(x1109+new_r11);
evalcond[2]=(((sj3*x1108))+new_r21);
evalcond[3]=(new_r00+((cj3*x1109)));
evalcond[4]=((((-1.0)*sj3*x1111))+new_r20);
evalcond[5]=((((-1.0)*x1108*x1110))+new_r01);
evalcond[6]=(x1108+(((-1.0)*new_r01*x1110))+((new_r21*sj3)));
evalcond[7]=(((new_r20*sj3))+(((-1.0)*x1111))+(((-1.0)*new_r00*x1110)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j2)))), 6.28318530717959)));
evalcond[1]=new_r12;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(new_r10) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r11) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r10)+IKsqr(new_r11)-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(new_r10, new_r11);
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x1112=IKsin(j4);
IkReal x1113=IKcos(j4);
IkReal x1114=((1.0)*x1113);
evalcond[0]=(((sj3*x1112))+new_r21);
evalcond[1]=(x1112+(((-1.0)*new_r10)));
evalcond[2]=(x1113+(((-1.0)*new_r11)));
evalcond[3]=((((-1.0)*sj3*x1114))+new_r20);
evalcond[4]=((((-1.0)*new_r00))+((cj3*x1113)));
evalcond[5]=((((-1.0)*new_r01))+(((-1.0)*cj3*x1112)));
evalcond[6]=(x1112+((cj3*new_r01))+((new_r21*sj3)));
evalcond[7]=(((new_r20*sj3))+((cj3*new_r00))+(((-1.0)*x1114)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j2)))), 6.28318530717959)));
evalcond[1]=new_r02;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(new_r00) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r01) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r00)+IKsqr(new_r01)-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(new_r00, new_r01);
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x1115=IKsin(j4);
IkReal x1116=IKcos(j4);
IkReal x1117=((1.0)*cj3);
IkReal x1118=((1.0)*x1116);
evalcond[0]=(((sj3*x1115))+new_r21);
evalcond[1]=(x1115+(((-1.0)*new_r00)));
evalcond[2]=(x1116+(((-1.0)*new_r01)));
evalcond[3]=(new_r10+((cj3*x1116)));
evalcond[4]=((((-1.0)*sj3*x1118))+new_r20);
evalcond[5]=(new_r11+(((-1.0)*x1115*x1117)));
evalcond[6]=(x1115+(((-1.0)*new_r11*x1117))+((new_r21*sj3)));
evalcond[7]=(((new_r20*sj3))+(((-1.0)*new_r10*x1117))+(((-1.0)*x1118)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j2)))), 6.28318530717959)));
evalcond[1]=new_r02;
if( IKabs(evalcond[0]) < 0.0000050000000000 && IKabs(evalcond[1]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
if( IKabs(((-1.0)*new_r00)) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r01)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r00))+IKsqr(((-1.0)*new_r01))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r00), ((-1.0)*new_r01));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x1119=IKsin(j4);
IkReal x1120=IKcos(j4);
IkReal x1121=((1.0)*x1120);
evalcond[0]=(x1119+new_r00);
evalcond[1]=(x1120+new_r01);
evalcond[2]=(((sj3*x1119))+new_r21);
evalcond[3]=((((-1.0)*sj3*x1121))+new_r20);
evalcond[4]=((((-1.0)*new_r10))+((cj3*x1120)));
evalcond[5]=((((-1.0)*new_r11))+(((-1.0)*cj3*x1119)));
evalcond[6]=(x1119+((cj3*new_r11))+((new_r21*sj3)));
evalcond[7]=(((new_r20*sj3))+(((-1.0)*x1121))+((cj3*new_r10)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(new_r20))+(IKabs(new_r21)));
if( IKabs(evalcond[0]) < 0.0000050000000000 )
{
bgotonextstatement=false;
{
IkReal j4eval[1];
new_r21=0;
new_r20=0;
new_r02=0;
new_r12=0;
j4eval[0]=IKabs(new_r22);
if( IKabs(j4eval[0]) < 0.0000000100000000 )
{
continue; // no branches [j4]
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=((-1.0)*new_r22);
op[1]=0;
op[2]=new_r22;
polyroots2(op,zeror,numroots);
IkReal j4array[2], cj4array[2], sj4array[2], tempj4array[1];
int numsolutions = 0;
for(int ij4 = 0; ij4 < numroots; ++ij4)
{
IkReal htj4 = zeror[ij4];
tempj4array[0]=((2.0)*(atan(htj4)));
for(int kj4 = 0; kj4 < 1; ++kj4)
{
j4array[numsolutions] = tempj4array[kj4];
if( j4array[numsolutions] > IKPI )
{
j4array[numsolutions]-=IK2PI;
}
else if( j4array[numsolutions] < -IKPI )
{
j4array[numsolutions]+=IK2PI;
}
sj4array[numsolutions] = IKsin(j4array[numsolutions]);
cj4array[numsolutions] = IKcos(j4array[numsolutions]);
numsolutions++;
}
}
bool j4valid[2]={true,true};
_nj4 = 2;
for(int ij4 = 0; ij4 < numsolutions; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
htj4 = IKtan(j4/2);
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < numsolutions; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j4]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x1123=IKPowWithIntegerCheck(sj3,-1);
if(!x1123.valid){
continue;
}
IkReal x1122=x1123.value;
CheckValue<IkReal> x1124=IKPowWithIntegerCheck(cj3,-1);
if(!x1124.valid){
continue;
}
CheckValue<IkReal> x1125=IKPowWithIntegerCheck(sj2,-1);
if(!x1125.valid){
continue;
}
if( IKabs(((-1.0)*new_r21*x1122)) < IKFAST_ATAN2_MAGTHRESH && IKabs((x1122*(x1124.value)*(x1125.value)*(((((-1.0)*new_r10*sj3))+((cj2*new_r21)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r21*x1122))+IKsqr((x1122*(x1124.value)*(x1125.value)*(((((-1.0)*new_r10*sj3))+((cj2*new_r21))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r21*x1122), (x1122*(x1124.value)*(x1125.value)*(((((-1.0)*new_r10*sj3))+((cj2*new_r21))))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[12];
IkReal x1126=IKsin(j4);
IkReal x1127=IKcos(j4);
IkReal x1128=(cj2*new_r01);
IkReal x1129=((1.0)*cj3);
IkReal x1130=(new_r10*sj2);
IkReal x1131=(new_r11*sj2);
IkReal x1132=(cj2*new_r00);
IkReal x1133=((1.0)*sj2);
IkReal x1134=(cj2*x1126);
IkReal x1135=(cj2*x1127);
IkReal x1136=((1.0)*x1127);
IkReal x1137=(cj3*x1127);
evalcond[0]=(((sj3*x1126))+new_r21);
evalcond[1]=((((-1.0)*sj3*x1136))+new_r20);
evalcond[2]=(x1126+(((-1.0)*new_r00*x1133))+((cj2*new_r10)));
evalcond[3]=(x1127+(((-1.0)*new_r01*x1133))+((cj2*new_r11)));
evalcond[4]=(x1132+x1130+x1137);
evalcond[5]=(x1134+((sj2*x1137))+new_r10);
evalcond[6]=(x1128+x1131+(((-1.0)*x1126*x1129)));
evalcond[7]=(((cj3*x1135))+(((-1.0)*x1126*x1133))+new_r00);
evalcond[8]=(x1135+(((-1.0)*sj2*x1126*x1129))+new_r11);
evalcond[9]=((((-1.0)*x1127*x1133))+new_r01+(((-1.0)*x1129*x1134)));
evalcond[10]=(x1126+(((-1.0)*x1128*x1129))+((new_r21*sj3))+(((-1.0)*x1129*x1131)));
evalcond[11]=(((new_r20*sj3))+(((-1.0)*x1136))+(((-1.0)*x1129*x1130))+(((-1.0)*x1129*x1132)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x1139=IKPowWithIntegerCheck(sj3,-1);
if(!x1139.valid){
continue;
}
IkReal x1138=x1139.value;
CheckValue<IkReal> x1140=IKPowWithIntegerCheck(cj2,-1);
if(!x1140.valid){
continue;
}
if( IKabs(((-1.0)*new_r21*x1138)) < IKFAST_ATAN2_MAGTHRESH && IKabs((x1138*(x1140.value)*(((((-1.0)*cj3*new_r21*sj2))+(((-1.0)*new_r11*sj3)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r21*x1138))+IKsqr((x1138*(x1140.value)*(((((-1.0)*cj3*new_r21*sj2))+(((-1.0)*new_r11*sj3))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2(((-1.0)*new_r21*x1138), (x1138*(x1140.value)*(((((-1.0)*cj3*new_r21*sj2))+(((-1.0)*new_r11*sj3))))));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[12];
IkReal x1141=IKsin(j4);
IkReal x1142=IKcos(j4);
IkReal x1143=(cj2*new_r01);
IkReal x1144=((1.0)*cj3);
IkReal x1145=(new_r10*sj2);
IkReal x1146=(new_r11*sj2);
IkReal x1147=(cj2*new_r00);
IkReal x1148=((1.0)*sj2);
IkReal x1149=(cj2*x1141);
IkReal x1150=(cj2*x1142);
IkReal x1151=((1.0)*x1142);
IkReal x1152=(cj3*x1142);
evalcond[0]=(((sj3*x1141))+new_r21);
evalcond[1]=((((-1.0)*sj3*x1151))+new_r20);
evalcond[2]=(x1141+(((-1.0)*new_r00*x1148))+((cj2*new_r10)));
evalcond[3]=(x1142+(((-1.0)*new_r01*x1148))+((cj2*new_r11)));
evalcond[4]=(x1147+x1145+x1152);
evalcond[5]=(x1149+((sj2*x1152))+new_r10);
evalcond[6]=(x1143+x1146+(((-1.0)*x1141*x1144)));
evalcond[7]=(((cj3*x1150))+(((-1.0)*x1141*x1148))+new_r00);
evalcond[8]=(x1150+(((-1.0)*sj2*x1141*x1144))+new_r11);
evalcond[9]=(new_r01+(((-1.0)*x1144*x1149))+(((-1.0)*x1142*x1148)));
evalcond[10]=(x1141+(((-1.0)*x1143*x1144))+((new_r21*sj3))+(((-1.0)*x1144*x1146)));
evalcond[11]=(((new_r20*sj3))+(((-1.0)*x1151))+(((-1.0)*x1144*x1147))+(((-1.0)*x1144*x1145)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x1153=IKPowWithIntegerCheck(IKsign(sj3),-1);
if(!x1153.valid){
continue;
}
CheckValue<IkReal> x1154 = IKatan2WithCheck(IkReal(((-1.0)*new_r21)),IkReal(new_r20),IKFAST_ATAN2_MAGTHRESH);
if(!x1154.valid){
continue;
}
j4array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1153.value)))+(x1154.value));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[12];
IkReal x1155=IKsin(j4);
IkReal x1156=IKcos(j4);
IkReal x1157=(cj2*new_r01);
IkReal x1158=((1.0)*cj3);
IkReal x1159=(new_r10*sj2);
IkReal x1160=(new_r11*sj2);
IkReal x1161=(cj2*new_r00);
IkReal x1162=((1.0)*sj2);
IkReal x1163=(cj2*x1155);
IkReal x1164=(cj2*x1156);
IkReal x1165=((1.0)*x1156);
IkReal x1166=(cj3*x1156);
evalcond[0]=(((sj3*x1155))+new_r21);
evalcond[1]=((((-1.0)*sj3*x1165))+new_r20);
evalcond[2]=(x1155+((cj2*new_r10))+(((-1.0)*new_r00*x1162)));
evalcond[3]=(x1156+(((-1.0)*new_r01*x1162))+((cj2*new_r11)));
evalcond[4]=(x1159+x1166+x1161);
evalcond[5]=(((sj2*x1166))+x1163+new_r10);
evalcond[6]=(x1157+x1160+(((-1.0)*x1155*x1158)));
evalcond[7]=(((cj3*x1164))+(((-1.0)*x1155*x1162))+new_r00);
evalcond[8]=(x1164+(((-1.0)*sj2*x1155*x1158))+new_r11);
evalcond[9]=((((-1.0)*x1156*x1162))+(((-1.0)*x1158*x1163))+new_r01);
evalcond[10]=(x1155+(((-1.0)*x1157*x1158))+(((-1.0)*x1158*x1160))+((new_r21*sj3)));
evalcond[11]=(((new_r20*sj3))+(((-1.0)*x1158*x1161))+(((-1.0)*x1158*x1159))+(((-1.0)*x1165)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
}
}
}
}
}
}
}static inline void polyroots3(IkReal rawcoeffs[3+1], IkReal rawroots[3], int& numroots)
{
using std::complex;
if( rawcoeffs[0] == 0 ) {
// solve with one reduced degree
polyroots2(&rawcoeffs[1], &rawroots[0], numroots);
return;
}
IKFAST_ASSERT(rawcoeffs[0] != 0);
const IkReal tol = 128.0*std::numeric_limits<IkReal>::epsilon();
const IkReal tolsqrt = sqrt(std::numeric_limits<IkReal>::epsilon());
complex<IkReal> coeffs[3];
const int maxsteps = 110;
for(int i = 0; i < 3; ++i) {
coeffs[i] = complex<IkReal>(rawcoeffs[i+1]/rawcoeffs[0]);
}
complex<IkReal> roots[3];
IkReal err[3];
roots[0] = complex<IkReal>(1,0);
roots[1] = complex<IkReal>(0.4,0.9); // any complex number not a root of unity works
err[0] = 1.0;
err[1] = 1.0;
for(int i = 2; i < 3; ++i) {
roots[i] = roots[i-1]*roots[1];
err[i] = 1.0;
}
for(int step = 0; step < maxsteps; ++step) {
bool changed = false;
for(int i = 0; i < 3; ++i) {
if ( err[i] >= tol ) {
changed = true;
// evaluate
complex<IkReal> x = roots[i] + coeffs[0];
for(int j = 1; j < 3; ++j) {
x = roots[i] * x + coeffs[j];
}
for(int j = 0; j < 3; ++j) {
if( i != j ) {
if( roots[i] != roots[j] ) {
x /= (roots[i] - roots[j]);
}
}
}
roots[i] -= x;
err[i] = abs(x);
}
}
if( !changed ) {
break;
}
}
numroots = 0;
bool visited[3] = {false};
for(int i = 0; i < 3; ++i) {
if( !visited[i] ) {
// might be a multiple root, in which case it will have more error than the other roots
// find any neighboring roots, and take the average
complex<IkReal> newroot=roots[i];
int n = 1;
for(int j = i+1; j < 3; ++j) {
// care about error in real much more than imaginary
if( abs(real(roots[i])-real(roots[j])) < tolsqrt && abs(imag(roots[i])-imag(roots[j])) < 0.002 ) {
newroot += roots[j];
n += 1;
visited[j] = true;
}
}
if( n > 1 ) {
newroot /= n;
}
// there are still cases where even the mean is not accurate enough, until a better multi-root algorithm is used, need to use the sqrt
if( IKabs(imag(newroot)) < tolsqrt ) {
rawroots[numroots++] = real(newroot);
}
}
}
}
static inline void polyroots2(IkReal rawcoeffs[2+1], IkReal rawroots[2], int& numroots) {
IkReal det = rawcoeffs[1]*rawcoeffs[1]-4*rawcoeffs[0]*rawcoeffs[2];
if( det < 0 ) {
numroots=0;
}
else if( det == 0 ) {
rawroots[0] = -0.5*rawcoeffs[1]/rawcoeffs[0];
numroots = 1;
}
else {
det = IKsqrt(det);
rawroots[0] = (-rawcoeffs[1]+det)/(2*rawcoeffs[0]);
rawroots[1] = (-rawcoeffs[1]-det)/(2*rawcoeffs[0]);//rawcoeffs[2]/(rawcoeffs[0]*rawroots[0]);
numroots = 2;
}
}
static inline void polyroots5(IkReal rawcoeffs[5+1], IkReal rawroots[5], int& numroots)
{
using std::complex;
if( rawcoeffs[0] == 0 ) {
// solve with one reduced degree
polyroots4(&rawcoeffs[1], &rawroots[0], numroots);
return;
}
IKFAST_ASSERT(rawcoeffs[0] != 0);
const IkReal tol = 128.0*std::numeric_limits<IkReal>::epsilon();
const IkReal tolsqrt = sqrt(std::numeric_limits<IkReal>::epsilon());
complex<IkReal> coeffs[5];
const int maxsteps = 110;
for(int i = 0; i < 5; ++i) {
coeffs[i] = complex<IkReal>(rawcoeffs[i+1]/rawcoeffs[0]);
}
complex<IkReal> roots[5];
IkReal err[5];
roots[0] = complex<IkReal>(1,0);
roots[1] = complex<IkReal>(0.4,0.9); // any complex number not a root of unity works
err[0] = 1.0;
err[1] = 1.0;
for(int i = 2; i < 5; ++i) {
roots[i] = roots[i-1]*roots[1];
err[i] = 1.0;
}
for(int step = 0; step < maxsteps; ++step) {
bool changed = false;
for(int i = 0; i < 5; ++i) {
if ( err[i] >= tol ) {
changed = true;
// evaluate
complex<IkReal> x = roots[i] + coeffs[0];
for(int j = 1; j < 5; ++j) {
x = roots[i] * x + coeffs[j];
}
for(int j = 0; j < 5; ++j) {
if( i != j ) {
if( roots[i] != roots[j] ) {
x /= (roots[i] - roots[j]);
}
}
}
roots[i] -= x;
err[i] = abs(x);
}
}
if( !changed ) {
break;
}
}
numroots = 0;
bool visited[5] = {false};
for(int i = 0; i < 5; ++i) {
if( !visited[i] ) {
// might be a multiple root, in which case it will have more error than the other roots
// find any neighboring roots, and take the average
complex<IkReal> newroot=roots[i];
int n = 1;
for(int j = i+1; j < 5; ++j) {
// care about error in real much more than imaginary
if( abs(real(roots[i])-real(roots[j])) < tolsqrt && abs(imag(roots[i])-imag(roots[j])) < 0.002 ) {
newroot += roots[j];
n += 1;
visited[j] = true;
}
}
if( n > 1 ) {
newroot /= n;
}
// there are still cases where even the mean is not accurate enough, until a better multi-root algorithm is used, need to use the sqrt
if( IKabs(imag(newroot)) < tolsqrt ) {
rawroots[numroots++] = real(newroot);
}
}
}
}
static inline void polyroots4(IkReal rawcoeffs[4+1], IkReal rawroots[4], int& numroots)
{
using std::complex;
if( rawcoeffs[0] == 0 ) {
// solve with one reduced degree
polyroots3(&rawcoeffs[1], &rawroots[0], numroots);
return;
}
IKFAST_ASSERT(rawcoeffs[0] != 0);
const IkReal tol = 128.0*std::numeric_limits<IkReal>::epsilon();
const IkReal tolsqrt = sqrt(std::numeric_limits<IkReal>::epsilon());
complex<IkReal> coeffs[4];
const int maxsteps = 110;
for(int i = 0; i < 4; ++i) {
coeffs[i] = complex<IkReal>(rawcoeffs[i+1]/rawcoeffs[0]);
}
complex<IkReal> roots[4];
IkReal err[4];
roots[0] = complex<IkReal>(1,0);
roots[1] = complex<IkReal>(0.4,0.9); // any complex number not a root of unity works
err[0] = 1.0;
err[1] = 1.0;
for(int i = 2; i < 4; ++i) {
roots[i] = roots[i-1]*roots[1];
err[i] = 1.0;
}
for(int step = 0; step < maxsteps; ++step) {
bool changed = false;
for(int i = 0; i < 4; ++i) {
if ( err[i] >= tol ) {
changed = true;
// evaluate
complex<IkReal> x = roots[i] + coeffs[0];
for(int j = 1; j < 4; ++j) {
x = roots[i] * x + coeffs[j];
}
for(int j = 0; j < 4; ++j) {
if( i != j ) {
if( roots[i] != roots[j] ) {
x /= (roots[i] - roots[j]);
}
}
}
roots[i] -= x;
err[i] = abs(x);
}
}
if( !changed ) {
break;
}
}
numroots = 0;
bool visited[4] = {false};
for(int i = 0; i < 4; ++i) {
if( !visited[i] ) {
// might be a multiple root, in which case it will have more error than the other roots
// find any neighboring roots, and take the average
complex<IkReal> newroot=roots[i];
int n = 1;
for(int j = i+1; j < 4; ++j) {
// care about error in real much more than imaginary
if( abs(real(roots[i])-real(roots[j])) < tolsqrt && abs(imag(roots[i])-imag(roots[j])) < 0.002 ) {
newroot += roots[j];
n += 1;
visited[j] = true;
}
}
if( n > 1 ) {
newroot /= n;
}
// there are still cases where even the mean is not accurate enough, until a better multi-root algorithm is used, need to use the sqrt
if( IKabs(imag(newroot)) < tolsqrt ) {
rawroots[numroots++] = real(newroot);
}
}
}
}
static inline void polyroots7(IkReal rawcoeffs[7+1], IkReal rawroots[7], int& numroots)
{
using std::complex;
if( rawcoeffs[0] == 0 ) {
// solve with one reduced degree
polyroots6(&rawcoeffs[1], &rawroots[0], numroots);
return;
}
IKFAST_ASSERT(rawcoeffs[0] != 0);
const IkReal tol = 128.0*std::numeric_limits<IkReal>::epsilon();
const IkReal tolsqrt = sqrt(std::numeric_limits<IkReal>::epsilon());
complex<IkReal> coeffs[7];
const int maxsteps = 110;
for(int i = 0; i < 7; ++i) {
coeffs[i] = complex<IkReal>(rawcoeffs[i+1]/rawcoeffs[0]);
}
complex<IkReal> roots[7];
IkReal err[7];
roots[0] = complex<IkReal>(1,0);
roots[1] = complex<IkReal>(0.4,0.9); // any complex number not a root of unity works
err[0] = 1.0;
err[1] = 1.0;
for(int i = 2; i < 7; ++i) {
roots[i] = roots[i-1]*roots[1];
err[i] = 1.0;
}
for(int step = 0; step < maxsteps; ++step) {
bool changed = false;
for(int i = 0; i < 7; ++i) {
if ( err[i] >= tol ) {
changed = true;
// evaluate
complex<IkReal> x = roots[i] + coeffs[0];
for(int j = 1; j < 7; ++j) {
x = roots[i] * x + coeffs[j];
}
for(int j = 0; j < 7; ++j) {
if( i != j ) {
if( roots[i] != roots[j] ) {
x /= (roots[i] - roots[j]);
}
}
}
roots[i] -= x;
err[i] = abs(x);
}
}
if( !changed ) {
break;
}
}
numroots = 0;
bool visited[7] = {false};
for(int i = 0; i < 7; ++i) {
if( !visited[i] ) {
// might be a multiple root, in which case it will have more error than the other roots
// find any neighboring roots, and take the average
complex<IkReal> newroot=roots[i];
int n = 1;
for(int j = i+1; j < 7; ++j) {
// care about error in real much more than imaginary
if( abs(real(roots[i])-real(roots[j])) < tolsqrt && abs(imag(roots[i])-imag(roots[j])) < 0.002 ) {
newroot += roots[j];
n += 1;
visited[j] = true;
}
}
if( n > 1 ) {
newroot /= n;
}
// there are still cases where even the mean is not accurate enough, until a better multi-root algorithm is used, need to use the sqrt
if( IKabs(imag(newroot)) < tolsqrt ) {
rawroots[numroots++] = real(newroot);
}
}
}
}
static inline void polyroots6(IkReal rawcoeffs[6+1], IkReal rawroots[6], int& numroots)
{
using std::complex;
if( rawcoeffs[0] == 0 ) {
// solve with one reduced degree
polyroots5(&rawcoeffs[1], &rawroots[0], numroots);
return;
}
IKFAST_ASSERT(rawcoeffs[0] != 0);
const IkReal tol = 128.0*std::numeric_limits<IkReal>::epsilon();
const IkReal tolsqrt = sqrt(std::numeric_limits<IkReal>::epsilon());
complex<IkReal> coeffs[6];
const int maxsteps = 110;
for(int i = 0; i < 6; ++i) {
coeffs[i] = complex<IkReal>(rawcoeffs[i+1]/rawcoeffs[0]);
}
complex<IkReal> roots[6];
IkReal err[6];
roots[0] = complex<IkReal>(1,0);
roots[1] = complex<IkReal>(0.4,0.9); // any complex number not a root of unity works
err[0] = 1.0;
err[1] = 1.0;
for(int i = 2; i < 6; ++i) {
roots[i] = roots[i-1]*roots[1];
err[i] = 1.0;
}
for(int step = 0; step < maxsteps; ++step) {
bool changed = false;
for(int i = 0; i < 6; ++i) {
if ( err[i] >= tol ) {
changed = true;
// evaluate
complex<IkReal> x = roots[i] + coeffs[0];
for(int j = 1; j < 6; ++j) {
x = roots[i] * x + coeffs[j];
}
for(int j = 0; j < 6; ++j) {
if( i != j ) {
if( roots[i] != roots[j] ) {
x /= (roots[i] - roots[j]);
}
}
}
roots[i] -= x;
err[i] = abs(x);
}
}
if( !changed ) {
break;
}
}
numroots = 0;
bool visited[6] = {false};
for(int i = 0; i < 6; ++i) {
if( !visited[i] ) {
// might be a multiple root, in which case it will have more error than the other roots
// find any neighboring roots, and take the average
complex<IkReal> newroot=roots[i];
int n = 1;
for(int j = i+1; j < 6; ++j) {
// care about error in real much more than imaginary
if( abs(real(roots[i])-real(roots[j])) < tolsqrt && abs(imag(roots[i])-imag(roots[j])) < 0.002 ) {
newroot += roots[j];
n += 1;
visited[j] = true;
}
}
if( n > 1 ) {
newroot /= n;
}
// there are still cases where even the mean is not accurate enough, until a better multi-root algorithm is used, need to use the sqrt
if( IKabs(imag(newroot)) < tolsqrt ) {
rawroots[numroots++] = real(newroot);
}
}
}
}
static inline void polyroots8(IkReal rawcoeffs[8+1], IkReal rawroots[8], int& numroots)
{
using std::complex;
if( rawcoeffs[0] == 0 ) {
// solve with one reduced degree
polyroots7(&rawcoeffs[1], &rawroots[0], numroots);
return;
}
IKFAST_ASSERT(rawcoeffs[0] != 0);
const IkReal tol = 128.0*std::numeric_limits<IkReal>::epsilon();
const IkReal tolsqrt = sqrt(std::numeric_limits<IkReal>::epsilon());
complex<IkReal> coeffs[8];
const int maxsteps = 110;
for(int i = 0; i < 8; ++i) {
coeffs[i] = complex<IkReal>(rawcoeffs[i+1]/rawcoeffs[0]);
}
complex<IkReal> roots[8];
IkReal err[8];
roots[0] = complex<IkReal>(1,0);
roots[1] = complex<IkReal>(0.4,0.9); // any complex number not a root of unity works
err[0] = 1.0;
err[1] = 1.0;
for(int i = 2; i < 8; ++i) {
roots[i] = roots[i-1]*roots[1];
err[i] = 1.0;
}
for(int step = 0; step < maxsteps; ++step) {
bool changed = false;
for(int i = 0; i < 8; ++i) {
if ( err[i] >= tol ) {
changed = true;
// evaluate
complex<IkReal> x = roots[i] + coeffs[0];
for(int j = 1; j < 8; ++j) {
x = roots[i] * x + coeffs[j];
}
for(int j = 0; j < 8; ++j) {
if( i != j ) {
if( roots[i] != roots[j] ) {
x /= (roots[i] - roots[j]);
}
}
}
roots[i] -= x;
err[i] = abs(x);
}
}
if( !changed ) {
break;
}
}
numroots = 0;
bool visited[8] = {false};
for(int i = 0; i < 8; ++i) {
if( !visited[i] ) {
// might be a multiple root, in which case it will have more error than the other roots
// find any neighboring roots, and take the average
complex<IkReal> newroot=roots[i];
int n = 1;
for(int j = i+1; j < 8; ++j) {
// care about error in real much more than imaginary
if( abs(real(roots[i])-real(roots[j])) < tolsqrt && abs(imag(roots[i])-imag(roots[j])) < 0.002 ) {
newroot += roots[j];
n += 1;
visited[j] = true;
}
}
if( n > 1 ) {
newroot /= n;
}
// there are still cases where even the mean is not accurate enough, until a better multi-root algorithm is used, need to use the sqrt
if( IKabs(imag(newroot)) < tolsqrt ) {
rawroots[numroots++] = real(newroot);
}
}
}
}
};
/// solves the inverse kinematics equations.
/// \param pfree is an array specifying the free joints of the chain.
IKFAST_API bool ComputeIk(const IkReal* eetrans, const IkReal* eerot, const IkReal* pfree, IkSolutionListBase<IkReal>& solutions) {
IKSolver solver;
return solver.ComputeIk(eetrans,eerot,pfree,solutions);
}
IKFAST_API bool ComputeIk2(const IkReal* eetrans, const IkReal* eerot, const IkReal* pfree, IkSolutionListBase<IkReal>& solutions, void* pOpenRAVEManip) {
IKSolver solver;
return solver.ComputeIk(eetrans,eerot,pfree,solutions);
}
IKFAST_API const char* GetKinematicsHash() { return "<robot:GenericRobot - iiwa7 (df59453aadeada0c1d102fc92db621ea)>"; }
IKFAST_API const char* GetIkFastVersion() { return "0x10000049"; }
#ifdef IKFAST_NAMESPACE
} // end namespace
#endif
#ifndef IKFAST_NO_MAIN
#include <stdio.h>
#include <stdlib.h>
#ifdef IKFAST_NAMESPACE
using namespace IKFAST_NAMESPACE;
#endif
int main(int argc, char** argv)
{
if( argc != 12+GetNumFreeParameters()+1 ) {
printf("\nUsage: ./ik r00 r01 r02 t0 r10 r11 r12 t1 r20 r21 r22 t2 free0 ...\n\n"
"Returns the ik solutions given the transformation of the end effector specified by\n"
"a 3x3 rotation R (rXX), and a 3x1 translation (tX).\n"
"There are %d free parameters that have to be specified.\n\n",GetNumFreeParameters());
return 1;
}
IkSolutionList<IkReal> solutions;
std::vector<IkReal> vfree(GetNumFreeParameters());
IkReal eerot[9],eetrans[3];
eerot[0] = atof(argv[1]); eerot[1] = atof(argv[2]); eerot[2] = atof(argv[3]); eetrans[0] = atof(argv[4]);
eerot[3] = atof(argv[5]); eerot[4] = atof(argv[6]); eerot[5] = atof(argv[7]); eetrans[1] = atof(argv[8]);
eerot[6] = atof(argv[9]); eerot[7] = atof(argv[10]); eerot[8] = atof(argv[11]); eetrans[2] = atof(argv[12]);
for(std::size_t i = 0; i < vfree.size(); ++i)
vfree[i] = atof(argv[13+i]);
bool bSuccess = ComputeIk(eetrans, eerot, vfree.size() > 0 ? &vfree[0] : NULL, solutions);
if( !bSuccess ) {
fprintf(stderr,"Failed to get ik solution\n");
return -1;
}
printf("Found %d ik solutions:\n", (int)solutions.GetNumSolutions());
std::vector<IkReal> solvalues(GetNumJoints());
for(std::size_t i = 0; i < solutions.GetNumSolutions(); ++i) {
const IkSolutionBase<IkReal>& sol = solutions.GetSolution(i);
printf("sol%d (free=%d): ", (int)i, (int)sol.GetFree().size());
std::vector<IkReal> vsolfree(sol.GetFree().size());
sol.GetSolution(&solvalues[0],vsolfree.size()>0?&vsolfree[0]:NULL);
for( std::size_t j = 0; j < solvalues.size(); ++j)
printf("%.15f, ", solvalues[j]);
printf("\n");
}
return 0;
}
#endif
| [
"leo.li.3821@gmail.com"
] | leo.li.3821@gmail.com |
e7a3879b536a2a43b931a20f302696f636e7cc94 | 9264ad419b73883a69fb02688ddc3ee40c53edbd | /Codechef/AUGLONG-STRINGRA.cpp | dd9b6214a57c83aff2e98476e2f35659e4e5089b | [] | no_license | manish1997/Competitive-Programming | 6d5e7fb6081d1a09f8658638bddcd1c72495c396 | b7048f770f7db8ac0bc871d59f1973482f79668f | refs/heads/master | 2021-01-13T04:31:13.082435 | 2020-03-22T20:32:04 | 2020-03-22T20:32:04 | 79,900,759 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,118 | cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define pin(n) printf("%d\n",n)
#define plln(n) printf("%lld\n",n)
#define pis(n) printf("%d ",n)
#define plls(n) printf("%lld ",n)
#define rep(i, start, end) for(int i=start; i<end; i++)
#define S second
#define F first
#define P pair<int,int>
#define PP pair<P,int>
#define mod 1000000007
#define MAX 100005
#define newLine printf("\n");
int n,m;
int ans[MAX];
int last[MAX];
bool done[MAX];
int distinct[MAX];
vector<int> adj[MAX];
int main() {
int t; si(t);
while(t--){
memset(ans,0,sizeof(ans));
memset(last,-1, sizeof(last));
rep(i,0,MAX){
adj[i].clear();
}
si(n);
si(m);
bool flag=true;
rep(i,0,m){
int a,b;
si(a); si(b);
if(a>=b) flag=false;
adj[a].push_back(b);
}
if(!flag){
pin(-1);
continue;
}
rep(i,0,n) sort(adj[i].begin(), adj[i].end());
int maxx=0;
rep(i,0,adj[0].size()){
if(ans[adj[0][i]]==0) {
ans[adj[0][i]]=++maxx;
last[maxx]=adj[0][i];
}
else flag=false;
}
if(!flag){
pin(-1);
continue;
}
rep(qq, 1, n){
if(adj[qq].size()==0){
flag=false;
break;
}
vector<int> curr=adj[qq];
rep(i,0,curr.size()){
if(i!=0 && curr[i-1]==curr[i]){
flag=false;
break;
}
if(ans[curr[i]]==0){
rep(j,1,maxx+1){
if(last[j]==qq){
ans[curr[i]]=j;
last[j]=curr[i];
break;
}
if(j==maxx){
flag=false;
}
}
}
if(!flag) break;
}
if(!flag) break;
}
if(!flag){
pin(-1);
continue;
}
//ans[5]=2;
// rep(i,1,n+1){
// pis(ans[i]);
// }
// printf("\n");
memset(done, false, sizeof(done));
memset(distinct,0,sizeof(distinct));
int cnt=0;
distinct[n+1]=0;
for(int i=n; i>=0; i--){
if(done[ans[i]]==false){
done[ans[i]]=true;
cnt++;
}
distinct[i]=cnt;
}
rep(i,0,n+1){
if(adj[i].size()!=distinct[i+1]){
flag=false;
break;
}
}
if(!flag){
pin(-1);
continue;
}
rep(i,1,n+1){
pis(ans[i]);
}
printf("\n");
}
return 0;
}
| [
"manu1.uec2014@gmail.com"
] | manu1.uec2014@gmail.com |
3941bd23f3f686d12d4d78c2ce4421380ceef158 | 481f182a92429ef5658e4749e355d2f8dc24dcd5 | /main.cpp | 72765c31ddad647fbdf006f201bfc7b842dc9f6a | [] | no_license | v-lavrushko/Learning | f09730d9e96746826faf6009d976b6d8294902f2 | 1f1ac83ac5d60d5f9748a91bf50038e61f57a461 | refs/heads/master | 2021-01-01T04:01:46.746259 | 2018-01-26T14:36:30 | 2018-01-26T14:36:30 | 97,101,863 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 903 | cpp | #include <iostream>
using namespace std;
void primes(unsigned long long int *arr2, unsigned long long int start, unsigned long long int end) {
unsigned long long int arr1[25000], i = 2, k = 0;
arr1[0] = 2;
arr1[1] = 3;
for (unsigned long long int x = 4; x < end + 1; x++) {
for (unsigned long long int y = 0; arr1[y] * arr1[y] <= x; y++) {
if (x % arr1[y] == 0) {
goto next;
}
}
arr1[i] = x;
i++;
next:
continue;
}
while (arr1[k] <= start) {
k++;
}
for (unsigned long long int j = 0; j<i; j++) {
*(arr2+j) = arr1[j+k];
}
}
int main() {
unsigned long long int arr2[25000], s = 100000, e = 1000000000;
primes(arr2, s, e);
for (unsigned long long int n = 0; arr2[n] <= e && arr2[n] != 0; n++) {
cout << arr2[n] << endl;
}
return 0;
}
| [
"noreply@github.com"
] | v-lavrushko.noreply@github.com |
15db677843c574dfba7905dbc26900e72f2d1d71 | d2d6aae454fd2042c39127e65fce4362aba67d97 | /build/iOS/Debug/include/Fuse.Controls.RegularPolygon.h | d2a6658ee900a0cc984ad632049b63c22923f707 | [] | no_license | Medbeji/Eventy | de88386ff9826b411b243d7719b22ff5493f18f5 | 521261bca5b00ba879e14a2992e6980b225c50d4 | refs/heads/master | 2021-01-23T00:34:16.273411 | 2017-09-24T21:16:34 | 2017-09-24T21:16:34 | 92,812,809 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,755 | h | // This file was generated based on '/Users/medbeji/Library/Application Support/Fusetools/Packages/Fuse.Controls.Primitives/1.0.2/shapes/$.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Fuse.Animations.IResize.h>
#include <Fuse.Binding.h>
#include <Fuse.Controls.Shape.h>
#include <Fuse.Drawing.IDrawObj-d34d045e.h>
#include <Fuse.Drawing.ISurfaceDrawable.h>
#include <Fuse.IActualPlacement.h>
#include <Fuse.INotifyUnrooted.h>
#include <Fuse.IProperties.h>
#include <Fuse.Node.h>
#include <Fuse.Scripting.IScriptObject.h>
#include <Fuse.Triggers.Actions.IHide.h>
#include <Fuse.Triggers.Actions.IShow.h>
#include <Fuse.Triggers.Actions-ea70af1f.h>
#include <Uno.Collections.ICollection-1.h>
#include <Uno.Collections.IEnumerable-1.h>
#include <Uno.Collections.IList-1.h>
#include <Uno.UX.IPropertyListener.h>
namespace g{namespace Fuse{namespace Controls{struct RegularPolygon;}}}
namespace g{namespace Fuse{namespace Drawing{struct Surface;}}}
namespace g{namespace Fuse{namespace Drawing{struct SurfacePath;}}}
namespace g{
namespace Fuse{
namespace Controls{
// public partial sealed class RegularPolygon :1531
// {
::g::Fuse::Controls::Shape_type* RegularPolygon_typeof();
void RegularPolygon__CreateSurfacePath_fn(RegularPolygon* __this, ::g::Fuse::Drawing::Surface* surface, ::g::Fuse::Drawing::SurfacePath** __retval);
void RegularPolygon__get_NeedSurface_fn(RegularPolygon* __this, bool* __retval);
void RegularPolygon__get_Sides_fn(RegularPolygon* __this, int* __retval);
void RegularPolygon__set_Sides_fn(RegularPolygon* __this, int* value);
struct RegularPolygon : ::g::Fuse::Controls::Shape
{
int _sides;
int Sides();
void Sides(int value);
};
// }
}}} // ::g::Fuse::Controls
| [
"medbeji@MacBook-Pro-de-MedBeji.local"
] | medbeji@MacBook-Pro-de-MedBeji.local |
9510dab2a1358e3d99bf055450c564369e543c6b | cdf92aa3a8a49dc044306c125356cca26910dbda | /src4/static/INDI2/oldEIRlibs/eirExe/eirExe.cpp | 1b8c04eb1b08a22d10709ec29ddd22d4ab144ff4 | [
"MIT"
] | permissive | eirTony/INDI1 | b7c5d2ba0922a509b32d9d411938ecdc0f725109 | 07fe9eff4fb88c6c2d636c94267ea8734d295223 | refs/heads/master | 2020-01-23T21:22:49.833055 | 2016-11-26T07:43:06 | 2016-11-26T07:43:06 | 74,568,244 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 43 | cpp | #include "eirExe.h"
eirExe::eirExe()
{
}
| [
"totto@eclipseir.com"
] | totto@eclipseir.com |
7952fe4a6618a509f5d237bacd8986329606fac7 | 15d44c4869cdd917083de807b98b8edb97df5714 | /Dynamic programming assignment -1/roy and coin boxes.cpp | c78fad1bafc7879818cc0c9bec54dae59b20ceeb | [] | no_license | imhkr/Eminence-CP-dec | 03140c93cc9c05bb56d6d7221c1f63d1ee09bb9b | b899a2f7ad1bccbd4aff48d028d0a0d9df436e9b | refs/heads/master | 2021-10-28T07:47:28.723101 | 2019-04-22T19:44:34 | 2019-04-22T19:44:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,025 | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[1000001] = {0};
int dp2[1000001] = {0};
int r_sum[1000001] = {0};
int main()
{
int t,n;
scanf(" %d",&t);
scanf(" %d",&n);
for(int i=0;i<n;i++)
{
int x,y;
scanf(" %d %d",&x,&y);
//We mark the ranges, this will help us fill up the dp
dp[x] += 1;
dp[y+1] -= 1;
}
//We fill up the dp
//After this operation dp[i] will tell us how many coins are there in ith coin box
for(int i=1;i<=t;i++)
{
dp[i] += dp[i-1];
//printf(" %d",dp[i]);
}
//How many coin boxes has exactly i coins? dp2[i] is this value
for(int i=0;i<1000001;i++)
{
dp2[dp[i]]++;
}
//Now we maintain a running sum of dp2 from left to right
//So r_sum[i] will tell us for how many coin boxes has atleast i coins in them
r_sum[1000000] = dp2[1000000];
for(int i=999999;i>=0;i--)
{
r_sum[i] = dp2[i] + r_sum[i+1];
}
//Now for each query we return the answer in O(1)
int q;
scanf(" %d",&q);
while(q--)
{
int z;
scanf(" %d",&z);
printf("%d\n",r_sum[z]);
}
return 0;
}
| [
"noreply@github.com"
] | imhkr.noreply@github.com |
944246190d712e4400a64e61c8bb228e834dea99 | 27a7b51c853902d757c50cb6fc5774310d09385a | /[Client]LUNA/PetResurrectionDialog.h | 9898e79a4ebbd7fe53cca65d620087930ed18277 | [] | no_license | WildGenie/LUNAPlus | f3ce20cf5b685efe98ab841eb1068819d2314cf3 | a1d6c24ece725df097ac9a975a94139117166124 | refs/heads/master | 2021-01-11T05:24:16.253566 | 2015-06-19T21:34:46 | 2015-06-19T21:34:46 | 71,666,622 | 4 | 2 | null | 2016-10-22T21:27:35 | 2016-10-22T21:27:34 | null | UTF-8 | C++ | false | false | 575 | h | #pragma once
#include "./interface/cdialog.h"
class cIconDialog;
class CVirtualItem;
class CItem;
class CPetResurrectionDialog :
public cDialog
{
cIconDialog* mIconDialog;
CVirtualItem* mSourceItem;
CItem* mUsedItem;
MSG_DWORD3 mMessage;
public:
CPetResurrectionDialog(void);
virtual ~CPetResurrectionDialog(void);
void Linking();
virtual BOOL FakeMoveIcon( LONG x, LONG y, cIcon* );
void SetUsedItem( CItem* pItem ) { mUsedItem = pItem; }
virtual void OnActionEvent(LONG lId, void* p, DWORD we);
virtual void SetActive( BOOL val );
void Send();
};
| [
"brandonroode75@gmail.com"
] | brandonroode75@gmail.com |
20a3cf3400b2a2718be4b6822828609ad8271080 | 340d1d8286caa3702d88bd4fbbebcbbe7dc93ef1 | /main/main.ino | 13b7b4ca0eda369106d6d8ef9291fb483db66e5c | [] | no_license | scifi6546/EE-102-GROUP | 018959787de284c812fe833fb5e0c344ab66a569 | 3428d2a30a2ddfe5045d68b52e870b90cf5821ee | refs/heads/master | 2020-05-04T04:03:25.384341 | 2019-04-28T01:07:00 | 2019-04-28T01:07:00 | 178,958,071 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 535 | ino | #include "game.hpp"
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
int lastValue = 0;
bool toggledSwitch(){
int a = analogRead(A0);
if(lastValue==a){
lastValue=a;
return false;
}else if(abs(a-lastValue)>800){
lastValue=a;
return true;
}
lastValue=a;
return false;
}
int count=0;
void loop() {
bool toggle=toggledSwitch();
count++;
//if(count%40==0)
//Serial.println(analogRead(A0));
if(toggle)
Serial.println("switch toggled");
}
| [
"scifi6546@protonmail.com"
] | scifi6546@protonmail.com |
83683f1536f8f413b5c6e564417e98c23628ed30 | 6b660cb96baa003de9e18e332b048c0f1fa67ab9 | /External/SDK/Proposal_SL_CoD_Chapter5_classes.h | 5e3c9492d822c94a9e956d622017f9e96daf2187 | [] | no_license | zanzo420/zSoT-SDK | 1edbff62b3e12695ecf3969537a6d2631a0ff36f | 5e581eb0400061f6e5f93b3affd95001f62d4f7c | refs/heads/main | 2022-07-30T03:35:51.225374 | 2021-07-07T01:07:20 | 2021-07-07T01:07:20 | 383,634,601 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 819 | h | #pragma once
// Name: SoT, Version: 2.2.0.2
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace CG
{
//---------------------------------------------------------------------------
// Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass Proposal_SL_CoD_Chapter5.Proposal_SL_CoD_Chapter5_C
// 0x0000 (FullSize[0x0140] - InheritedSize[0x0140])
class UProposal_SL_CoD_Chapter5_C : public UVoyageCheckpointProposalDesc
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("BlueprintGeneratedClass Proposal_SL_CoD_Chapter5.Proposal_SL_CoD_Chapter5_C");
return ptr;
}
void AfterRead();
void BeforeDelete();
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"Massimo.linker@gmail.com"
] | Massimo.linker@gmail.com |
da98b0b426578fdf3eabeea0dffc331d6f201d6a | dbcf311d97da672c49f2753cf927ec4eb93b5fc0 | /cpp05/ex03/Intern.cpp | 1d2b21056fd6cea6bcdb306d9ad5ef4a79f782e4 | [] | no_license | ekmbcd/Cpp_Piscine | fdbcd5b408ecba504e328f143caf9146fef838b6 | b8d4123229f362e0e50acc65020f1ded8d3d073a | refs/heads/main | 2023-05-01T06:05:11.494469 | 2021-05-12T16:20:22 | 2021-05-12T16:20:22 | 361,516,339 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,142 | cpp | #include "Intern.hpp"
Intern::Intern()
{
}
Intern::Intern(const Intern & src)
{
*this = src;
}
Intern::~Intern()
{
}
Intern & Intern::operator=(const Intern & src)
{
(void)src;
return(*this);
}
Form * Intern::makeShrub(std::string const & target)
{
return (new ShrubberyCreationForm(target));
}
Form * Intern::makeRobot(std::string const & target)
{
return (new RobotomyRequestForm(target));
}
Form * Intern::makePres(std::string const & target)
{
return (new PresidentialPardonForm(target));
}
typedef Form * (Intern::*form_constr) (std::string const & target);
Form * Intern::makeForm(std::string const & name, std::string const & target)
{
Form *ret;
std::string forms[3] = {
"shrubbery creation",
"robotomy request",
"presidential pardon"
};
form_constr functs[3] = {
&Intern::makeShrub,
&Intern::makeRobot,
&Intern::makePres
};
for (int i = 0; i < 3; i++)
{
if (name == forms[i])
{
ret = (this->*functs[i])(target);
std::cout << "Intern creates " << forms[i] << std::endl;
return (ret);
}
}
std::cout << "Intern doesn't know how to make " << name << std::endl;
return (NULL);
} | [
"ekmbcd@gmail.com"
] | ekmbcd@gmail.com |
0f8b15089ce2f0fb7b3d8c9f5a11c2a7440e6f77 | 5246133c32392ed5bb95df383b06d6d7b4443254 | /kits/interface/DosControlLook.cpp | f7cfda0280248c67e80a5b60f49c5bb612a56614 | [
"MIT"
] | permissive | D-os/libb2 | 428b483a59c0548bf7858ced6d513e3c514d9e9a | b9d0ad771c104b1463692095073ba4fcef05ecbf | refs/heads/main | 2023-04-14T08:10:14.943219 | 2023-04-11T17:32:38 | 2023-04-11T17:34:39 | 125,916,877 | 8 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 15,067 | cpp | #define CHECKBOX_BOX_SIZE 12.0f
#define CHECKBOX_TEXT_PADDING 5.0f
#include "DosControlLook.h"
#include <Bitmap.h>
#include <Control.h>
#include <Font.h>
#include <String.h>
#include <Window.h>
using namespace BPrivate;
DosControlLook::DosControlLook() {}
DosControlLook::~DosControlLook() {}
BAlignment DosControlLook::DefaultLabelAlignment() const
{
return BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);
}
float DosControlLook::DefaultLabelSpacing() const
{
return ceilf(be_plain_font->Size() / 2.0);
}
float DosControlLook::DefaultItemSpacing() const
{
return ceilf(be_plain_font->Size() * 0.85);
}
uint32 DosControlLook::Flags(BControl* control) const
{
uint32 flags = B_IS_CONTROL;
if (!control->IsEnabled())
flags |= B_DISABLED;
if (control->IsFocus() && control->Window() && control->Window()->IsActive()) {
flags |= B_FOCUSED;
}
switch (control->Value()) {
case B_CONTROL_ON:
flags |= B_ACTIVATED;
break;
case B_CONTROL_PARTIALLY_ON:
flags |= B_PARTIALLY_ACTIVATED;
break;
}
if (control->Parent() && (control->Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
// In this constellation, assume we want to render the control
// against the already existing view contents of the parent view.
flags |= B_BLEND_FRAME;
}
return flags;
}
void DosControlLook::DrawMenuBarBackground(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 flags,
uint32 borders)
{
if (!rect.IsValid() || !rect.Intersects(updateRect))
return;
// the surface edges
// colors
float topTint;
float bottomTint;
if ((flags & B_ACTIVATED) != 0) {
rgb_color bevelColor1 = tint_color(base, 1.40);
rgb_color bevelColor2 = tint_color(base, 1.25);
topTint = 1.25;
bottomTint = 1.20;
_DrawFrame(view, rect,
bevelColor1, bevelColor1,
bevelColor2, bevelColor2,
borders & B_TOP_BORDER);
}
else {
rgb_color cornerColor = tint_color(base, 0.9);
rgb_color bevelColorTop = tint_color(base, 0.5);
rgb_color bevelColorLeft = tint_color(base, 0.7);
rgb_color bevelColorRightBottom = tint_color(base, 1.08);
topTint = 0.69;
bottomTint = 1.03;
_DrawFrame(view, rect,
bevelColorLeft, bevelColorTop,
bevelColorRightBottom, bevelColorRightBottom,
cornerColor, cornerColor,
borders);
}
// draw surface top
_FillGradient(view, rect, base, topTint, bottomTint);
}
void DosControlLook::DrawMenuBackground(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags,
uint32 borders)
{
if (!rect.IsValid() || !rect.Intersects(updateRect))
return;
// inner bevel colors
rgb_color bevelLightColor;
rgb_color bevelShadowColor;
if ((flags & B_DISABLED) != 0) {
bevelLightColor = tint_color(base, 0.80);
bevelShadowColor = tint_color(base, 1.07);
}
else {
bevelLightColor = tint_color(base, 0.6);
bevelShadowColor = tint_color(base, 1.12);
}
// draw inner bevel
_DrawFrame(view, rect,
bevelLightColor, bevelLightColor,
bevelShadowColor, bevelShadowColor,
borders);
// draw surface top
view->SetHighColor(base);
view->FillRect(rect);
}
void DosControlLook::DrawMenuItemBackground(BView* view, BRect& rect,
const BRect& updateRect, const rgb_color& base, uint32 flags,
uint32 borders)
{
if (!rect.IsValid() || !rect.Intersects(updateRect))
return;
// surface edges
float topTint;
float bottomTint;
rgb_color selectedColor = base;
if ((flags & B_ACTIVATED) != 0) {
topTint = 0.9;
bottomTint = 1.05;
}
else if ((flags & B_DISABLED) != 0) {
topTint = 0.80;
bottomTint = 1.07;
}
else {
topTint = 0.6;
bottomTint = 1.12;
}
rgb_color bevelLightColor = tint_color(selectedColor, topTint);
rgb_color bevelShadowColor = tint_color(selectedColor, bottomTint);
// draw surface edges
_DrawFrame(view, rect,
bevelLightColor, bevelLightColor,
bevelShadowColor, bevelShadowColor,
borders);
// draw surface top
view->SetLowColor(selectedColor);
// _FillGradient(view, rect, selectedColor, topTint, bottomTint);
_FillGradient(view, rect, selectedColor, bottomTint, topTint);
}
void DosControlLook::DrawArrowShape(BView* view, BRect& rect,
const BRect& updateRect, const rgb_color& base, uint32 direction,
uint32 flags, float tint)
{
BPoint tri1, tri2, tri3;
float hInset = rect.Width() / 3;
float vInset = rect.Height() / 3;
rect.InsetBy(hInset, vInset);
switch (direction) {
case B_LEFT_ARROW:
tri1.Set(rect.right, rect.top);
tri2.Set(rect.right - rect.Width() / 1.33,
(rect.top + rect.bottom + 1) / 2);
tri3.Set(rect.right, rect.bottom + 1);
break;
case B_RIGHT_ARROW:
tri1.Set(rect.left + 1, rect.bottom + 1);
tri2.Set(rect.left + 1 + rect.Width() / 1.33,
(rect.top + rect.bottom + 1) / 2);
tri3.Set(rect.left + 1, rect.top);
break;
case B_UP_ARROW:
tri1.Set(rect.left, rect.bottom);
tri2.Set((rect.left + rect.right + 1) / 2,
rect.bottom - rect.Height() / 1.33);
tri3.Set(rect.right + 1, rect.bottom);
break;
case B_DOWN_ARROW:
default:
tri1.Set(rect.left, rect.top + 1);
tri2.Set((rect.left + rect.right + 1) / 2,
rect.top + 1 + rect.Height() / 1.33);
tri3.Set(rect.right + 1, rect.top + 1);
break;
case B_LEFT_UP_ARROW:
tri1.Set(rect.left, rect.bottom);
tri2.Set(rect.left, rect.top);
tri3.Set(rect.right - 1, rect.top);
break;
case B_RIGHT_UP_ARROW:
tri1.Set(rect.left + 1, rect.top);
tri2.Set(rect.right, rect.top);
tri3.Set(rect.right, rect.bottom);
break;
case B_RIGHT_DOWN_ARROW:
tri1.Set(rect.right, rect.top);
tri2.Set(rect.right, rect.bottom);
tri3.Set(rect.left + 1, rect.bottom);
break;
case B_LEFT_DOWN_ARROW:
tri1.Set(rect.right - 1, rect.bottom);
tri2.Set(rect.left, rect.bottom);
tri3.Set(rect.left, rect.top);
break;
}
if ((flags & B_DISABLED) != 0)
tint = (tint + B_NO_TINT + B_NO_TINT) / 3;
view->SetHighColor(tint_color(base, tint));
float penSize = view->PenSize();
drawing_mode mode = view->DrawingMode();
view->SetPenSize(ceilf(hInset / 2.0));
view->SetDrawingMode(B_OP_OVER);
view->MovePenTo(tri1);
view->StrokeLine(tri2);
view->StrokeLine(tri3);
view->SetPenSize(penSize);
view->SetDrawingMode(mode);
}
void DosControlLook::DrawBorder(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
border_style borderStyle, uint32 flags,
uint32 borders)
{
if (borderStyle == B_NO_BORDER)
return;
rgb_color scrollbarFrameColor = tint_color(base, B_DARKEN_2_TINT);
if (base.red + base.green + base.blue <= 128 * 3) {
scrollbarFrameColor = tint_color(base, B_LIGHTEN_1_TINT);
}
if ((flags & B_FOCUSED) != 0)
scrollbarFrameColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
if (borderStyle == B_FANCY_BORDER)
_DrawOuterResessedFrame(view, rect, base, 1.0, 1.0, flags, borders);
_DrawFrame(view, rect, scrollbarFrameColor, scrollbarFrameColor,
scrollbarFrameColor, scrollbarFrameColor, borders);
}
void DosControlLook::DrawLabel(BView* view, const char* label, BRect rect,
const BRect& updateRect, const rgb_color& base, uint32 flags,
const rgb_color* textColor)
{
DrawLabel(view, label, NULL, rect, updateRect, base, flags,
DefaultLabelAlignment(), textColor);
}
void DosControlLook::DrawLabel(BView* view, const char* label, BRect rect,
const BRect& updateRect, const rgb_color& base, uint32 flags,
const BAlignment& alignment, const rgb_color* textColor)
{
DrawLabel(view, label, NULL, rect, updateRect, base, flags, alignment,
textColor);
}
void DosControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base,
uint32 flags, const BPoint& where, const rgb_color* textColor)
{
rgb_color low;
rgb_color color;
rgb_color glowColor;
if (textColor)
glowColor = *textColor;
else if ((flags & B_IS_CONTROL) != 0)
glowColor = ui_color(B_CONTROL_TEXT_COLOR);
else
glowColor = ui_color(B_PANEL_TEXT_COLOR);
color = glowColor;
low = base;
if ((flags & B_DISABLED) != 0) {
color.red = (uint8)(((int32)low.red + color.red + 1) / 2);
color.green = (uint8)(((int32)low.green + color.green + 1) / 2);
color.blue = (uint8)(((int32)low.blue + color.blue + 1) / 2);
}
drawing_mode oldMode = view->DrawingMode();
view->SetHighColor(color);
view->SetDrawingMode(B_OP_OVER);
view->DrawString(label, where);
view->SetDrawingMode(oldMode);
}
void DosControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon,
BRect rect, const BRect& updateRect, const rgb_color& base, uint32 flags,
const BAlignment& alignment, const rgb_color* textColor)
{
if (!rect.Intersects(updateRect))
return;
if (!label && !icon)
return;
if (!label) {
// icon only
BRect alignedRect = _AlignInFrame(rect, icon->Bounds().Size(), alignment);
drawing_mode oldMode = view->DrawingMode();
view->SetDrawingMode(B_OP_OVER);
view->DrawBitmap(icon, alignedRect.LeftTop());
view->SetDrawingMode(oldMode);
return;
}
// label, possibly with icon
float availableWidth = rect.Width() + 1;
float width = 0;
float textOffset = 0;
float height = 0;
if (icon) {
width = icon->Bounds().Width() + DefaultLabelSpacing() + 1;
height = icon->Bounds().Height() + 1;
textOffset = width;
availableWidth -= textOffset;
}
// truncate the label if necessary and get the width and height
BString truncatedLabel(label);
BFont font;
view->GetFont(&font);
font.TruncateString(&truncatedLabel, B_TRUNCATE_END, availableWidth);
width += ceilf(font.StringWidth(truncatedLabel.String()));
font_height fontHeight;
font.GetHeight(&fontHeight);
float textHeight = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent);
height = std::max(height, textHeight);
// handle alignment
BRect alignedRect(_AlignOnRect(rect, BSize(width - 1, height - 1), alignment));
if (icon != NULL) {
BPoint location(alignedRect.LeftTop());
if (icon->Bounds().Height() + 1 < height)
location.y += ceilf((height - icon->Bounds().Height() - 1) / 2);
drawing_mode oldMode = view->DrawingMode();
view->SetDrawingMode(B_OP_OVER);
view->DrawBitmap(icon, location);
view->SetDrawingMode(oldMode);
}
BPoint location(alignedRect.left + textOffset,
alignedRect.top + ceilf(fontHeight.ascent));
if (textHeight < height)
location.y += ceilf((height - textHeight) / 2);
DrawLabel(view, truncatedLabel.String(), base, flags, location, textColor);
}
#pragma mark -
void DosControlLook::_DrawOuterResessedFrame(BView* view, BRect& rect,
const rgb_color& base, float contrast, float brightness, uint32 flags,
uint32 borders)
{
rgb_color edgeLightColor = ui_color(B_SHINE_COLOR);
rgb_color edgeShadowColor = ui_color(B_SHADOW_COLOR);
if ((flags & B_BLEND_FRAME) != 0) {
// assumes the background has already been painted
drawing_mode oldDrawingMode = view->DrawingMode();
view->SetDrawingMode(B_OP_ALPHA);
_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor,
edgeLightColor, edgeLightColor, borders);
view->SetDrawingMode(oldDrawingMode);
}
else {
_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor,
edgeLightColor, edgeLightColor, borders);
}
}
void DosControlLook::_DrawFrame(BView* view, BRect& rect, const rgb_color& left,
const rgb_color& top, const rgb_color& right, const rgb_color& bottom,
uint32 borders)
{
view->BeginLineArray(4);
if (borders & B_LEFT_BORDER) {
view->AddLine(
BPoint(rect.left, rect.bottom),
BPoint(rect.left, rect.top), left);
rect.left++;
}
if (borders & B_TOP_BORDER) {
view->AddLine(
BPoint(rect.left, rect.top),
BPoint(rect.right, rect.top), top);
rect.top++;
}
if (borders & B_RIGHT_BORDER) {
view->AddLine(
BPoint(rect.right, rect.top),
BPoint(rect.right, rect.bottom), right);
rect.right--;
}
if (borders & B_BOTTOM_BORDER) {
view->AddLine(
BPoint(rect.left, rect.bottom),
BPoint(rect.right, rect.bottom), bottom);
rect.bottom--;
}
view->EndLineArray();
}
void DosControlLook::_DrawFrame(BView* view, BRect& rect, const rgb_color& left,
const rgb_color& top, const rgb_color& right, const rgb_color& bottom,
const rgb_color& rightTop, const rgb_color& leftBottom, uint32 borders)
{
view->BeginLineArray(6);
if (borders & B_TOP_BORDER) {
if (borders & B_RIGHT_BORDER) {
view->AddLine(
BPoint(rect.left, rect.top),
BPoint(rect.right - 1, rect.top), top);
view->AddLine(
BPoint(rect.right, rect.top),
BPoint(rect.right, rect.top), rightTop);
}
else {
view->AddLine(
BPoint(rect.left, rect.top),
BPoint(rect.right, rect.top), top);
}
rect.top++;
}
if (borders & B_LEFT_BORDER) {
view->AddLine(
BPoint(rect.left, rect.top),
BPoint(rect.left, rect.bottom - 1), left);
view->AddLine(
BPoint(rect.left, rect.bottom),
BPoint(rect.left, rect.bottom), leftBottom);
rect.left++;
}
if (borders & B_BOTTOM_BORDER) {
view->AddLine(
BPoint(rect.left, rect.bottom),
BPoint(rect.right, rect.bottom), bottom);
rect.bottom--;
}
if (borders & B_RIGHT_BORDER) {
view->AddLine(
BPoint(rect.right, rect.bottom),
BPoint(rect.right, rect.top), right);
rect.right--;
}
view->EndLineArray();
}
// AlignInFrame
// This method restricts the dimensions of the resulting rectangle according
// to the available size specified by maxSize.
BRect DosControlLook::_AlignInFrame(BRect frame, BSize maxSize, BAlignment alignment)
{
// align according to the given alignment
if (maxSize.width < frame.Width()
&& alignment.horizontal != B_ALIGN_USE_FULL_WIDTH) {
frame.left += (int)((frame.Width() - maxSize.width) * alignment.RelativeHorizontal());
frame.right = frame.left + maxSize.width;
}
if (maxSize.height < frame.Height()
&& alignment.vertical != B_ALIGN_USE_FULL_HEIGHT) {
frame.top += (int)((frame.Height() - maxSize.height) * alignment.RelativeVertical());
frame.bottom = frame.top + maxSize.height;
}
return frame;
}
void DosControlLook::_FillGradient(BView* view, const BRect& rect,
const rgb_color& base, float topTint, float bottomTint,
orientation orientation)
{
// BGradientLinear gradient;
// _MakeGradient(gradient, rect, base, topTint, bottomTint, orientation);
// view->FillRect(rect, gradient);
// FIXME: temporary hack
view->SetHighColor(base);
view->FillRect(rect);
}
// AlignOnRect
// This method, unlike AlignInFrame(), provides the possibility to return
// a rectangle with dimensions greater than the available size.
BRect DosControlLook::_AlignOnRect(BRect rect, BSize size, BAlignment alignment)
{
rect.left += (int)((rect.Width() - size.width) * alignment.RelativeHorizontal());
rect.top += (int)(((rect.Height() - size.height)) * alignment.RelativeVertical());
rect.right = rect.left + size.width;
rect.bottom = rect.top + size.height;
return rect;
}
| [
"tomasz@sterna.link"
] | tomasz@sterna.link |
9b4f03b5e8e89d85c7bd421cd2288bb3391136c8 | 470fae08316b55246ab01675ac5013febfb13eee | /src/server/game/Server/Packets/TalentPackets.cpp | c852f46de9da81ee556cf8e04bc8c4f4b2b170b8 | [] | no_license | adde13372/shadowcore | 8db6fb6ccc99821e6bd40237a0c284ce7cf543c2 | aa87944193ce02f6e99f7b35eceac5023abfca1b | refs/heads/main | 2023-04-01T07:38:39.359558 | 2021-04-03T07:54:17 | 2021-04-03T07:54:17 | 354,320,611 | 4 | 8 | null | 2021-04-03T15:02:49 | 2021-04-03T15:02:49 | null | UTF-8 | C++ | false | false | 3,671 | cpp | /*
* Copyright 2021 ShadowCore
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TalentPackets.h"
ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Talent::PvPTalent& pvpTalent)
{
data >> pvpTalent.PvPTalentID;
data >> pvpTalent.Slot;
return data;
}
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Talent::PvPTalent const& pvpTalent)
{
data << uint16(pvpTalent.PvPTalentID);
data << uint8(pvpTalent.Slot);
return data;
}
WorldPacket const* WorldPackets::Talent::UpdateTalentData::Write()
{
_worldPacket << uint8(Info.ActiveGroup);
_worldPacket << uint32(Info.PrimarySpecialization);
_worldPacket << uint32(Info.TalentGroups.size());
for (auto& talentGroupInfo : Info.TalentGroups)
{
_worldPacket << uint32(talentGroupInfo.SpecID);
_worldPacket << uint32(talentGroupInfo.TalentIDs.size());
_worldPacket << uint32(talentGroupInfo.PvPTalents.size());
for (uint16 talent : talentGroupInfo.TalentIDs)
_worldPacket << uint16(talent);
for (PvPTalent talent : talentGroupInfo.PvPTalents)
_worldPacket << talent;
}
return &_worldPacket;
}
void WorldPackets::Talent::LearnTalents::Read()
{
Talents.resize(_worldPacket.ReadBits(6));
for (uint32 i = 0; i < Talents.size(); ++i)
_worldPacket >> Talents[i];
}
WorldPacket const* WorldPackets::Talent::RespecWipeConfirm::Write()
{
_worldPacket << int8(RespecType);
_worldPacket << uint32(Cost);
_worldPacket << RespecMaster;
return &_worldPacket;
}
void WorldPackets::Talent::ConfirmRespecWipe::Read()
{
_worldPacket >> RespecMaster;
_worldPacket >> RespecType;
}
WorldPacket const* WorldPackets::Talent::LearnTalentFailed::Write()
{
_worldPacket.WriteBits(Reason, 4);
_worldPacket << int32(SpellID);
_worldPacket << uint32(Talents.size());
if (!Talents.empty())
_worldPacket.append(Talents.data(), Talents.size());
return &_worldPacket;
}
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Talent::GlyphBinding const& glyphBinding)
{
data << uint32(glyphBinding.SpellID);
data << uint16(glyphBinding.GlyphID);
return data;
}
WorldPacket const* WorldPackets::Talent::ActiveGlyphs::Write()
{
_worldPacket << uint32(Glyphs.size());
for (GlyphBinding const& glyph : Glyphs)
_worldPacket << glyph;
_worldPacket.WriteBit(IsFullUpdate);
_worldPacket.FlushBits();
return &_worldPacket;
}
void WorldPackets::Talent::LearnPvpTalents::Read()
{
Talents.resize(_worldPacket.read<uint32>());
for (uint32 i = 0; i < Talents.size(); ++i)
_worldPacket >> Talents[i];
}
WorldPacket const* WorldPackets::Talent::LearnPvpTalentFailed::Write()
{
_worldPacket.WriteBits(Reason, 4);
_worldPacket << int32(SpellID);
_worldPacket << uint32(Talents.size());
for (PvPTalent pvpTalent : Talents)
_worldPacket << pvpTalent;
return &_worldPacket;
}
void WorldPackets::Talent::UnlearnSpecialization::Read()
{
_worldPacket >> SpecializationID;
}
| [
"81566364+NemoPRM@users.noreply.github.com"
] | 81566364+NemoPRM@users.noreply.github.com |
2ed74f1f403797e61974b1604bbf73e720110425 | f83685ad975f5270a788a48971dbbff73da09470 | /ictclas-linux32/Example.cpp | f56e7c0941b81cef315a7b3dedf939ecb85658a3 | [] | no_license | daizw/judou | 5447dd188f7a53c58f8da6785e6e9d009cd72b6b | 5ae3ee96c8e55a4e7b7071c8d528ba63414a400b | refs/heads/master | 2021-01-01T16:06:19.862973 | 2012-05-15T02:08:02 | 2012-05-15T02:08:02 | 32,115,520 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 5,715 | cpp | // win_cDemo.cpp : 定义控制台应用程序的入口点。
//
#include "ICTCLAS2011.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef OS_LINUX
#pragma comment(lib, "ICTCLAS2011.lib")
#else
#include <iconv.h>
#endif
//Linux
#ifdef OS_LINUX
#define _stricmp(X,Y) strcasecmp((X),(Y))
#define _strnicmp(X,Y,Z) strncasecmp((X),(Y),(Z))
#define strnicmp(X,Y,Z) strncasecmp((X),(Y),(Z))
#define _fstat(X,Y) fstat((X),(Y))
#define _fileno(X) fileno((X))
#define _stat stat
#define _getcwd getcwd
#define _off_t off_t
#define PATH_DELEMETER "/"
int MAX_OUTPUT = 1024;
char * g_buf = NULL;
iconv_t g_cd = NULL;
void open_output(const char* to, const char* from)
{
if (g_cd != NULL)
iconv_close(g_cd);
g_cd = iconv_open(to, from);
if (g_cd == (iconv_t)-1) {
printf("iconv_open failed!\n");
exit(EXIT_FAILURE);
}
g_buf = (char *)realloc(g_buf, MAX_OUTPUT);
memset(g_buf, 0, MAX_OUTPUT);
}
char * prepare_output(const char *msg)
{
int len = strlen(msg);
if (len > MAX_OUTPUT)
{
MAX_OUTPUT = len;
g_buf = (char *)realloc(g_buf, MAX_OUTPUT);
}
memset(g_buf, 0, MAX_OUTPUT);
char *inptr = (char *)msg;
char *outptr = g_buf;
size_t in_left = len;
size_t out_left = MAX_OUTPUT;
size_t r = iconv(g_cd, &inptr, &in_left, &outptr, &out_left);
if (r == -1) {
printf("iconv failed!\n");
exit(EXIT_FAILURE);
}
return g_buf;
}
void close_output()
{
if (g_buf != NULL)
free(g_buf);
iconv_close(g_cd);
}
#else
#pragma warning(disable:4786)
#define PATH_DELEMETER "\\"
void open_output(const char* from, const char* to) { }
char * prepare_output(const char *msg)
{
return msg;
}
void close_output() { }
#endif
void SplitGBK(const char *sInput);
void SplitBIG5();
void SplitUTF8();
void SplitGBK(const char *sInput)
{//分词演示
//初始化分词组件
if(!ICTCLAS_Init())//数据在当前路径下,默认为GBK编码的分词
{
printf("ICTCLAS INIT FAILED!\n");
return ;
}
ICTCLAS_SetPOSmap(ICT_POS_MAP_SECOND);
char sSentence[2000]="三枪拍案惊奇的主创人员包括孙红雷、小沈阳、闫妮等,导演为张艺谋";
const char * sResult;
int nCount;
ICTCLAS_ParagraphProcessA(sSentence,&nCount);
printf("nCount=%d\n",nCount);
ICTCLAS_AddUserWord("孙红雷 yym");//添加孙红雷,作为演员名称
sResult = ICTCLAS_ParagraphProcess(sSentence,1);
printf("%s\n", prepare_output(sResult));
ICTCLAS_AddUserWord("小沈阳 yym");//添加小沈阳,作为演员名称
sResult = ICTCLAS_ParagraphProcess(sSentence,1);
printf("%s\n", prepare_output(sResult));
ICTCLAS_AddUserWord("闫妮 yym");//添加闫妮,作为演员名称
sResult = ICTCLAS_ParagraphProcess(sSentence,1);
printf("%s\n", prepare_output(sResult));
ICTCLAS_AddUserWord("三枪拍案惊奇 dym");//添加三枪拍案惊奇,作为电影名称
sResult = ICTCLAS_ParagraphProcess(sSentence,1);
printf("%s\n", prepare_output(sResult));
while(_stricmp(sSentence,"q")!=0)
{
sResult = ICTCLAS_ParagraphProcess(sSentence,0);
printf("%s\nInput string now('q' to quit)!\n", prepare_output(sResult));
scanf("%s", sSentence);
open_output("GB18030", "UTF-8");
char *p = prepare_output(sSentence);
strcpy(sSentence, p);
sSentence[strlen(p)+1] = NULL;
open_output("UTF-8", "GB18030");
p = prepare_output(sSentence);
}
//导入用户词典前
printf(prepare_output("未导入用户词典:\n"));
sResult = ICTCLAS_ParagraphProcess(sInput, 0);
printf("%s\n", prepare_output(sResult));
//导入用户词典后
printf(prepare_output("\n导入用户词典后:\n"));
nCount = ICTCLAS_ImportUserDict("userdic.txt");//userdic.txt覆盖以前的用户词典
//保存用户词典
ICTCLAS_SaveTheUsrDic();
printf(prepare_output("导入%d个用户词。\n"), nCount);
sResult = ICTCLAS_ParagraphProcess(sInput, 1);
printf("%s\n", prepare_output(sResult));
//动态添加用户词
printf(prepare_output("\n动态添加用户词后:\n"));
ICTCLAS_AddUserWord("计算机学院 xueyuan");
ICTCLAS_SaveTheUsrDic();
sResult = ICTCLAS_ParagraphProcess(sInput, 1);
printf("%s\n", prepare_output(sResult));
//对文件进行分词
ICTCLAS_FileProcess("testGBK.txt","testGBK_result.txt",1);
//释放分词组件资源
ICTCLAS_Exit();
}
void SplitBIG5()
{
//初始化分词组件
if(!ICTCLAS_Init("",BIG5_CODE))//数据在当前路径下,设置为BIG5编码的分词
{
printf("ICTCLAS INIT FAILED!\n");
return ;
}
ICTCLAS_FileProcess("testBIG.txt","testBIG_result.txt");
ICTCLAS_Exit();
}
void SplitUTF8()
{
//初始化分词组件
if(!ICTCLAS_Init("",UTF8_CODE))//数据在当前路径下,设置为UTF8编码的分词
{
printf("ICTCLAS INIT FAILED!\n");
return ;
}
ICTCLAS_FileProcess("testUTF.txt","testUTF_result.txt");
ICTCLAS_Exit();
}
int main()
{
open_output("UTF-8", "GB18030");
const char *sInput = "张华平2009年底调入北京理工大学计算机学院。";
//分词
SplitBIG5();
SplitGBK(sInput);
SplitUTF8();
//char buf[1024];
//scanf("%s", buf);
//open_output("GB18030", "UTF-8");
//char *p = prepare_output(buf);
//strcpy(buf, p);
//open_output("UTF-8", "GB18030");
//p = prepare_output(buf);
//printf("%s\n", p);
close_output();
return 1;
}
| [
"twinsant@2b19d78c-24d0-11de-82e8-8d21a8f7b98a"
] | twinsant@2b19d78c-24d0-11de-82e8-8d21a8f7b98a |
f14631398fc129052216f53eae58b35003a5fb54 | 3f18ca377ffd9e73c3dacf12decf78c7c7994757 | /src/unique_path.hh | 0fec51e7870f60d332eae5d1bf3c6548e4739b0a | [
"BSD-2-Clause"
] | permissive | xanloboi/lnav | 070c1bc738e6e2b380cea1b8a4d96a7423b81a8e | c52240a25d02781b06bc0c8f386315ee5c3e2c10 | refs/heads/master | 2023-09-04T08:55:43.739825 | 2021-10-28T16:22:08 | 2021-10-28T16:22:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,827 | hh | /**
* Copyright (c) 2018, Timothy Stack
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Timothy Stack nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @file unique_path.hh
*/
#ifndef LNAV_UNIQUE_PATH_HH
#define LNAV_UNIQUE_PATH_HH
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "ghc/filesystem.hpp"
/**
* A source of a path for the unique_path_generator.
*/
class unique_path_source {
public:
virtual ~unique_path_source() = default;
virtual void set_unique_path(const std::string &path) {
this->ups_unique_path = path;
}
virtual std::string get_unique_path() const {
return this->ups_unique_path;
}
virtual ghc::filesystem::path get_path() const = 0;
ghc::filesystem::path& get_path_prefix() {
return this->ups_prefix;
}
void set_path_prefix(const ghc::filesystem::path &prefix) {
this->ups_prefix = prefix;
}
private:
ghc::filesystem::path ups_prefix;
std::string ups_unique_path;
};
/**
* Given a collection of filesystem paths, this class will generate a shortened
* and unique path for each of the given paths.
*/
class unique_path_generator {
public:
void add_source(const std::shared_ptr<unique_path_source>& path_source);
void generate();
std::map<std::string, std::vector<std::shared_ptr<unique_path_source>>> upg_unique_paths;
size_t upg_max_len{0};
};
#endif //LNAV_UNIQUE_PATH_HH
| [
"timothyshanestack@gmail.com"
] | timothyshanestack@gmail.com |
c37c9ba3f122e4cdb3c0d2f1778324a06359415d | cf86574f8dc83ac340b9f7816fb55c1583c3b5c8 | /ios/Pods/Flipper-Folly/folly/String-inl.h | 3e0dfe05cbe5c7cf4a3d652838bcb7f5383b859b | [
"Apache-2.0",
"MIT"
] | permissive | juxtin/yarnu | 94b9f6068ebf3dd46b02173eb2cb9b394a06c969 | a3c3748a6738283644f252f87244880ca430c2f4 | refs/heads/master | 2022-12-30T07:17:56.708695 | 2020-09-28T19:29:02 | 2020-09-28T19:29:02 | 299,406,578 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 19,918 | h | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <iterator>
#include <stdexcept>
#include <folly/CppAttributes.h>
#ifndef FOLLY_STRING_H_
#error This file may only be included from String.h
#endif
namespace folly {
namespace detail {
// Map from character code to value of one-character escape sequence
// ('\n' = 10 maps to 'n'), 'O' if the character should be printed as
// an octal escape sequence, or 'P' if the character is printable and
// should be printed as is.
extern const std::array<char, 256> cEscapeTable;
} // namespace detail
template <class String>
void cEscape(StringPiece str, String& out) {
char esc[4];
esc[0] = '\\';
out.reserve(out.size() + str.size());
auto p = str.begin();
auto last = p; // last regular character
// We advance over runs of regular characters (printable, not double-quote or
// backslash) and copy them in one go; this is faster than calling push_back
// repeatedly.
while (p != str.end()) {
char c = *p;
unsigned char v = static_cast<unsigned char>(c);
char e = detail::cEscapeTable[v];
if (e == 'P') { // printable
++p;
} else if (e == 'O') { // octal
out.append(&*last, size_t(p - last));
esc[1] = '0' + ((v >> 6) & 7);
esc[2] = '0' + ((v >> 3) & 7);
esc[3] = '0' + (v & 7);
out.append(esc, 4);
++p;
last = p;
} else { // special 1-character escape
out.append(&*last, size_t(p - last));
esc[1] = e;
out.append(esc, 2);
++p;
last = p;
}
}
out.append(&*last, size_t(p - last));
}
namespace detail {
// Map from the character code of the character following a backslash to
// the unescaped character if a valid one-character escape sequence
// ('n' maps to 10 = '\n'), 'O' if this is the first character of an
// octal escape sequence, 'X' if this is the first character of a
// hexadecimal escape sequence, or 'I' if this escape sequence is invalid.
extern const std::array<char, 256> cUnescapeTable;
// Map from the character code to the hex value, or 16 if invalid hex char.
extern const std::array<unsigned char, 256> hexTable;
} // namespace detail
template <class String>
void cUnescape(StringPiece str, String& out, bool strict) {
out.reserve(out.size() + str.size());
auto p = str.begin();
auto last = p; // last regular character (not part of an escape sequence)
// We advance over runs of regular characters (not backslash) and copy them
// in one go; this is faster than calling push_back repeatedly.
while (p != str.end()) {
char c = *p;
if (c != '\\') { // normal case
++p;
continue;
}
out.append(&*last, p - last);
++p;
if (p == str.end()) { // backslash at end of string
if (strict) {
throw_exception<std::invalid_argument>("incomplete escape sequence");
}
out.push_back('\\');
last = p;
continue;
}
char e = detail::cUnescapeTable[static_cast<unsigned char>(*p)];
if (e == 'O') { // octal
unsigned char val = 0;
for (int i = 0; i < 3 && p != str.end() && *p >= '0' && *p <= '7';
++i, ++p) {
val <<= 3;
val |= (*p - '0');
}
out.push_back(val);
last = p;
} else if (e == 'X') { // hex
++p;
if (p == str.end()) { // \x at end of string
if (strict) {
throw_exception<std::invalid_argument>(
"incomplete hex escape sequence");
}
out.append("\\x");
last = p;
continue;
}
unsigned char val = 0;
unsigned char h;
for (; (p != str.end() &&
(h = detail::hexTable[static_cast<unsigned char>(*p)]) < 16);
++p) {
val <<= 4;
val |= h;
}
out.push_back(val);
last = p;
} else if (e == 'I') { // invalid
if (strict) {
throw_exception<std::invalid_argument>("invalid escape sequence");
}
out.push_back('\\');
out.push_back(*p);
++p;
last = p;
} else { // standard escape sequence, \' etc
out.push_back(e);
++p;
last = p;
}
}
out.append(&*last, p - last);
}
namespace detail {
// Map from character code to escape mode:
// 0 = pass through
// 1 = unused
// 2 = pass through in PATH mode
// 3 = space, replace with '+' in QUERY mode
// 4 = percent-encode
extern const std::array<unsigned char, 256> uriEscapeTable;
} // namespace detail
template <class String>
void uriEscape(StringPiece str, String& out, UriEscapeMode mode) {
static const char hexValues[] = "0123456789abcdef";
char esc[3];
esc[0] = '%';
// Preallocate assuming that 25% of the input string will be escaped
out.reserve(out.size() + str.size() + 3 * (str.size() / 4));
auto p = str.begin();
auto last = p; // last regular character
// We advance over runs of passthrough characters and copy them in one go;
// this is faster than calling push_back repeatedly.
unsigned char minEncode = static_cast<unsigned char>(mode);
while (p != str.end()) {
char c = *p;
unsigned char v = static_cast<unsigned char>(c);
unsigned char discriminator = detail::uriEscapeTable[v];
if (LIKELY(discriminator <= minEncode)) {
++p;
} else if (mode == UriEscapeMode::QUERY && discriminator == 3) {
out.append(&*last, size_t(p - last));
out.push_back('+');
++p;
last = p;
} else {
out.append(&*last, size_t(p - last));
esc[1] = hexValues[v >> 4];
esc[2] = hexValues[v & 0x0f];
out.append(esc, 3);
++p;
last = p;
}
}
out.append(&*last, size_t(p - last));
}
template <class String>
void uriUnescape(StringPiece str, String& out, UriEscapeMode mode) {
out.reserve(out.size() + str.size());
auto p = str.begin();
auto last = p;
// We advance over runs of passthrough characters and copy them in one go;
// this is faster than calling push_back repeatedly.
while (p != str.end()) {
char c = *p;
switch (c) {
case '%': {
if (UNLIKELY(std::distance(p, str.end()) < 3)) {
throw_exception<std::invalid_argument>(
"incomplete percent encode sequence");
}
auto h1 = detail::hexTable[static_cast<unsigned char>(p[1])];
auto h2 = detail::hexTable[static_cast<unsigned char>(p[2])];
if (UNLIKELY(h1 == 16 || h2 == 16)) {
throw_exception<std::invalid_argument>(
"invalid percent encode sequence");
}
out.append(&*last, size_t(p - last));
out.push_back((h1 << 4) | h2);
p += 3;
last = p;
break;
}
case '+':
if (mode == UriEscapeMode::QUERY) {
out.append(&*last, size_t(p - last));
out.push_back(' ');
++p;
last = p;
break;
}
// else fallthrough
FOLLY_FALLTHROUGH;
default:
++p;
break;
}
}
out.append(&*last, size_t(p - last));
}
namespace detail {
/*
* The following functions are type-overloaded helpers for
* internalSplit().
*/
inline size_t delimSize(char) {
return 1;
}
inline size_t delimSize(StringPiece s) {
return s.size();
}
inline bool atDelim(const char* s, char c) {
return *s == c;
}
inline bool atDelim(const char* s, StringPiece sp) {
return !std::memcmp(s, sp.start(), sp.size());
}
// These are used to short-circuit internalSplit() in the case of
// 1-character strings.
inline char delimFront(char c) {
// This one exists only for compile-time; it should never be called.
std::abort();
return c;
}
inline char delimFront(StringPiece s) {
assert(!s.empty() && s.start() != nullptr);
return *s.start();
}
/*
* Shared implementation for all the split() overloads.
*
* This uses some external helpers that are overloaded to let this
* algorithm be more performant if the deliminator is a single
* character instead of a whole string.
*
* @param ignoreEmpty iff true, don't copy empty segments to output
*/
template <class OutStringT, class DelimT, class OutputIterator>
void internalSplit(
DelimT delim,
StringPiece sp,
OutputIterator out,
bool ignoreEmpty) {
assert(sp.empty() || sp.start() != nullptr);
const char* s = sp.start();
const size_t strSize = sp.size();
const size_t dSize = delimSize(delim);
if (dSize > strSize || dSize == 0) {
if (!ignoreEmpty || strSize > 0) {
*out++ = to<OutStringT>(sp);
}
return;
}
if (std::is_same<DelimT, StringPiece>::value && dSize == 1) {
// Call the char version because it is significantly faster.
return internalSplit<OutStringT>(delimFront(delim), sp, out, ignoreEmpty);
}
size_t tokenStartPos = 0;
size_t tokenSize = 0;
for (size_t i = 0; i <= strSize - dSize; ++i) {
if (atDelim(&s[i], delim)) {
if (!ignoreEmpty || tokenSize > 0) {
*out++ = to<OutStringT>(sp.subpiece(tokenStartPos, tokenSize));
}
tokenStartPos = i + dSize;
tokenSize = 0;
i += dSize - 1;
} else {
++tokenSize;
}
}
tokenSize = strSize - tokenStartPos;
if (!ignoreEmpty || tokenSize > 0) {
*out++ = to<OutStringT>(sp.subpiece(tokenStartPos, tokenSize));
}
}
template <class String>
StringPiece prepareDelim(const String& s) {
return StringPiece(s);
}
inline char prepareDelim(char c) {
return c;
}
template <class OutputType>
void toOrIgnore(StringPiece input, OutputType& output) {
output = folly::to<OutputType>(input);
}
inline void toOrIgnore(StringPiece, decltype(std::ignore)&) {}
template <bool exact, class Delim, class OutputType>
bool splitFixed(const Delim& delimiter, StringPiece input, OutputType& output) {
static_assert(
exact || std::is_same<OutputType, StringPiece>::value ||
IsSomeString<OutputType>::value ||
std::is_same<OutputType, decltype(std::ignore)>::value,
"split<false>() requires that the last argument be a string type "
"or std::ignore");
if (exact && UNLIKELY(std::string::npos != input.find(delimiter))) {
return false;
}
toOrIgnore(input, output);
return true;
}
template <bool exact, class Delim, class OutputType, class... OutputTypes>
bool splitFixed(
const Delim& delimiter,
StringPiece input,
OutputType& outHead,
OutputTypes&... outTail) {
size_t cut = input.find(delimiter);
if (UNLIKELY(cut == std::string::npos)) {
return false;
}
StringPiece head(input.begin(), input.begin() + cut);
StringPiece tail(
input.begin() + cut + detail::delimSize(delimiter), input.end());
if (LIKELY(splitFixed<exact>(delimiter, tail, outTail...))) {
toOrIgnore(head, outHead);
return true;
}
return false;
}
} // namespace detail
//////////////////////////////////////////////////////////////////////
template <class Delim, class String, class OutputType>
void split(
const Delim& delimiter,
const String& input,
std::vector<OutputType>& out,
bool ignoreEmpty) {
detail::internalSplit<OutputType>(
detail::prepareDelim(delimiter),
StringPiece(input),
std::back_inserter(out),
ignoreEmpty);
}
template <class Delim, class String, class OutputType>
void split(
const Delim& delimiter,
const String& input,
fbvector<OutputType, std::allocator<OutputType>>& out,
bool ignoreEmpty) {
detail::internalSplit<OutputType>(
detail::prepareDelim(delimiter),
StringPiece(input),
std::back_inserter(out),
ignoreEmpty);
}
template <
class OutputValueType,
class Delim,
class String,
class OutputIterator>
void splitTo(
const Delim& delimiter,
const String& input,
OutputIterator out,
bool ignoreEmpty) {
detail::internalSplit<OutputValueType>(
detail::prepareDelim(delimiter), StringPiece(input), out, ignoreEmpty);
}
template <bool exact, class Delim, class... OutputTypes>
typename std::enable_if<
StrictConjunction<IsConvertible<OutputTypes>...>::value &&
sizeof...(OutputTypes) >= 1,
bool>::type
split(const Delim& delimiter, StringPiece input, OutputTypes&... outputs) {
return detail::splitFixed<exact>(
detail::prepareDelim(delimiter), input, outputs...);
}
namespace detail {
/*
* If a type can have its string size determined cheaply, we can more
* efficiently append it in a loop (see internalJoinAppend). Note that the
* struct need not conform to the std::string api completely (ex. does not need
* to implement append()).
*/
template <class T>
struct IsSizableString {
enum {
value = IsSomeString<T>::value || std::is_same<T, StringPiece>::value
};
};
template <class Iterator>
struct IsSizableStringContainerIterator
: IsSizableString<typename std::iterator_traits<Iterator>::value_type> {};
template <class Delim, class Iterator, class String>
void internalJoinAppend(
Delim delimiter,
Iterator begin,
Iterator end,
String& output) {
assert(begin != end);
if (std::is_same<Delim, StringPiece>::value && delimSize(delimiter) == 1) {
internalJoinAppend(delimFront(delimiter), begin, end, output);
return;
}
toAppend(*begin, &output);
while (++begin != end) {
toAppend(delimiter, *begin, &output);
}
}
template <class Delim, class Iterator, class String>
typename std::enable_if<IsSizableStringContainerIterator<Iterator>::value>::type
internalJoin(Delim delimiter, Iterator begin, Iterator end, String& output) {
output.clear();
if (begin == end) {
return;
}
const size_t dsize = delimSize(delimiter);
Iterator it = begin;
size_t size = it->size();
while (++it != end) {
size += dsize + it->size();
}
output.reserve(size);
internalJoinAppend(delimiter, begin, end, output);
}
template <class Delim, class Iterator, class String>
typename std::enable_if<
!IsSizableStringContainerIterator<Iterator>::value>::type
internalJoin(Delim delimiter, Iterator begin, Iterator end, String& output) {
output.clear();
if (begin == end) {
return;
}
internalJoinAppend(delimiter, begin, end, output);
}
} // namespace detail
template <class Delim, class Iterator, class String>
void join(
const Delim& delimiter,
Iterator begin,
Iterator end,
String& output) {
detail::internalJoin(detail::prepareDelim(delimiter), begin, end, output);
}
template <class OutputString>
void backslashify(
folly::StringPiece input,
OutputString& output,
bool hex_style) {
static const char hexValues[] = "0123456789abcdef";
output.clear();
output.reserve(3 * input.size());
for (unsigned char c : input) {
// less than space or greater than '~' are considered unprintable
if (c < 0x20 || c > 0x7e || c == '\\') {
bool hex_append = false;
output.push_back('\\');
if (hex_style) {
hex_append = true;
} else {
if (c == '\r') {
output += 'r';
} else if (c == '\n') {
output += 'n';
} else if (c == '\t') {
output += 't';
} else if (c == '\a') {
output += 'a';
} else if (c == '\b') {
output += 'b';
} else if (c == '\0') {
output += '0';
} else if (c == '\\') {
output += '\\';
} else {
hex_append = true;
}
}
if (hex_append) {
output.push_back('x');
output.push_back(hexValues[(c >> 4) & 0xf]);
output.push_back(hexValues[c & 0xf]);
}
} else {
output += c;
}
}
}
template <class String1, class String2>
void humanify(const String1& input, String2& output) {
size_t numUnprintable = 0;
size_t numPrintablePrefix = 0;
for (unsigned char c : input) {
if (c < 0x20 || c > 0x7e || c == '\\') {
++numUnprintable;
}
if (numUnprintable == 0) {
++numPrintablePrefix;
}
}
// hexlify doubles a string's size; backslashify can potentially
// explode it by 4x. Now, the printable range of the ascii
// "spectrum" is around 95 out of 256 values, so a "random" binary
// string should be around 60% unprintable. We use a 50% hueristic
// here, so if a string is 60% unprintable, then we just use hex
// output. Otherwise we backslash.
//
// UTF8 is completely ignored; as a result, utf8 characters will
// likely be \x escaped (since most common glyphs fit in two bytes).
// This is a tradeoff of complexity/speed instead of a convenience
// that likely would rarely matter. Moreover, this function is more
// about displaying underlying bytes, not about displaying glyphs
// from languages.
if (numUnprintable == 0) {
output = input;
} else if (5 * numUnprintable >= 3 * input.size()) {
// However! If we have a "meaningful" prefix of printable
// characters, say 20% of the string, we backslashify under the
// assumption viewing the prefix as ascii is worth blowing the
// output size up a bit.
if (5 * numPrintablePrefix >= input.size()) {
backslashify(input, output);
} else {
output = "0x";
hexlify(input, output, true /* append output */);
}
} else {
backslashify(input, output);
}
}
template <class InputString, class OutputString>
bool hexlify(
const InputString& input,
OutputString& output,
bool append_output) {
if (!append_output) {
output.clear();
}
static char hexValues[] = "0123456789abcdef";
auto j = output.size();
output.resize(2 * input.size() + output.size());
for (size_t i = 0; i < input.size(); ++i) {
int ch = input[i];
output[j++] = hexValues[(ch >> 4) & 0xf];
output[j++] = hexValues[ch & 0xf];
}
return true;
}
template <class InputString, class OutputString>
bool unhexlify(const InputString& input, OutputString& output) {
if (input.size() % 2 != 0) {
return false;
}
output.resize(input.size() / 2);
int j = 0;
for (size_t i = 0; i < input.size(); i += 2) {
int highBits = detail::hexTable[static_cast<uint8_t>(input[i])];
int lowBits = detail::hexTable[static_cast<uint8_t>(input[i + 1])];
if ((highBits | lowBits) & 0x10) {
// One of the characters wasn't a hex digit
return false;
}
output[j++] = (highBits << 4) + lowBits;
}
return true;
}
namespace detail {
/**
* Hex-dump at most 16 bytes starting at offset from a memory area of size
* bytes. Return the number of bytes actually dumped.
*/
size_t
hexDumpLine(const void* ptr, size_t offset, size_t size, std::string& line);
} // namespace detail
template <class OutIt>
void hexDump(const void* ptr, size_t size, OutIt out) {
size_t offset = 0;
std::string line;
while (offset < size) {
offset += detail::hexDumpLine(ptr, offset, size, line);
*out++ = line;
}
}
} // namespace folly
| [
"juxtin@github.com"
] | juxtin@github.com |
3fc5bbc3c91b0a74073619099ea1a9e0428c34e2 | d1a0d697798704d2a989b068574587cf6ca1ece9 | /chrome/browser/ui/webui/about_ui.cc | de595e5a36821bd4072eb8b21b76c6ca88684ae7 | [
"BSD-3-Clause"
] | permissive | lihui7115/ChromiumGStreamerBackend | 983199aa76e052d3e9ea21ff53d0dd4cf4c995dc | 6e41f524b780f2ff8d731f9986be743414a49a33 | refs/heads/master | 2021-01-17T10:26:00.070404 | 2015-08-05T16:39:35 | 2015-08-05T17:09:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 37,444 | cc | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/about_ui.h"
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/i18n/number_formatting.h"
#include "base/json/json_writer.h"
#include "base/memory/singleton.h"
#include "base/metrics/statistics_recorder.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread.h"
#include "base/values.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/memory/oom_priority_manager.h"
#include "chrome/browser/memory/tab_stats.h"
#include "chrome/browser/memory_details.h"
#include "chrome/browser/net/predictor.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/locale_settings.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_client.h"
#include "content/public/common/process_type.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "grit/browser_resources.h"
#include "net/base/escape.h"
#include "net/base/filename_util.h"
#include "net/base/load_flags.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_status.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/jstemplate_builder.h"
#include "ui/base/webui/web_ui_util.h"
#include "url/gurl.h"
#if defined(ENABLE_THEMES)
#include "chrome/browser/ui/webui/theme_source.h"
#endif
#if defined(OS_LINUX) || defined(OS_OPENBSD)
#include "content/public/browser/zygote_host_linux.h"
#include "content/public/common/sandbox_linux.h"
#endif
#if defined(OS_WIN)
#include "chrome/browser/enumerate_modules_model_win.h"
#endif
#if defined(OS_CHROMEOS)
#include "chrome/browser/browser_process_platform_part_chromeos.h"
#include "chrome/browser/chromeos/customization/customization_document.h"
#endif
using base::Time;
using base::TimeDelta;
using content::BrowserThread;
using content::WebContents;
namespace {
const char kCreditsJsPath[] = "credits.js";
const char kMemoryJsPath[] = "memory.js";
const char kMemoryCssPath[] = "about_memory.css";
const char kStatsJsPath[] = "stats.js";
const char kStringsJsPath[] = "strings.js";
// When you type about:memory, it actually loads this intermediate URL that
// redirects you to the final page. This avoids the problem where typing
// "about:memory" on the new tab page or any other page where a process
// transition would occur to the about URL will cause some confusion.
//
// The problem is that during the processing of the memory page, there are two
// processes active, the original and the destination one. This can create the
// impression that we're using more resources than we actually are. This
// redirect solves the problem by eliminating the process transition during the
// time that about memory is being computed.
std::string GetAboutMemoryRedirectResponse(Profile* profile) {
return base::StringPrintf("<meta http-equiv='refresh' content='0;%s'>",
chrome::kChromeUIMemoryRedirectURL);
}
// Handling about:memory is complicated enough to encapsulate its related
// methods into a single class. The user should create it (on the heap) and call
// its |StartFetch()| method.
class AboutMemoryHandler : public MemoryDetails {
public:
explicit AboutMemoryHandler(
const content::URLDataSource::GotDataCallback& callback)
: callback_(callback) {
}
void OnDetailsAvailable() override;
private:
~AboutMemoryHandler() override {}
void BindProcessMetrics(base::DictionaryValue* data,
ProcessMemoryInformation* info);
void AppendProcess(base::ListValue* child_data,
ProcessMemoryInformation* info);
content::URLDataSource::GotDataCallback callback_;
DISALLOW_COPY_AND_ASSIGN(AboutMemoryHandler);
};
#if defined(OS_CHROMEOS)
const char kKeyboardUtilsPath[] = "keyboard_utils.js";
// chrome://terms falls back to offline page after kOnlineTermsTimeoutSec.
const int kOnlineTermsTimeoutSec = 7;
// Helper class that fetches the online Chrome OS terms. Empty string is
// returned once fetching failed or exceeded |kOnlineTermsTimeoutSec|.
class ChromeOSOnlineTermsHandler : public net::URLFetcherDelegate {
public:
typedef base::Callback<void (ChromeOSOnlineTermsHandler*)> FetchCallback;
explicit ChromeOSOnlineTermsHandler(const FetchCallback& callback,
const std::string& locale)
: fetch_callback_(callback) {
std::string eula_URL = base::StringPrintf(chrome::kOnlineEulaURLPath,
locale.c_str());
eula_fetcher_ =
net::URLFetcher::Create(0 /* ID used for testing */, GURL(eula_URL),
net::URLFetcher::GET, this);
eula_fetcher_->SetRequestContext(
g_browser_process->system_request_context());
eula_fetcher_->AddExtraRequestHeader("Accept: text/html");
eula_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
net::LOAD_DO_NOT_SAVE_COOKIES |
net::LOAD_DISABLE_CACHE);
eula_fetcher_->Start();
// Abort the download attempt if it takes longer than one minute.
download_timer_.Start(FROM_HERE,
base::TimeDelta::FromSeconds(kOnlineTermsTimeoutSec),
this,
&ChromeOSOnlineTermsHandler::OnDownloadTimeout);
}
void GetResponseResult(std::string* response_string) {
std::string mime_type;
if (!eula_fetcher_ ||
!eula_fetcher_->GetStatus().is_success() ||
eula_fetcher_->GetResponseCode() != 200 ||
!eula_fetcher_->GetResponseHeaders()->GetMimeType(&mime_type) ||
mime_type != "text/html" ||
!eula_fetcher_->GetResponseAsString(response_string)) {
response_string->clear();
}
}
private:
// Prevents allocation on the stack. ChromeOSOnlineTermsHandler should be
// created by 'operator new'. |this| takes care of destruction.
~ChromeOSOnlineTermsHandler() override {}
// net::URLFetcherDelegate:
void OnURLFetchComplete(const net::URLFetcher* source) override {
if (source != eula_fetcher_.get()) {
NOTREACHED() << "Callback from foreign URL fetcher";
return;
}
fetch_callback_.Run(this);
delete this;
}
void OnDownloadTimeout() {
eula_fetcher_.reset();
fetch_callback_.Run(this);
delete this;
}
// Timer that enforces a timeout on the attempt to download the
// ChromeOS Terms.
base::OneShotTimer<ChromeOSOnlineTermsHandler> download_timer_;
// |fetch_callback_| called when fetching succeeded or failed.
FetchCallback fetch_callback_;
// Helper to fetch online eula.
scoped_ptr<net::URLFetcher> eula_fetcher_;
DISALLOW_COPY_AND_ASSIGN(ChromeOSOnlineTermsHandler);
};
class ChromeOSTermsHandler
: public base::RefCountedThreadSafe<ChromeOSTermsHandler> {
public:
static void Start(const std::string& path,
const content::URLDataSource::GotDataCallback& callback) {
scoped_refptr<ChromeOSTermsHandler> handler(
new ChromeOSTermsHandler(path, callback));
handler->StartOnUIThread();
}
private:
friend class base::RefCountedThreadSafe<ChromeOSTermsHandler>;
ChromeOSTermsHandler(const std::string& path,
const content::URLDataSource::GotDataCallback& callback)
: path_(path),
callback_(callback),
// Previously we were using "initial locale" http://crbug.com/145142
locale_(g_browser_process->GetApplicationLocale()) {
}
virtual ~ChromeOSTermsHandler() {}
void StartOnUIThread() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (path_ == chrome::kOemEulaURLPath) {
// Load local OEM EULA from the disk.
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(&ChromeOSTermsHandler::LoadOemEulaFileOnFileThread, this));
} else {
// Try to load online version of ChromeOS terms first.
// ChromeOSOnlineTermsHandler object destroys itself.
new ChromeOSOnlineTermsHandler(
base::Bind(&ChromeOSTermsHandler::OnOnlineEULAFetched, this),
locale_);
}
}
void OnOnlineEULAFetched(ChromeOSOnlineTermsHandler* loader) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
loader->GetResponseResult(&contents_);
if (contents_.empty()) {
// Load local ChromeOS terms from the file.
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(&ChromeOSTermsHandler::LoadEulaFileOnFileThread, this));
} else {
ResponseOnUIThread();
}
}
void LoadOemEulaFileOnFileThread() {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
const chromeos::StartupCustomizationDocument* customization =
chromeos::StartupCustomizationDocument::GetInstance();
if (customization->IsReady()) {
base::FilePath oem_eula_file_path;
if (net::FileURLToFilePath(GURL(customization->GetEULAPage(locale_)),
&oem_eula_file_path)) {
if (!base::ReadFileToString(oem_eula_file_path, &contents_)) {
contents_.clear();
}
}
}
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&ChromeOSTermsHandler::ResponseOnUIThread, this));
}
void LoadEulaFileOnFileThread() {
std::string file_path =
base::StringPrintf(chrome::kEULAPathFormat, locale_.c_str());
if (!base::ReadFileToString(base::FilePath(file_path), &contents_)) {
// No EULA for given language - try en-US as default.
file_path = base::StringPrintf(chrome::kEULAPathFormat, "en-US");
if (!base::ReadFileToString(base::FilePath(file_path), &contents_)) {
// File with EULA not found, ResponseOnUIThread will load EULA from
// resources if contents_ is empty.
contents_.clear();
}
}
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&ChromeOSTermsHandler::ResponseOnUIThread, this));
}
void ResponseOnUIThread() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// If we fail to load Chrome OS EULA from disk, load it from resources.
// Do nothing if OEM EULA load failed.
if (contents_.empty() && path_ != chrome::kOemEulaURLPath)
contents_ = l10n_util::GetStringUTF8(IDS_TERMS_HTML);
callback_.Run(base::RefCountedString::TakeString(&contents_));
}
// Path in the URL.
const std::string path_;
// Callback to run with the response.
content::URLDataSource::GotDataCallback callback_;
// Locale of the EULA.
const std::string locale_;
// EULA contents that was loaded from file.
std::string contents_;
DISALLOW_COPY_AND_ASSIGN(ChromeOSTermsHandler);
};
class ChromeOSCreditsHandler
: public base::RefCountedThreadSafe<ChromeOSCreditsHandler> {
public:
static void Start(const std::string& path,
const content::URLDataSource::GotDataCallback& callback) {
scoped_refptr<ChromeOSCreditsHandler> handler(
new ChromeOSCreditsHandler(path, callback));
handler->StartOnUIThread();
}
private:
friend class base::RefCountedThreadSafe<ChromeOSCreditsHandler>;
ChromeOSCreditsHandler(
const std::string& path,
const content::URLDataSource::GotDataCallback& callback)
: path_(path), callback_(callback) {}
virtual ~ChromeOSCreditsHandler() {}
void StartOnUIThread() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (path_ == kKeyboardUtilsPath) {
contents_ = ResourceBundle::GetSharedInstance()
.GetRawDataResource(IDR_KEYBOARD_UTILS_JS)
.as_string();
ResponseOnUIThread();
return;
}
// Load local Chrome OS credits from the disk.
BrowserThread::PostBlockingPoolTaskAndReply(
FROM_HERE,
base::Bind(&ChromeOSCreditsHandler::LoadCreditsFileOnBlockingPool,
this),
base::Bind(&ChromeOSCreditsHandler::ResponseOnUIThread, this));
}
void LoadCreditsFileOnBlockingPool() {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
base::FilePath credits_file_path(chrome::kChromeOSCreditsPath);
if (!base::ReadFileToString(credits_file_path, &contents_)) {
// File with credits not found, ResponseOnUIThread will load credits
// from resources if contents_ is empty.
contents_.clear();
}
}
void ResponseOnUIThread() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// If we fail to load Chrome OS credits from disk, load it from resources.
if (contents_.empty() && path_ != kKeyboardUtilsPath) {
contents_ = ResourceBundle::GetSharedInstance()
.GetRawDataResource(IDR_OS_CREDITS_HTML)
.as_string();
}
callback_.Run(base::RefCountedString::TakeString(&contents_));
}
// Path in the URL.
const std::string path_;
// Callback to run with the response.
content::URLDataSource::GotDataCallback callback_;
// Chrome OS credits contents that was loaded from file.
std::string contents_;
DISALLOW_COPY_AND_ASSIGN(ChromeOSCreditsHandler);
};
#endif
} // namespace
// Individual about handlers ---------------------------------------------------
namespace about_ui {
void AppendHeader(std::string* output, int refresh,
const std::string& unescaped_title) {
output->append("<!DOCTYPE HTML>\n<html>\n<head>\n");
if (!unescaped_title.empty()) {
output->append("<title>");
output->append(net::EscapeForHTML(unescaped_title));
output->append("</title>\n");
}
output->append("<meta charset='utf-8'>\n");
if (refresh > 0) {
output->append("<meta http-equiv='refresh' content='");
output->append(base::IntToString(refresh));
output->append("'/>\n");
}
}
void AppendBody(std::string *output) {
output->append("</head>\n<body>\n");
}
void AppendFooter(std::string *output) {
output->append("</body>\n</html>\n");
}
} // namespace about_ui
using about_ui::AppendHeader;
using about_ui::AppendBody;
using about_ui::AppendFooter;
namespace {
std::string ChromeURLs() {
std::string html;
AppendHeader(&html, 0, "Chrome URLs");
AppendBody(&html);
html += "<h2>List of Chrome URLs</h2>\n<ul>\n";
std::vector<std::string> hosts(
chrome::kChromeHostURLs,
chrome::kChromeHostURLs + chrome::kNumberOfChromeHostURLs);
std::sort(hosts.begin(), hosts.end());
for (std::vector<std::string>::const_iterator i = hosts.begin();
i != hosts.end(); ++i)
html += "<li><a href='chrome://" + *i + "/'>chrome://" + *i + "</a></li>\n";
html += "</ul>\n<h2>For Debug</h2>\n"
"<p>The following pages are for debugging purposes only. Because they "
"crash or hang the renderer, they're not linked directly; you can type "
"them into the address bar if you need them.</p>\n<ul>";
for (int i = 0; i < chrome::kNumberOfChromeDebugURLs; i++)
html += "<li>" + std::string(chrome::kChromeDebugURLs[i]) + "</li>\n";
html += "</ul>\n";
AppendFooter(&html);
return html;
}
#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
const char kAboutDiscardsRunCommand[] = "run";
// Html output helper functions
// Helper function to wrap HTML with a tag.
std::string WrapWithTag(const std::string& tag, const std::string& text) {
return "<" + tag + ">" + text + "</" + tag + ">";
}
#if defined(OS_CHROMEOS)
// Helper function to wrap Html with <td> tag.
std::string WrapWithTD(const std::string& text) {
return "<td>" + text + "</td>";
}
// Helper function to wrap Html with <tr> tag.
std::string WrapWithTR(const std::string& text) {
return "<tr>" + text + "</tr>";
}
std::string AddStringRow(const std::string& name, const std::string& value) {
std::string row;
row.append(WrapWithTD(name));
row.append(WrapWithTD(value));
return WrapWithTR(row);
}
#endif
void AddContentSecurityPolicy(std::string* output) {
output->append("<meta http-equiv='Content-Security-Policy' "
"content='default-src 'none';'>");
}
// TODO(stevenjb): L10N AboutDiscards.
std::string BuildAboutDiscardsRunPage() {
std::string output;
AppendHeader(&output, 0, "About discards");
output.append(base::StringPrintf("<meta http-equiv='refresh' content='2;%s'>",
chrome::kChromeUIDiscardsURL));
AddContentSecurityPolicy(&output);
output.append(WrapWithTag("p", "Discarding a tab..."));
AppendFooter(&output);
return output;
}
std::vector<std::string> GetHtmlTabDescriptorsForDiscardPage() {
memory::OomPriorityManager* oom = g_browser_process->GetOomPriorityManager();
memory::TabStatsList stats = oom->GetTabStats();
std::vector<std::string> titles;
titles.reserve(stats.size());
for (memory::TabStatsList::iterator it = stats.begin(); it != stats.end();
++it) {
std::string str;
str.reserve(4096);
str += "<b>";
str += it->is_app ? "[App] " : "";
str += it->is_internal_page ? "[Internal] " : "";
str += it->is_playing_audio ? "[Audio] " : "";
str += it->is_pinned ? "[Pinned] " : "";
str += it->is_discarded ? "[Discarded] " : "";
str += "</b>";
str += net::EscapeForHTML(base::UTF16ToUTF8(it->title));
#if defined(OS_CHROMEOS)
str += base::StringPrintf(" (%d) ", it->oom_score);
#endif
if (!it->is_discarded) {
str += base::StringPrintf(" <a href='%s%s/%" PRId64 "'>Discard</a>",
chrome::kChromeUIDiscardsURL,
kAboutDiscardsRunCommand, it->tab_contents_id);
}
titles.push_back(str);
}
return titles;
}
std::string AboutDiscards(const std::string& path) {
std::string output;
std::vector<std::string> path_split;
int64 web_content_id;
memory::OomPriorityManager* oom = g_browser_process->GetOomPriorityManager();
base::SplitString(path, '/', &path_split);
if (path_split.size() == 2 && path_split[0] == kAboutDiscardsRunCommand &&
base::StringToInt64(path_split[1], &web_content_id)) {
oom->DiscardTabById(web_content_id);
return BuildAboutDiscardsRunPage();
} else if (path_split.size() == 1 &&
path_split[0] == kAboutDiscardsRunCommand) {
oom->DiscardTab();
return BuildAboutDiscardsRunPage();
}
AppendHeader(&output, 0, "About discards");
AddContentSecurityPolicy(&output);
AppendBody(&output);
output.append("<h3>Discarded Tabs</h3>");
output.append(
"<p>Tabs sorted from most interesting to least interesting. The least "
"interesting tab may be discarded if we run out of physical memory.</p>");
std::vector<std::string> titles = GetHtmlTabDescriptorsForDiscardPage();
if (!titles.empty()) {
output.append("<ul>");
std::vector<std::string>::iterator it = titles.begin();
for ( ; it != titles.end(); ++it) {
output.append(WrapWithTag("li", *it));
}
output.append("</ul>");
} else {
output.append("<p>None found. Wait 10 seconds, then refresh.</p>");
}
output.append(
base::StringPrintf("%d discards this session. ", oom->discard_count()));
output.append(base::StringPrintf("<a href='%s%s'>Discard tab now</a>",
chrome::kChromeUIDiscardsURL,
kAboutDiscardsRunCommand));
#if defined(OS_CHROMEOS)
base::SystemMemoryInfoKB meminfo;
base::GetSystemMemoryInfo(&meminfo);
output.append("<h3>System memory information in MB</h3>");
output.append("<table>");
// Start with summary statistics.
output.append(AddStringRow(
"Total", base::IntToString(meminfo.total / 1024)));
output.append(AddStringRow(
"Free", base::IntToString(meminfo.free / 1024)));
int mem_allocated_kb = meminfo.active_anon + meminfo.inactive_anon;
#if defined(ARCH_CPU_ARM_FAMILY)
// ARM counts allocated graphics memory separately from anonymous.
if (meminfo.gem_size != -1)
mem_allocated_kb += meminfo.gem_size / 1024;
#endif
output.append(AddStringRow(
"Allocated", base::IntToString(mem_allocated_kb / 1024)));
// Add some space, then detailed numbers.
output.append(AddStringRow(" ", " "));
output.append(AddStringRow(
"Buffered", base::IntToString(meminfo.buffers / 1024)));
output.append(AddStringRow(
"Cached", base::IntToString(meminfo.cached / 1024)));
output.append(AddStringRow(
"Active Anon", base::IntToString(meminfo.active_anon / 1024)));
output.append(AddStringRow(
"Inactive Anon", base::IntToString(meminfo.inactive_anon / 1024)));
output.append(AddStringRow(
"Shared", base::IntToString(meminfo.shmem / 1024)));
output.append(AddStringRow(
"Graphics", base::IntToString(meminfo.gem_size / 1024 / 1024)));
output.append("</table>");
#endif // OS_CHROMEOS
AppendFooter(&output);
return output;
}
#endif // OS_WIN || OS_CHROMEOS
// AboutDnsHandler bounces the request back to the IO thread to collect
// the DNS information.
class AboutDnsHandler : public base::RefCountedThreadSafe<AboutDnsHandler> {
public:
static void Start(Profile* profile,
const content::URLDataSource::GotDataCallback& callback) {
scoped_refptr<AboutDnsHandler> handler(
new AboutDnsHandler(profile, callback));
handler->StartOnUIThread();
}
private:
friend class base::RefCountedThreadSafe<AboutDnsHandler>;
AboutDnsHandler(Profile* profile,
const content::URLDataSource::GotDataCallback& callback)
: profile_(profile),
callback_(callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
virtual ~AboutDnsHandler() {}
// Calls FinishOnUIThread() on completion.
void StartOnUIThread() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
chrome_browser_net::Predictor* predictor = profile_->GetNetworkPredictor();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&AboutDnsHandler::StartOnIOThread, this, predictor));
}
void StartOnIOThread(chrome_browser_net::Predictor* predictor) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
std::string data;
AppendHeader(&data, 0, "About DNS");
AppendBody(&data);
chrome_browser_net::Predictor::PredictorGetHtmlInfo(predictor, &data);
AppendFooter(&data);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&AboutDnsHandler::FinishOnUIThread, this, data));
}
void FinishOnUIThread(const std::string& data) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::string data_copy(data);
callback_.Run(base::RefCountedString::TakeString(&data_copy));
}
Profile* profile_;
// Callback to run with the response.
content::URLDataSource::GotDataCallback callback_;
DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler);
};
void FinishMemoryDataRequest(
const std::string& path,
const content::URLDataSource::GotDataCallback& callback) {
if (path == kStringsJsPath) {
// The AboutMemoryHandler cleans itself up, but |StartFetch()| will want
// the refcount to be greater than 0.
scoped_refptr<AboutMemoryHandler> handler(new AboutMemoryHandler(callback));
handler->StartFetch(MemoryDetails::FROM_ALL_BROWSERS);
} else {
int id = IDR_ABOUT_MEMORY_HTML;
if (path == kMemoryJsPath) {
id = IDR_ABOUT_MEMORY_JS;
} else if (path == kMemoryCssPath) {
id = IDR_ABOUT_MEMORY_CSS;
}
std::string result =
ResourceBundle::GetSharedInstance().GetRawDataResource(id).as_string();
callback.Run(base::RefCountedString::TakeString(&result));
}
}
#if defined(OS_LINUX) || defined(OS_OPENBSD)
std::string AboutLinuxProxyConfig() {
std::string data;
AppendHeader(&data, 0,
l10n_util::GetStringUTF8(IDS_ABOUT_LINUX_PROXY_CONFIG_TITLE));
data.append("<style>body { max-width: 70ex; padding: 2ex 5ex; }</style>");
AppendBody(&data);
base::FilePath binary = base::CommandLine::ForCurrentProcess()->GetProgram();
data.append(l10n_util::GetStringFUTF8(
IDS_ABOUT_LINUX_PROXY_CONFIG_BODY,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
base::ASCIIToUTF16(binary.BaseName().value())));
AppendFooter(&data);
return data;
}
void AboutSandboxRow(std::string* data, int name_id, bool good) {
data->append("<tr><td>");
data->append(l10n_util::GetStringUTF8(name_id));
if (good) {
data->append("</td><td style='color: green;'>");
data->append(
l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL));
} else {
data->append("</td><td style='color: red;'>");
data->append(
l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL));
}
data->append("</td></tr>");
}
std::string AboutSandbox() {
std::string data;
AppendHeader(&data, 0, l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_TITLE));
AppendBody(&data);
data.append("<h1>");
data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_TITLE));
data.append("</h1>");
// Get expected sandboxing status of renderers.
const int status = content::ZygoteHost::GetInstance()->GetSandboxStatus();
data.append("<table>");
AboutSandboxRow(&data, IDS_ABOUT_SANDBOX_SUID_SANDBOX,
status & content::kSandboxLinuxSUID);
AboutSandboxRow(&data, IDS_ABOUT_SANDBOX_NAMESPACE_SANDBOX,
status & content::kSandboxLinuxUserNS);
AboutSandboxRow(&data, IDS_ABOUT_SANDBOX_PID_NAMESPACES,
status & content::kSandboxLinuxPIDNS);
AboutSandboxRow(&data, IDS_ABOUT_SANDBOX_NET_NAMESPACES,
status & content::kSandboxLinuxNetNS);
AboutSandboxRow(&data, IDS_ABOUT_SANDBOX_SECCOMP_BPF_SANDBOX,
status & content::kSandboxLinuxSeccompBPF);
AboutSandboxRow(&data, IDS_ABOUT_SANDBOX_SECCOMP_BPF_SANDBOX_TSYNC,
status & content::kSandboxLinuxSeccompTSYNC);
AboutSandboxRow(&data, IDS_ABOUT_SANDBOX_YAMA_LSM,
status & content::kSandboxLinuxYama);
data.append("</table>");
// Require either the setuid or namespace sandbox for our first-layer sandbox.
bool good_layer1 = (status & content::kSandboxLinuxSUID ||
status & content::kSandboxLinuxUserNS) &&
status & content::kSandboxLinuxPIDNS &&
status & content::kSandboxLinuxNetNS;
// A second-layer sandbox is also required to be adequately sandboxed.
bool good_layer2 = status & content::kSandboxLinuxSeccompBPF;
bool good = good_layer1 && good_layer2;
if (good) {
data.append("<p style='color: green'>");
data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_OK));
} else {
data.append("<p style='color: red'>");
data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_BAD));
}
data.append("</p>");
AppendFooter(&data);
return data;
}
#endif
// AboutMemoryHandler ----------------------------------------------------------
// Helper for AboutMemory to bind results from a ProcessMetrics object
// to a DictionaryValue. Fills ws_usage and comm_usage so that the objects
// can be used in caller's scope (e.g for appending to a net total).
void AboutMemoryHandler::BindProcessMetrics(base::DictionaryValue* data,
ProcessMemoryInformation* info) {
DCHECK(data && info);
// Bind metrics to dictionary.
data->SetInteger("ws_priv", static_cast<int>(info->working_set.priv));
data->SetInteger("ws_shareable",
static_cast<int>(info->working_set.shareable));
data->SetInteger("ws_shared", static_cast<int>(info->working_set.shared));
data->SetInteger("comm_priv", static_cast<int>(info->committed.priv));
data->SetInteger("comm_map", static_cast<int>(info->committed.mapped));
data->SetInteger("comm_image", static_cast<int>(info->committed.image));
data->SetInteger("pid", info->pid);
data->SetString("version", info->version);
data->SetInteger("processes", info->num_processes);
}
// Helper for AboutMemory to append memory usage information for all
// sub-processes (i.e. renderers, plugins) used by Chrome.
void AboutMemoryHandler::AppendProcess(base::ListValue* child_data,
ProcessMemoryInformation* info) {
DCHECK(child_data && info);
// Append a new DictionaryValue for this renderer to our list.
base::DictionaryValue* child = new base::DictionaryValue();
child_data->Append(child);
BindProcessMetrics(child, info);
std::string child_label(
ProcessMemoryInformation::GetFullTypeNameInEnglish(info->process_type,
info->renderer_type));
if (info->is_diagnostics)
child_label.append(" (diagnostics)");
child->SetString("child_name", child_label);
base::ListValue* titles = new base::ListValue();
child->Set("titles", titles);
for (size_t i = 0; i < info->titles.size(); ++i)
titles->Append(new base::StringValue(info->titles[i]));
}
void AboutMemoryHandler::OnDetailsAvailable() {
// the root of the JSON hierarchy for about:memory jstemplate
scoped_ptr<base::DictionaryValue> root(new base::DictionaryValue);
base::ListValue* browsers = new base::ListValue();
root->Set("browsers", browsers);
const std::vector<ProcessData>& browser_processes = processes();
// Aggregate per-process data into browser summary data.
base::string16 log_string;
for (size_t index = 0; index < browser_processes.size(); index++) {
if (browser_processes[index].processes.empty())
continue;
// Sum the information for the processes within this browser.
ProcessMemoryInformation aggregate;
ProcessMemoryInformationList::const_iterator iterator;
iterator = browser_processes[index].processes.begin();
aggregate.pid = iterator->pid;
aggregate.version = iterator->version;
while (iterator != browser_processes[index].processes.end()) {
if (!iterator->is_diagnostics ||
browser_processes[index].processes.size() == 1) {
aggregate.working_set.priv += iterator->working_set.priv;
aggregate.working_set.shared += iterator->working_set.shared;
aggregate.working_set.shareable += iterator->working_set.shareable;
aggregate.committed.priv += iterator->committed.priv;
aggregate.committed.mapped += iterator->committed.mapped;
aggregate.committed.image += iterator->committed.image;
aggregate.num_processes++;
}
++iterator;
}
base::DictionaryValue* browser_data = new base::DictionaryValue();
browsers->Append(browser_data);
browser_data->SetString("name", browser_processes[index].name);
BindProcessMetrics(browser_data, &aggregate);
// We log memory info as we record it.
if (!log_string.empty())
log_string += base::ASCIIToUTF16(", ");
log_string += browser_processes[index].name + base::ASCIIToUTF16(", ") +
base::Int64ToString16(aggregate.working_set.priv) +
base::ASCIIToUTF16(", ") +
base::Int64ToString16(aggregate.working_set.shared) +
base::ASCIIToUTF16(", ") +
base::Int64ToString16(aggregate.working_set.shareable);
}
if (!log_string.empty())
VLOG(1) << "memory: " << log_string;
// Set the browser & renderer detailed process data.
base::DictionaryValue* browser_data = new base::DictionaryValue();
root->Set("browzr_data", browser_data);
base::ListValue* child_data = new base::ListValue();
root->Set("child_data", child_data);
ProcessData process = browser_processes[0]; // Chrome is the first browser.
root->SetString("current_browser_name", process.name);
for (size_t index = 0; index < process.processes.size(); index++) {
if (process.processes[index].process_type == content::PROCESS_TYPE_BROWSER)
BindProcessMetrics(browser_data, &process.processes[index]);
else
AppendProcess(child_data, &process.processes[index]);
}
root->SetBoolean("show_other_browsers",
browser_defaults::kShowOtherBrowsersInAboutMemory);
base::DictionaryValue load_time_data;
load_time_data.SetString(
"summary_desc",
l10n_util::GetStringUTF16(IDS_MEMORY_USAGE_SUMMARY_DESC));
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, &load_time_data);
load_time_data.Set("jstemplateData", root.release());
std::string data;
webui::AppendJsonJS(&load_time_data, &data);
callback_.Run(base::RefCountedString::TakeString(&data));
}
} // namespace
// AboutUIHTMLSource ----------------------------------------------------------
AboutUIHTMLSource::AboutUIHTMLSource(const std::string& source_name,
Profile* profile)
: source_name_(source_name),
profile_(profile) {}
AboutUIHTMLSource::~AboutUIHTMLSource() {}
std::string AboutUIHTMLSource::GetSource() const {
return source_name_;
}
void AboutUIHTMLSource::StartDataRequest(
const std::string& path,
int render_process_id,
int render_frame_id,
const content::URLDataSource::GotDataCallback& callback) {
std::string response;
// Add your data source here, in alphabetical order.
if (source_name_ == chrome::kChromeUIChromeURLsHost) {
response = ChromeURLs();
} else if (source_name_ == chrome::kChromeUICreditsHost) {
int idr = IDR_CREDITS_HTML;
if (path == kCreditsJsPath)
idr = IDR_CREDITS_JS;
#if defined(OS_CHROMEOS)
else if (path == kKeyboardUtilsPath)
idr = IDR_KEYBOARD_UTILS_JS;
#endif
response = ResourceBundle::GetSharedInstance().GetRawDataResource(
idr).as_string();
#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
} else if (source_name_ == chrome::kChromeUIDiscardsHost) {
response = AboutDiscards(path);
#endif
} else if (source_name_ == chrome::kChromeUIDNSHost) {
AboutDnsHandler::Start(profile(), callback);
return;
#if defined(OS_LINUX) || defined(OS_OPENBSD)
} else if (source_name_ == chrome::kChromeUILinuxProxyConfigHost) {
response = AboutLinuxProxyConfig();
#endif
} else if (source_name_ == chrome::kChromeUIMemoryHost) {
response = GetAboutMemoryRedirectResponse(profile());
} else if (source_name_ == chrome::kChromeUIMemoryRedirectHost) {
FinishMemoryDataRequest(path, callback);
return;
#if defined(OS_CHROMEOS)
} else if (source_name_ == chrome::kChromeUIOSCreditsHost) {
ChromeOSCreditsHandler::Start(path, callback);
return;
#endif
#if defined(OS_LINUX) || defined(OS_OPENBSD)
} else if (source_name_ == chrome::kChromeUISandboxHost) {
response = AboutSandbox();
#endif
#if !defined(OS_ANDROID)
} else if (source_name_ == chrome::kChromeUITermsHost) {
#if defined(OS_CHROMEOS)
ChromeOSTermsHandler::Start(path, callback);
return;
#else
response = l10n_util::GetStringUTF8(IDS_TERMS_HTML);
#endif
#endif
}
FinishDataRequest(response, callback);
}
void AboutUIHTMLSource::FinishDataRequest(
const std::string& html,
const content::URLDataSource::GotDataCallback& callback) {
std::string html_copy(html);
callback.Run(base::RefCountedString::TakeString(&html_copy));
}
std::string AboutUIHTMLSource::GetMimeType(const std::string& path) const {
if (path == kCreditsJsPath ||
#if defined(OS_CHROMEOS)
path == kKeyboardUtilsPath ||
#endif
path == kStatsJsPath ||
path == kStringsJsPath ||
path == kMemoryJsPath) {
return "application/javascript";
}
return "text/html";
}
bool AboutUIHTMLSource::ShouldAddContentSecurityPolicy() const {
#if defined(OS_CHROMEOS)
if (source_name_ == chrome::kChromeUIOSCreditsHost)
return false;
#endif
return content::URLDataSource::ShouldAddContentSecurityPolicy();
}
bool AboutUIHTMLSource::ShouldDenyXFrameOptions() const {
#if defined(OS_CHROMEOS)
if (source_name_ == chrome::kChromeUITermsHost) {
// chrome://terms page is embedded in iframe to chrome://oobe.
return false;
}
#endif
return content::URLDataSource::ShouldDenyXFrameOptions();
}
AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name)
: WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
#if defined(ENABLE_THEMES)
// Set up the chrome://theme/ source.
ThemeSource* theme = new ThemeSource(profile);
content::URLDataSource::Add(profile, theme);
#endif
content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile));
}
| [
"j.isorce@samsung.com"
] | j.isorce@samsung.com |
d04dbd8777cd5572f3a2fc3663191cf7359aa69e | 970fa23d79728eabef19b0348e260dc7f4d0e466 | /P4/catalogo_check.cpp | 86d5da21773e1e38ab11218a49b8fd7630c536f0 | [] | no_license | miguelcram/POO | 553c7efd640419ecb0f652de19a69c0b1176a452 | 1ce5b02c6969fca75c9b67ec3e6c2cc2cef58a7e | refs/heads/master | 2022-09-26T07:46:42.581729 | 2020-06-06T15:52:36 | 2020-06-06T15:52:36 | 263,119,830 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,118 | cpp | /*
* catalogo_check.cpp - Comprobación estática de código fuente para P4
* ©2020 POO - Pedro, Inma, Fidel, Gerardo
*/
#include "caclibrary.h"
#include <vector>
#include <iostream>
using namespace std;
int main(int argc, const char **argv)
{
checkCode c1(argc, argv, "articulo.cpp", "Modo de empleo: ./catalogo_check"
" articulo.cpp tarjeta.cpp usuario.cpp pedido.cpp"
" pedido-articulo.cpp usuario-pedido.cpp -- -std=c++14"
" -I../P1");
c1.setCorrectMessage("Verificación correcta de la clase Artículo.");
c1.setIncorrectMessage("REVISA LA CLASE Articulo.");
vector<string> functionNames = {"strlen", "strcat", "memset",
"strcpy", "strcmp"};
string headerName = "cstring";
if(c1.findClass({"Articulo", "ArticuloAlmacenable", "Autor",
"Libro","Cederron","LibroDigital"})) {
llvm::outs() << "* articulo.cpp:\n";
c1.allPrivateVariableMember("Articulo",
"Revisa el acceso a los atributos.");
c1.notFriendMember("Articulo",
"Revisa si es necesario incluir 'friend'.");
c1.guardClauses("articulo.hpp",
"Recuerda añadir las guardas de inclusión.");
c1.memberVariable("Articulo", {"stock_"}, {"?"}, {false},
"Revisa el enunciado respecto a los atributos"
" que deben estar en cada clase.");
c1.memberVariable("ArticuloAlmacenable", {"stock_"}, {"noconst"},
{true}, "Revisa el enunciado respecto a los atributos"
" que deben estar en cada clase.");
c1.virtualMethod({"~Articulo"},{{}},"Articulo",{"noconst"},
"Contempla crear un destructor apropiado para esta clase."
);
c1.functionWithReferencedMethod({"operator<<"},{{
"class std::basic_ostream<char> &","const class Articulo &"}},
{"impresion_especifica"},{{"class std::basic_ostream<char> &"}},
"Articulo",{"const"},
"Incluya impresion_especifica en el operador de inserción");
c1.methodWithReferencedMemberVariable({"impresion_especifica"}, {{
"class std::basic_ostream<char> &"}}, "Libro", {"const"},
{"n_pag_"}, "Revisa qué debe imprimir la definición"
" del método impresion_especifica en cada clase.");
c1.methodWithReferencedMemberVariable({"impresion_especifica"}, {{
"class std::basic_ostream<char> &"}}, "Libro", {"const"},
{"stock_"},"Revisa qué debe imprimir la definición"
" del método impresion_especifica en cada clase.");
c1.methodWithReferencedMemberVariable({"impresion_especifica"}, {{
"class std::basic_ostream<char> &"}}, "Cederron", {"const"},
{"tam_"},"Revisa qué debe imprimir la definición"
" del método impresion_especifica en cada clase.");
c1.methodWithReferencedMemberVariable({"impresion_especifica"}, {{
"class std::basic_ostream<char> &"}}, "Cederron", {"const"},
{"stock_"},"Revisa qué debe imprimir la definición"
" del método impresion_especifica en cada clase.");
c1.methodWithReferencedMemberVariable({"impresion_especifica"}, {{
"class std::basic_ostream<char> &"}}, "LibroDigital", {"const"},
{"f_expir_"},"Revisa qué debe imprimir la definición"
" del método impresion_especifica en cada clase.");
c1.method({"nombre","apellidos","direccion"}, {{},{},{}}, "Autor",
{"const","const","const"},
"Revisa el uso de métodos constantes.");
c1.noExceptMethod({"nombre","apellidos","direccion"},{{},{},{}},
"Autor", {"const","const","const"},
"Revisa el enunciado respecto a las excepciones.");
c1.check();
}
else
llvm::outs() << "No se han encontrado las clases 'Articulo',"
" 'ArticuloAlmacenable', 'Autor', 'Libro', "
"'Cederron' o 'LibroDigital'\n";
checkCode c2(argc, argv, "tarjeta.cpp", "");
c2.setCorrectMessage("Verificación correcta de la clase Tarjeta.");
c2.setIncorrectMessage("REVISA LA CLASE Tarjeta.");
if(c2.findClass({"Tarjeta"})) {
llvm::outs() << "* tarjeta.cpp:\n";
c2.invocationsFromHeaders(functionNames, headerName, true,
"Revisa de dónde son tomadas las funciones de"
" la biblioteca estándar de C, como strcmp...");
c2.allPrivateVariableMember("Tarjeta", "Revisa el acceso a los atributos.");
//Constructor de copia y operador de asignación
c2.deletedMethod({"Tarjeta", "operator="}, {{
"const class Tarjeta &"}, {"const class Tarjeta &"}}, "Tarjeta",
{"noconst", "noconst"},
"Revisa el enunciado respecto a la copia de objetos.");
c2.guardClauses("tarjeta.hpp", "Recuerda añadir las guardas de inclusión.");
vector<string> methodNames = {"numero", "caducidad", "activa"};
vector<vector<string>> parametersMethods = {{},{},{}};
c2.inlineMethod(methodNames, parametersMethods, "Tarjeta",
{ "const", "const", "const" },
"Sugerencia: incluir marca 'inline' a aquellos métodos"
" con pocas instrucciones, como 'numero()', 'caducidad()'"
" o 'activa()'.");
c2.check();
}
else
llvm::outs() << "No se ha encontrado la clase 'Tarjeta'"<<"\n";
checkCode c3(argc, argv,"usuario.cpp", "");
c3.setCorrectMessage("Verificación correcta de la clase Usuario.");
c3.setIncorrectMessage("REVISA LA CLASE Usuario.");
if(c3.findClass({"Usuario"})) {
llvm::outs() << "* usuario.cpp:\n";
c3.invocationsFromHeaders(functionNames, headerName, true,
"Revisa de dónde son tomadas las funciones"
" de la biblioteca estándar de C, como strlen, strcmp...");
c3.allPrivateVariableMember("Usuario", "Revisa el acceso a los atributos.");
//Constructor de copia y operador de asignación
c3.deletedMethod({"Usuario", "operator="},
{{"const class Usuario &"}, {"const class Usuario &"}},
"Usuario", {"noconst", "noconst"},
"Revisa el enunciado respecto a la copia de objetos.");
c3.numberOfConstructors("Usuario", 1, false,
"Revisa el enunciado respecto a los constructores en esta clase.");
c3.friendFunction({"operator<<"}, {{"?"}}, "Usuario",
"Revisa si existen funciones que deben ser marcadas"
" como amigas de la clase.");
vector<string> methodNames = {"id", "nombre", "apellidos"};
vector<vector<string>> parametersMethods = {{},{},{}};
c3.inlineMethod(methodNames, parametersMethods, "Usuario",
{"const", "const", "const"},
"Sugerencia: incluir marca 'inline'"
" a aquellos métodos con pocas instrucciones, como"
" 'id()', 'nombre()' o 'apellidos()'.");
c3.guardClauses("usuario.hpp", "Recuerda añadir las guardas de inclusión.");
c3.check();
}
else
llvm::outs()<<"No se ha encontrado la clase 'Usuario'"<<"\n";
checkCode c4(argc, argv,"pedido.cpp", "");
c4.setCorrectMessage("Verificación correcta de la clase Pedido.");
c4.setIncorrectMessage("REVISA LA CLASE Pedido.");
if(c4.findClass({"Pedido"})) {
llvm::outs() << "* pedido.cpp:\n";
c4.allPrivateVariableMember("Pedido", "Revisa el acceso a los atributos.");
c4.numberOfConstructors("Pedido", 1, false,
"Revisa el enunciado respecto al n.º de constructores de Pedido");
c4.defaultArgumentsInMethod({"Pedido"}, {{"?"}}, "Pedido",
{"?"}, {1}, {{"Fecha()"}},
"Revisa el enunciado respecto a la construcción de un Pedido.");
/* Ponemos "?" como lista de parámetros porque solo debe haber un
constructor. La regla funcionará cualquiera que sea el orden en
el que se pongan los inicializadores en el constructor.
*/
c4.listInitializerConstructor("Pedido", {"?"}, {"int",
"const class Tarjeta *", "class Fecha", "double"},
"Revisa la lista de inicialización del constructor.");
c4.function({"operator<<"},
{{"class std::basic_ostream<char> &", "const class Pedido &"}},
"Revisa el enunciado respecto al operador de inserción.");
c4.memberVariable("Pedido", {"tarjeta_"}, {"const"}, {true},
"Revisa el enunciado respecto al atributo de la tarjeta."
);
c4.guardClauses("pedido.hpp", "Recuerda añadir las guardas de inclusión");
c4.methodWithDynamicCast("Pedido", {}, "Pedido", "noconst",
"class Articulo *", "class ArticuloAlmacenable *",
"Es necesario que emplees el operador de molde "
"apropiado en el constructor de la clase.\n");
c4.methodWithDynamicCast("Pedido", {}, "Pedido", "noconst",
"class Articulo *", "class LibroDigital *",
"Es necesario que emplees el operador de molde "
"apropiado en el constructor de la clase.\n");
c4.check();
}
else
llvm::outs() << "No se ha encontrado la clase 'Pedido'.\n";
checkCode c5(argc, argv,"pedido-articulo.cpp", "");
c5.setCorrectMessage("Verificación correcta de la clase Pedido_Articulo.");
c5.setIncorrectMessage("REVISA LA CLASE Pedido_Articulo.");
if(c5.findClass({"Pedido_Articulo", "LineaPedido"})) {
llvm::outs() << "* pedido-articulo.cpp:\n";
c5.numberOfConstructors("Pedido_Articulo", 0, false,
"Revisa la necesidad de definir constructores"
" de Pedido_Articulo.");
c5.numberOfConstructors("LineaPedido", 1, false,
"Revisa el enunciado respecto al n.º de "
"constructores de LineaPedido.");
vector<string> params = { "double", "unsigned int" };
vector<vector<string>> methodsParams = { params };
c5.defaultArgumentsInMethod({"LineaPedido"}, methodsParams,
"LineaPedido", {"?"}, {1}, {{"1"}},
"Revisa el enunciado respecto al "
"constructor de LineaPedido.");
c5.explicitSpecifiedConstructor("LineaPedido", params,
"Revisa el enunciado respecto a conversiones implícitas.");
c5.function({"operator<<"}, {{"class std::basic_ostream<char> &",
"const class LineaPedido &"}},
"Revisa el lugar de la declaración de los operadores.");
/* 'pedir' sobrecargado puede hacerse mediante la búsqueda de
dos métodos con diferentes parametros.
*/
c5.method({"pedir","pedir"},{{"class Pedido &",
"class Articulo &", "double", "unsigned int"},
{"class Articulo &", "class Pedido &", "double",
"unsigned int"}}, "Pedido_Articulo", {"noconst","noconst"},
"Se sugiere la sobrecarga del método 'pedir'.");
c5.guardClauses("pedido-articulo.hpp",
"Recuerda añadir las guardas de inclusión");
c5.check();
}
else
llvm::outs() << "No se ha encontrado la clase 'Pedido_Articulo'.\n";
checkCode c6(argc, argv,"usuario-pedido.cpp", "");
c6.setCorrectMessage("Verificación correcta de la clase Usuario_Pedido.");
c6.setIncorrectMessage("REVISA LA CLASE Usuario_Pedido.");
if(c6.findClass({"Usuario_Pedido"})) {
llvm::outs() << "* usuario-pedido.cpp:\n";
c6.allPrivateVariableMember("Usuario_Pedido",
"Revisa el acceso a los atributos.");
c6.guardClauses("usuario-pedido.hpp",
"Recuerda añadir las guardas de inclusión");
c6.notFriendMember("Usuario_Pedido",
"Revisa si es necesario incluir friend.");
c6.check();
}
else
llvm::outs() << "No se ha encontrado la clase 'Usuario_Pedido'.\n";
}
| [
"miguel.cabralramirez@alum.uca.es"
] | miguel.cabralramirez@alum.uca.es |
e7ece8e681cc280989b0ada27730da5492bbc090 | 761915f4aa660f6dc8b77a313ce1c789b3d722c0 | /orb_blend/LapBlend/LapBlend.cpp | 13520e9118acb847f2aca1ff050780a94983e19e | [] | no_license | hunandy14/orb_blend | 10824171568468bf957b2d0fa86f0ea73c8dfcab | 224a9a69bd49b99fb3ef3a3a2b1a764ea3e29149 | refs/heads/master | 2020-03-21T05:57:53.756843 | 2018-06-29T09:35:56 | 2018-06-29T09:35:56 | 138,190,902 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,659 | cpp | /*****************************************************************
Name :
Date : 2018/04/12
By : CharlotteHonG
Final: 2018/04/12
*****************************************************************/
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <timer.hpp>
using namespace std;
#include "LapBlend.hpp"
//==================================================================================
// 圖片放大縮小
//==================================================================================
// 快速線性插值
inline static void fast_Bilinear_rgb(unsigned char* p,
const basic_ImgData& src, double y, double x)
{
// 起點
int _x = (int)x;
int _y = (int)y;
// 左邊比值
double l_x = x - (double)_x;
double r_x = 1.f - l_x;
double t_y = y - (double)_y;
double b_y = 1.f - t_y;
int srcW = src.width;
int srcH = src.height;
// 計算RGB
double R , G, B;
int x2 = (_x+1) > src.width -1? src.width -1: _x+1;
int y2 = (_y+1) > src.height-1? src.height-1: _y+1;
R = (double)src.raw_img[(_y*srcW + _x)*3 + 0]*(r_x * b_y);
G = (double)src.raw_img[(_y*srcW + _x)*3 + 1]*(r_x * b_y);
B = (double)src.raw_img[(_y*srcW + _x)*3 + 2]*(r_x * b_y);
R += (double)src.raw_img[(_y*srcW + x2)*3 + 0]*(l_x * b_y);
G += (double)src.raw_img[(_y*srcW + x2)*3 + 1]*(l_x * b_y);
B += (double)src.raw_img[(_y*srcW + x2)*3 + 2]*(l_x * b_y);
R += (double)src.raw_img[(y2*srcW + _x)*3 + 0]*(r_x * t_y);
G += (double)src.raw_img[(y2*srcW + _x)*3 + 1]*(r_x * t_y);
B += (double)src.raw_img[(y2*srcW + _x)*3 + 2]*(r_x * t_y);
R += (double)src.raw_img[(y2*srcW + x2)*3 + 0]*(l_x * t_y);
G += (double)src.raw_img[(y2*srcW + x2)*3 + 1]*(l_x * t_y);
B += (double)src.raw_img[(y2*srcW + x2)*3 + 2]*(l_x * t_y);
p[0] = (unsigned char) R;
p[1] = (unsigned char) G;
p[2] = (unsigned char) B;
}
// 快速補值
inline static void fast_NearestNeighbor_rgb(unsigned char* p,
const basic_ImgData& src, double y, double x)
{
// 位置(四捨五入)
int _x = (int)(x+0.5);
int _y = (int)(y+0.5);
int srcW = src.width;
int srcH = src.height;
// 計算RGB
double R , G, B;
int x2 = (_x+1) > src.width -1? src.width -1: _x+1;
int y2 = (_y+1) > src.height-1? src.height-1: _y+1;
R = (double)src.raw_img[(y2*srcW + x2) *3 + 0];
G = (double)src.raw_img[(y2*srcW + x2) *3 + 1];
B = (double)src.raw_img[(y2*srcW + x2) *3 + 2];
p[0] = (unsigned char) R;
p[1] = (unsigned char) G;
p[2] = (unsigned char) B;
}
// 圖像縮放
void WarpScale(const basic_ImgData &src, basic_ImgData &dst, double ratio){
int newH = (int)((src.height * ratio) +0.5);
int newW = (int)((src.width * ratio) +0.5);
// 初始化 dst
dst.raw_img.resize(newW * newH * src.bits/8.0);
dst.width = newW;
dst.height = newH;
dst.bits = src.bits;
// 縮小的倍率
double r1W = ((double)src.width )/(dst.width );
double r1H = ((double)src.height)/(dst.height);
// 放大的倍率
double r2W = (src.width -1.0)/(dst.width -1.0);
double r2H = (src.height-1.0)/(dst.height-1.0);
// 縮小時候的誤差
double deviW = ((src.width-1.0) - (dst.width -1.0)*(r1W)) /dst.width;
double deviH = ((src.height-1.0) - (dst.height-1.0)*(r1H)) /dst.height;
// 跑新圖座標
#pragma omp parallel for
for (int j = 0; j < newH; ++j) {
for (int i = 0; i < newW; ++i) {
// 調整對齊
double srcY, srcX;
if (ratio < 1.0) {
srcX = i*(r1W+deviW);
srcY = j*(r1H+deviH);
} else if (ratio >= 1.0) {
srcX = i*r2W;
srcY = j*r2H;
}
// 獲取插補值
unsigned char* p = &dst.raw_img[(j*newW + i) *3];
fast_Bilinear_rgb(p, src, srcY, srcX);
}
}
}
//==================================================================================
// 模糊圖片
//==================================================================================
// 高斯核心
static vector<double> getGaussianKernel(int n, double sigma)
{
const int SMALL_GAUSSIAN_SIZE = 7;
static const float small_gaussian_tab[][SMALL_GAUSSIAN_SIZE] =
{
{1.f},
{0.25f, 0.5f, 0.25f},
{0.0625f, 0.25f, 0.375f, 0.25f, 0.0625f},
{0.03125f, 0.109375f, 0.21875f, 0.28125f, 0.21875f, 0.109375f, 0.03125f}
};
const float* fixed_kernel = n % 2 == 1 && n <= SMALL_GAUSSIAN_SIZE && sigma <= 0 ?
small_gaussian_tab[n>>1] : 0;
vector<double> kernel(n);
double* cd = kernel.data();
double sigmaX = sigma > 0 ? sigma : ((n-1)*0.5 - 1)*0.3 + 0.8;
double scale2X = -0.5/(sigmaX*sigmaX);
double sum = 0;
int i;
for( i = 0; i < n; i++ )
{
double x = i - (n-1)*0.5;
double t = fixed_kernel ? (double)fixed_kernel[i] : std::exp(scale2X*x*x);
cd[i] = t;
sum += cd[i];
}
sum = 1./sum;
for( i = 0; i < n; i++ )
{
cd[i] *= sum;
}
return kernel;
}
// 高斯模糊
void GaussianBlurX(const basic_ImgData& src, basic_ImgData& dst, size_t mat_len, double p=0)
{
Timer t1;
size_t width = src.width;
size_t height = src.height;
vector<double> gau_mat = getGaussianKernel(mat_len, p);
// 初始化 dst
dst.raw_img.resize(width*height * src.bits/8.0);
dst.width = width;
dst.height = height;
dst.bits = src.bits;
// 緩存
//vector<double> img_gauX(width*height*3);
// 高斯模糊 X 軸
const size_t r = gau_mat.size() / 2;
#pragma omp parallel for
for (int j = 0; j < height; ++j) {
for (int i = 0; i < width; ++i) {
double sumR = 0;
double sumG = 0;
double sumB = 0;
for (int k = 0; k < gau_mat.size(); ++k) {
int idx = i-r + k;
// idx超出邊緣處理
if (idx < 0) {
idx = 0;
} else if (idx >(int)(width-1)) {
idx = (width-1);
}
sumR += (double)src.raw_img[(j*width + idx)*3 + 0] * gau_mat[k];
sumG += (double)src.raw_img[(j*width + idx)*3 + 1] * gau_mat[k];
sumB += (double)src.raw_img[(j*width + idx)*3 + 2] * gau_mat[k];
}
dst.raw_img[(j*width + i)*3 + 0] = sumR;
dst.raw_img[(j*width + i)*3 + 1] = sumG;
dst.raw_img[(j*width + i)*3 + 2] = sumB;
}
}
// 高斯模糊 Y 軸
/*#pragma omp parallel for
for (int j = 0; j < height; ++j) {
for (int i = 0; i < width; ++i) {
double sumR = 0;
double sumG = 0;
double sumB = 0;
for (int k = 0; k < gau_mat.size(); ++k) {
int idx = j-r + k;
// idx超出邊緣處理
if (idx < 0) {
idx = 0;
} else if (idx > (int)(height-1)) {
idx = (height-1);
}
sumR += img_gauX[(idx*width + i)*3 + 0] * gau_mat[k];
sumG += img_gauX[(idx*width + i)*3 + 1] * gau_mat[k];
sumB += img_gauX[(idx*width + i)*3 + 2] * gau_mat[k];
}
dst.raw_img[(j*width + i)*3 + 0] = sumR;
dst.raw_img[(j*width + i)*3 + 1] = sumG;
dst.raw_img[(j*width + i)*3 + 2] = sumB;
}
}*/
}
// 積分模糊
void Lowpass(const basic_ImgData& src, basic_ImgData& dst) {
int d=5;
// 初始化 dst
dst.raw_img.resize(src.width * src.height* src.bits/8.0);
dst.width = src.width;
dst.height = src.height;
dst.bits = src.bits;
int radius = (d-1) *0.5;
// 開始跑圖(邊緣扣除半徑)
#pragma omp parallel for
for (int j = 0; j < src.height; j++) {
for (int i = 0; i < src.width; i++) {
int r_t=0, g_t=0, b_t=0;
// 半徑內平均
for (int dy = -radius; dy <= radius; dy++) {
for (int dx = -radius; dx <= radius; dx++) {
int yy = (j+dy)<0? 0:(j+dy);
int xx = (i+dx)<0? 0:(i+dx);
if (yy > dst.height-1) yy = dst.height-1;
if (xx > dst.width-1) xx = dst.width-1;
int posi = (yy*src.width + xx)*3;
r_t += src.raw_img[posi +0];
g_t += src.raw_img[posi +1];
b_t += src.raw_img[posi +2];
}
}
dst.raw_img[(j*src.width+i)*3 +0] = r_t /(d*d);
dst.raw_img[(j*src.width+i)*3 +1] = g_t /(d*d);
dst.raw_img[(j*src.width+i)*3 +2] = b_t /(d*d);
}
}
}
// 高斯矩陣
static vector<double> getGauKer(int x){
vector<double> kernel(x);
double half = (x-1) / 2.f;
constexpr double rlog5_2 = -0.721348; // 1 / (2.f*log(0.5f))
double sigma = sqrt( -powf(x-1-half, 2.f) * rlog5_2 );
double rSigma22 = 1.0/(2 * sigma * sigma);
//#pragma omp parallel for
for(int i = 0; i < x; i++){
float g;
if(i <= (x - half)){
g = exp( -(i*i*rSigma22) );
} else{
g = 1.0 - exp(-powf(x-i-1, 2.f) * rSigma22);
}
kernel[i] = g;
}
return kernel;
}
//==================================================================================
// 金字塔處理
//==================================================================================
void pyraUp(const basic_ImgData &src, basic_ImgData &dst) {
int newH = (int)(src.height * 2.0);
int newW = (int)(src.width * 2.0);
// 初始化 dst
dst.raw_img.resize(newW * newH * src.bits/8.0);
dst.width = newW;
dst.height = newH;
dst.bits = src.bits;
basic_ImgData temp;
WarpScale(src, temp, 2.0);
GaussianBlurX(temp, dst, 3);
}
void pyraDown(const basic_ImgData &src, basic_ImgData &dst) {
//Timer t1;
int newH = (int)(src.height * 0.5);
int newW = (int)(src.width * 0.5);
// 初始化 dst
dst.raw_img.clear();
dst.raw_img.resize(newW * newH * src.bits/8.0);
dst.width = newW;
dst.height = newH;
dst.bits = src.bits;
basic_ImgData temp;
WarpScale(src, temp, 0.5);
GaussianBlurX(temp, dst, 3);
}
void imgSub(basic_ImgData &src, const basic_ImgData &dst) {
int i, j;
#pragma omp parallel for private(i, j)
for (j = 0; j < src.height; j++) {
for (i = 0; i < src.width; i++) {
int srcIdx = (j*src.width + i) * 3;
int dstIdx = (j*dst.width + i) * 3;
int pixR = (int)src.raw_img[srcIdx+0] - (int)dst.raw_img[dstIdx+0] +128;
int pixG = (int)src.raw_img[srcIdx+1] - (int)dst.raw_img[dstIdx+1] +128;
int pixB = (int)src.raw_img[srcIdx+2] - (int)dst.raw_img[dstIdx+2] +128;
pixR = pixR <0? 0: pixR;
pixG = pixG <0? 0: pixG;
pixB = pixB <0? 0: pixB;
pixR = pixR >255? 255: pixR;
pixG = pixG >255? 255: pixG;
pixB = pixB >255? 255: pixB;
src.raw_img[srcIdx+0] = pixR;
src.raw_img[srcIdx+1] = pixG;
src.raw_img[srcIdx+2] = pixB;
}
}
}
void imgAdd(basic_ImgData &src, const basic_ImgData &dst) {
int i, j;
#pragma omp parallel for private(i, j)
for (j = 0; j < src.height; j++) {
for (i = 0; i < src.width; i++) {
int srcIdx = (j*src.width + i) * 3;
int dstIdx = (j*dst.width + i) * 3;
int pixR = (int)src.raw_img[srcIdx+0] + (int)dst.raw_img[dstIdx+0] -128;
int pixG = (int)src.raw_img[srcIdx+1] + (int)dst.raw_img[dstIdx+1] -128;
int pixB = (int)src.raw_img[srcIdx+2] + (int)dst.raw_img[dstIdx+2] -128;
pixR = pixR <0? 0: pixR;
pixG = pixG <0? 0: pixG;
pixB = pixB <0? 0: pixB;
pixR = pixR >255? 255: pixR;
pixG = pixG >255? 255: pixG;
pixB = pixB >255? 255: pixB;
src.raw_img[srcIdx+0] = pixR;
src.raw_img[srcIdx+1] = pixG;
src.raw_img[srcIdx+2] = pixB;
}
}
}
// 金字塔
using LapPyr = vector<basic_ImgData>;
void buildPyramids(const basic_ImgData &src, vector<basic_ImgData> &pyr, int octvs=5) {
pyr.clear();
pyr.resize(octvs);
pyr[0]=src;
for(int i = 1; i < octvs; i++) {
pyraDown(pyr[i-1], pyr[i]);
}
}
void buildLaplacianPyramids(const basic_ImgData &src, LapPyr &pyr, int octvs=5) {
Timer t1;
t1.priSta=0;
pyr.clear();
pyr.resize(octvs);
pyr[0]=src;
for(int i = 1; i < octvs; i++) {
basic_ImgData expend;
t1.start();
pyraDown(pyr[i-1], pyr[i]); // 0.6
t1.print(" pyraDown");
t1.start();
WarpScale(pyr[i], expend, 2.0); // 0.5
t1.print(" WarpScale");
imgSub(pyr[i-1], expend);
}
}
void reLaplacianPyramids(LapPyr &pyr, basic_ImgData &dst, int octvs=5) {
Timer t1;
int newH = (int)(pyr[0].height);
int newW = (int)(pyr[0].width);
// 初始化 dst
dst.raw_img.clear();
dst.raw_img.resize(newW * newH * pyr[0].bits/8.0);
dst.width = newW;
dst.height = newH;
dst.bits = pyr[0].bits;
for(int i = octvs-1; i >= 1; i--) {
basic_ImgData expend;
WarpScale(pyr[i], expend, 2.0);
imgAdd(pyr[i-1], expend);
}
dst = pyr[0];
}
// 混合拉普拉斯金字塔
void imgBlendHalf(const basic_ImgData& imgA, const basic_ImgData& imgB, basic_ImgData& dst) {
#pragma omp parallel for
for(int j = 0; j < dst.height; j++) {
for(int i = 0; i < dst.width; i++) {
for(int rgb = 0; rgb < 3; rgb++) {
int dstIdx = (j* dst.width+i)*3;
int LAIdx = (j*imgA.width+i)*3;
int LBIdx = (j*imgB.width+i)*3;
int center = dst.width >>1;
// 拉普拉斯差值區 (左邊就放左邊差值,右邊放右邊差值,正中間放平均)
if(i == center) {// 正中間
dst.raw_img[dstIdx +rgb] = (imgA.raw_img[LAIdx +rgb] + imgB.raw_img[LBIdx +rgb]) >>1;
} else if(i > center) {// 右半部
dst.raw_img[dstIdx +rgb] = imgB.raw_img[LBIdx +rgb];
} else { // 左半部
dst.raw_img[dstIdx +rgb] = imgA.raw_img[LAIdx +rgb];
}
}
}
}
}
void imgBlendAlpha(const basic_ImgData& imgA, const basic_ImgData& imgB, basic_ImgData& dst) {
double rat = 1.0 / dst.width;
#pragma omp parallel for
for(int j = 0; j < dst.height; j++) {
for(int i = 0; i < dst.width; i++) {
for(int rgb = 0; rgb < 3; rgb++) {
int dstIdx = (j* dst.width +i)*3;
int LAIdx = (j*imgA.width +i)*3;
int LBIdx = (j*imgB.width +i)*3;
double r1 = rat*i;
double r2 = 1.0-r1;
dst.raw_img[dstIdx +rgb] = imgA.raw_img[LAIdx +rgb]*r2 + imgB.raw_img[LBIdx +rgb]*r1;
}
}
}
}
void blendLaplacianPyramids(LapPyr& LS, const LapPyr& LA, const LapPyr& LB) {
LS.resize(LA.size());
// 混合圖片
for(int idx = 0; idx < LS.size(); idx++) {
// 初始化
basic_ImgData& dst = LS[idx];
ImgData_resize(dst, LA[idx].width, LA[idx].height, LA[idx].bits);
// 開始混合各層
if(idx == LS.size()-1) {
imgBlendAlpha(LA[idx], LB[idx], dst);
} else {
imgBlendHalf(LA[idx], LB[idx], dst);
}
}
}
void blendLaplacianPyramids2(LapPyr& LS, const LapPyr& LA, const LapPyr& LB) {
LS.resize(LA.size());
// 高斯矩陣
auto gausKernal = getGauKer(LA.back().width);
// 混合圖片
for(int idx = 0; idx < LS.size(); idx++) {
// 初始化
ImgData_resize(LS[idx], LA[idx].width, LA[idx].height, LA[idx].bits);
// 捷徑
basic_ImgData& dst = LS[idx];
const basic_ImgData& imgA = LA[idx];
const basic_ImgData& imgB = LB[idx];
// 開始混合各層
#pragma omp parallel for
for(int j = 0; j < dst.height; j++) {
for(int i = 0; i < dst.width; i++) {
for(int rgb = 0; rgb < 3; rgb++) {
int dstIdx = (j*dst.width + i) * 3;
int LAIdx = (j*LA[idx].width+i)*3;
int LBIdx = (j*LB[idx].width+i)*3;
int center = dst.width >>1;
if(idx == LS.size()-1) {
// 拉普拉斯彩色區 (L*高斯) + (R*(1-高斯))
dst.raw_img[dstIdx +rgb] =
LA[idx].raw_img[LAIdx +rgb] * gausKernal[i] +
LB[idx].raw_img[LBIdx +rgb] * (1.f - gausKernal[i]);
} else {
// 拉普拉斯差值區 (左邊就放左邊差值,右邊放右邊差值,正中間放平均)
if(i == center) {// 正中間
dst.raw_img[dstIdx +rgb] = (imgA.raw_img[LAIdx +rgb] + imgB.raw_img[LBIdx +rgb]) >>1;
} else if(i > center) {// 右半部
dst.raw_img[dstIdx +rgb] = imgB.raw_img[LBIdx +rgb];
} else { // 左半部
dst.raw_img[dstIdx +rgb] = imgA.raw_img[LAIdx +rgb];
}
}
}
}
}
}
}
// 混合圖片
void blendLaplacianImg(basic_ImgData& dst, const basic_ImgData& src1, const basic_ImgData& src2) {
Timer t1;
t1.priSta=0;
// 拉普拉斯金字塔 AB
vector<basic_ImgData> LA, LB;
t1.start();
buildLaplacianPyramids(src1, LA);
t1.print(" buildLapA");
t1.start();
buildLaplacianPyramids(src2, LB);
t1.print(" buildLapB");
// 混合金字塔
LapPyr LS;
t1.start();
blendLaplacianPyramids(LS, LA, LB);
t1.print(" blendImg");
// 還原拉普拉斯金字塔
t1.start();
reLaplacianPyramids(LS, dst);
t1.print(" rebuildLaplacianPyramids");
}
//==================================================================================
// 圓柱投影
//==================================================================================
// 圓柱投影座標反轉換
inline static void WarpCylindrical_CoorTranfer_Inve(double R,
size_t width, size_t height,
double& x, double& y)
{
double r2 = (x - width*.5);
double k = sqrt(R*R + r2*r2) / R;
x = (x - width *.5)*k + width *.5;
y = (y - height*.5)*k + height*.5;
}
// 圓柱投影 basic_ImgData
void WarpCylindrical(basic_ImgData &dst, const basic_ImgData &src,
double R ,int mx, int my, double edge)
{
int w = src.width;
int h = src.height;
int moveH = (h*edge) + my;
unsigned int moveW = mx;
dst.raw_img.clear();
dst.raw_img.resize((w+moveW)*3 *h *(1+edge*2));
dst.width = w+moveW;
dst.height = h * (1+edge*2);
// 圓柱投影
#pragma omp parallel for
for (int j = 0; j < h; j++){
for (int i = 0; i < w; i++){
double x = i, y = j;
WarpCylindrical_CoorTranfer_Inve(R, w, h, x, y);
if (x >= 0 && y >= 0 && x < w - 1 && y < h - 1) {
unsigned char* p = &dst.raw_img[((j+moveH)*(w+moveW) + (i+moveW)) *3];
fast_Bilinear_rgb(p, src, y, x);
}
}
}
}
// 找到圓柱投影角點
void WarpCyliCorner(const basic_ImgData &src, vector<int>& corner) {
corner.resize(4);
// 左上角角點
for (int i = 0; i < src.width; i++) {
int pix = (int)src.raw_img[(src.height/2*src.width +i)*3 +0];
if (i<src.width/2 and pix != 0) {
corner[0]=i;
//cout << "corner=" << corner[0] << endl;
i=src.width/2;
} else if (i>src.width/2 and pix == 0) {
corner[2] = i-1;
//cout << "corner=" << corner[2] << endl;
break;
}
}
// 右上角角點
for (int i = 0; i < src.height; i++) {
int pix = (int)src.raw_img[(i*src.width +corner[0])*3 +0];
if (i<src.height/2 and pix != 0) {
corner[1] = i;
//cout << "corner=" << corner[2] << endl;
i=src.height/2;
} else if (i>src.height/2 and pix == 0) {
corner[3] = i-1;
//cout << "corner=" << corner[3] << endl;
break;
}
}
}
// 刪除左右黑邊
void delPillarboxing(const basic_ImgData &src, basic_ImgData &dst,
vector<int>& corner)
{
// 新圖大小
int newH=src.height;
int newW=corner[2]-corner[0];
ImgData_resize(dst, newW, newH, 24);
#pragma omp parallel for
for (int j = 0; j < newH; j++) {
for (int i = 0; i < newW; i++) {
for (int rgb = 0; rgb < 3; rgb++) {
dst.raw_img[(j*dst.width+i)*3 +rgb] =
src.raw_img[(j*src.width+(i+corner[0]))*3 +rgb];
}
}
}
ImgData_write(dst, "delPillarboxing.bmp");
}
// 取出重疊區
void getOverlap(const basic_ImgData &src1, const basic_ImgData &src2,
basic_ImgData& cut1, basic_ImgData& cut2, vector<int> corner)
{
// 偏移量
int mx=corner[4];
int my=corner[5];
// 新圖大小
int newH=corner[3]-corner[1]-abs(my);
int newW=corner[2]-corner[0]+mx;
// 重疊區大小
int lapH=newH;
int lapW=corner[2]-corner[0]-mx;
// 兩張圖的高度偏差值
int myA = my<0? 0:my;
int myB = my>0? 0:-my;
// 重疊區
ImgData_resize(cut1, lapW, lapH, 24);
ImgData_resize(cut2, lapW, lapH, 24);
#pragma omp parallel for
for (int j = 0; j < newH; j++) {
for (int i = 0; i < newW-mx; i++) {
// 圖1
if (i < corner[2]-corner[0]-mx) {
for (int rgb = 0; rgb < 3; rgb++) {
cut1.raw_img[(j*cut1.width +i) *3+rgb] =
src1.raw_img[(((j+myA)+corner[1])*src1.width +(i+corner[0]+mx)) *3+rgb];
}
}
// 圖2
if (i >= mx) {
for (int rgb = 0; rgb < 3; rgb++) {
cut2.raw_img[(j*cut2.width +(i-mx)) *3+rgb] =
src2.raw_img[(((j+myB)+corner[1])*src1.width +((i-mx)+corner[0])) *3+rgb];
}
}
}
}
//ImgData_write(cut1, "__cut1.bmp");
//ImgData_write(cut2, "__cut2.bmp");
}
void getOverlap_noncut(const basic_ImgData &src1, const basic_ImgData &src2,
basic_ImgData& cut1, basic_ImgData& cut2, vector<int> corner)
{
// 偏移量
int mx=corner[4];
int my=corner[5];
// 新圖大小
int newH=src1.height+abs(my);
int newW=corner[2]-corner[0]+mx;
// 重疊區大小
int lapH=newH;
int lapW=corner[2]-corner[0]-mx;
// 兩張圖的高度偏差值
int myA = my>0? 0:-my;
int myB = my<0? 0:my;
// 重疊區
ImgData_resize(cut1, lapW, lapH, 24);
ImgData_resize(cut2, lapW, lapH, 24);
#pragma omp parallel for
for (int j = 0; j < newH; j++) {
for (int i = 0; i < newW-mx; i++) {
// 圖1
if (i < corner[2]-corner[0]-mx and j<src1.height-1) {
for (int rgb = 0; rgb < 3; rgb++) {
cut1.raw_img[((j+myA)*cut1.width +i) *3+rgb]
= src1.raw_img[((j)*src1.width +(i+corner[0]+mx)) *3+rgb];
}
}
// 圖2
if (i >= mx and j<src2.height-1) {
for (int rgb = 0; rgb < 3; rgb++) {
cut2.raw_img[((j+myB)*cut2.width +(i-mx)) *3+rgb] =
src2.raw_img[((j)*src1.width +((i-mx)+corner[0])) *3+rgb];
}
}
}
}
//ImgData_write(cut1, "__cut1.bmp");
//ImgData_write(cut2, "__cut2.bmp");
}
// 重疊區與兩張原圖合併
void mergeOverlap(const basic_ImgData &src1, const basic_ImgData &src2,
const basic_ImgData &blend, basic_ImgData &dst, vector<int> corner)
{
// 偏移量
int mx=corner[4];
int my=corner[5];
// 新圖大小
int newH=corner[3]-corner[1]-abs(my);
int newW=corner[2]-corner[0]+mx;
ImgData_resize(dst, newW, newH, 24);
// 兩張圖的高度偏差值
int myA = my<0? 0:my;
int myB = my>0? 0:-my;
// 合併圖片
#pragma omp parallel for
for (int j = 0; j < newH; j++) {
for (int i = 0; i < newW; i++) {
// 圖1
if (i < mx) {
for (int rgb = 0; rgb < 3; rgb++) {
dst.raw_img[(j*dst.width +i) *3+rgb] = src1.raw_img[(((j+myA)+corner[1])*src1.width +(i+corner[0])) *3+rgb];
}
}
// 重疊區
else if (i >= mx and i < corner[2]-corner[0]) {
for (int rgb = 0; rgb < 3; rgb++) {
dst.raw_img[(j*dst.width +i) *3+rgb] = blend.raw_img[(j*blend.width+(i-mx)) *3+rgb];
}
}
// 圖2
else if (i >= corner[2]-corner[0]) {
for (int rgb = 0; rgb < 3; rgb++) {
dst.raw_img[(j*dst.width +i) *3+rgb] = src2.raw_img[(((j+myB)+corner[1])*src1.width +((i-mx)+corner[0])) *3+rgb];
}
}
}
}
}
void mergeOverlap_noncut(const basic_ImgData &src1, const basic_ImgData &src2,
const basic_ImgData &blend, basic_ImgData &dst, vector<int> corner)
{
// 偏移量
int mx=corner[4];
int my=corner[5];
// 新圖大小
int newH=src1.height+abs(my);
int newW=corner[2]-corner[0]+mx;
ImgData_resize(dst, newW, newH, 24);
// 兩張圖的高度偏差值
int myA = my>0? 0:-my;
int myB = my<0? 0:my;
// 合併圖片
#pragma omp parallel for
for (int j = 0; j < newH; j++) {
for (int i = 0; i < newW; i++) {
// 圖1
if (i < mx and j<src1.height-1) {
for (int rgb = 0; rgb < 3; rgb++) {
dst.raw_img[((j+myA)*dst.width +i) *3+rgb] =
src1.raw_img[(((j))*src1.width +(i+corner[0])) *3+rgb];
}
}
// 重疊區
else if (i >= mx and i < corner[2]-corner[0]) {
for (int rgb = 0; rgb < 3; rgb++) {
dst.raw_img[(j*dst.width +i) *3+rgb] =
blend.raw_img[(j*blend.width+(i-mx)) *3+rgb];
}
}
// 圖2
else if (i >= corner[2]-corner[0] and j<src2.height) {
for (int rgb = 0; rgb < 3; rgb++) {
dst.raw_img[((j+myB)*dst.width +i) *3+rgb] =
src2.raw_img[((j)*src1.width +((i-mx)+corner[0])) *3+rgb];
}
}
}
}
}
// 混合兩張投影過(未裁減)的圓柱,過程會自動裁減輸出
void WarpCyliMuitBlend(basic_ImgData &dst,
const basic_ImgData &src1, const basic_ImgData &src2,
int mx, int my)
{
// 檢測圓柱圖角點(minX, minY, maxX, maxY, mx, my)
vector<int> corner;
WarpCyliCorner(src1, corner);
corner.push_back(mx);
corner.push_back(my);
// 取出重疊區
basic_ImgData cut1, cut2;
getOverlap(src1, src2, cut1, cut2, corner);
// 混合重疊區
basic_ImgData blend;
blendLaplacianImg(blend, cut1, cut2);
// 合併三張圖片
mergeOverlap(src1, src2, blend, dst, corner);
}
//==================================================================================
// 公開函式
//==================================================================================
// 混合原始圖
void LapBlender(basic_ImgData &dst,
const basic_ImgData &src1, const basic_ImgData &src2,
double ft, int mx, int my)
{
basic_ImgData warp1, warp2;
WarpCylindrical(warp1, src1, ft, 0, 0, 0);
WarpCylindrical(warp2, src2, ft, 0, 0, 0);
//ImgData_write(warp1, "warp1.bmp");
//ImgData_write(warp2, "warp2.bmp");
WarpCyliMuitBlend(dst, warp1, warp2, mx, my);
}
// 範例程式
void LapBlend_Tester() {
basic_ImgData src1, src2, dst;
string name1, name2;
double ft; int Ax, Ay;
// 籃球 (1334x1000, 237ms) 80~100ms
name1="srcIMG\\ball_01.bmp", name2="srcIMG\\ball_02.bmp"; ft=2252.97, Ax=539, Ay=-37;
// 校園 (752x500, 68ms)
//name1="srcIMG\\sc02.bmp", name2="srcIMG\\sc03.bmp"; ft=676.974, Ax=216, Ay=4;
// 讀取圖片
ImgData_read(src1, name1);
ImgData_read(src2, name2);
// 混合圖片
Timer t1;
t1.start();
LapBlender(dst, src1, src2, ft, Ax, Ay);
t1.print(" LapBlender");
// 輸出圖片
ImgData_write(dst, "_WarpCyliMuitBlend.bmp");
}
//==================================================================================
| [
"hunandy14@gmail.com"
] | hunandy14@gmail.com |
dc124d41859c3b50fa2b6b3f26ed2e5f2b0d4303 | 112c3c38bb126eea23ea75d17512f51ae8aec26d | /third_party/Windows-CalcEngine/src/SingleLayerOptics/src/DirectionalDiffuseBSDFLayer.hpp | d64dac7abf9b1834b99f971044d0830c2debb26b | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | tsbyq/EnergyPlus | 1c49fe8e356009d904cff23c9b7640e13d77f72b | 208212976a28f796b2181f8bef621f050518f96d | refs/heads/develop | 2021-07-06T06:56:40.049207 | 2019-02-09T12:27:12 | 2019-02-09T12:27:12 | 136,358,541 | 2 | 0 | NOASSERTION | 2019-02-07T00:39:29 | 2018-06-06T16:46:56 | C++ | UTF-8 | C++ | false | false | 1,003 | hpp | #ifndef DIRECTIONALDIFFUSEBSDFLAYER_H
#define DIRECTIONALDIFFUSEBSDFLAYER_H
#include <memory>
#include "BSDFLayer.hpp"
namespace SingleLayerOptics {
class CDirectionalDiffuseCell;
// All outgoing directions are calculated
class CDirectionalDiffuseBSDFLayer : public CBSDFLayer {
public:
CDirectionalDiffuseBSDFLayer( const std::shared_ptr< CDirectionalDiffuseCell >& t_Cell,
const std::shared_ptr< const CBSDFHemisphere >& t_Hemisphere );
protected:
std::shared_ptr< CDirectionalDiffuseCell > cellAsDirectionalDiffuse() const;
void calcDiffuseDistribution( const FenestrationCommon::Side aSide,
const CBeamDirection& t_Direction,
const size_t t_DirectionIndex );
void calcDiffuseDistribution_wv( const FenestrationCommon::Side aSide,
const CBeamDirection& t_Direction,
const size_t t_DirectionIndex );
};
}
#endif
| [
"dvvidanovic@lbl.gov"
] | dvvidanovic@lbl.gov |
e9c08be2951ec3a54831b8f731f3d742ff7e2015 | 9634c674c1b05dbf0d9583a8bb1f5a8e79c4ad6d | /Lab3_question70.cpp | 4388c37d07a51e3e513383a8cfb2c01953d9e763 | [] | no_license | shivammahapatra/NISER-CS141 | 3175f325f66699e644388354f9d220704bfb2a18 | 218b9b28ca6e46592c1cbd426e171047608c3fe3 | refs/heads/master | 2021-01-19T17:38:04.170288 | 2017-11-24T07:02:47 | 2017-11-24T07:02:47 | 101,077,411 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,513 | cpp | #include <iostream>
#include <string>
/*Program to convert Hexadecimal to Octal number system.*/
using namespace std;
int main()
{
int hexDigitToBinary[22] = {0, 1, 10, 11, 100, 101, 110, 111,
1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 1010, 1011, 1100, 1101, 1110, 1111};
char hexDigits[22] = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'a', 'b', 'c', 'd', 'e', 'f'};
char hexadecimal[30];
cout<<"Program to convert Hexadecimal to Octal number system.";
long long binary =0, octal;
int i = 0, j, index=0, multiple = 1, threeDig;
cout<<"\n \nEnter a hexadecimal number: ";
cin>>hexadecimal;
//converting hexadecimal to binary
for(i=0; hexadecimal[i] != '\0'; i++)
{
for(j = 0; j < 22; j++)
{
if(hexDigits[j] == hexadecimal[i])
{
binary = binary*10000 + hexDigitToBinary[j];
}
}
}
//Now Converting Binary Number to Octal Number
int num, dec=0,base=1,rem;
num=binary;
while (num > 0)
{
rem = num % 10;
dec = dec + rem * base;
base = base * 2;
num = num / 10;
}
int oct = 0;
i=1;
while (dec!=0)
{
rem= dec%8;
dec /= 8;
oct += rem*i;
i *= 10;
}
cout<<"\n \nThe required Octal digit is: "<<oct;
return 0;
}
| [
"noreply@github.com"
] | shivammahapatra.noreply@github.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.